git: 2ee2ef607f60 - main - pmap: prefer memcpy over bcopy

From: Brooks Davis <brooks_at_FreeBSD.org>
Date: Sun, 21 Jun 2026 16:14:38 UTC
The branch main has been updated by brooks:

URL: https://cgit.FreeBSD.org/src/commit/?id=2ee2ef607f6087757efd62b814cbf2400ef58ef2

commit 2ee2ef607f6087757efd62b814cbf2400ef58ef2
Author:     Brooks Davis <brooks@FreeBSD.org>
AuthorDate: 2026-06-21 15:47:23 +0000
Commit:     Brooks Davis <brooks@FreeBSD.org>
CommitDate: 2026-06-21 16:08:12 +0000

    pmap: prefer memcpy over bcopy
    
    Alter pmap_copy_page(s) to use memcpy rather than the deprecated bcopy.
    We'll be adding non-provenance preserving versions for CHERI support and
    would like to avoid introducing variants of deprecated APIs just to
    maintain symmetry.
    
    Reviewed by:    kib
    Suggested by:   emaste
    Sponsored by:   Innovate UK
    Differential Revision:  https://reviews.freebsd.org/D57687
---
 sys/amd64/amd64/pmap.c |  2 +-
 sys/arm/arm/pmap-v6.c  | 10 +++++-----
 sys/arm64/arm64/pmap.c |  4 ++--
 sys/riscv/riscv/pmap.c |  4 ++--
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/sys/amd64/amd64/pmap.c b/sys/amd64/amd64/pmap.c
index 691fac8c89b4..b37700a53aec 100644
--- a/sys/amd64/amd64/pmap.c
+++ b/sys/amd64/amd64/pmap.c
@@ -8317,7 +8317,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
 		mapped = pmap_map_io_transient(pages, vaddr, 2, false);
 		a_cp = (char *)vaddr[0] + a_pg_offset;
 		b_cp = (char *)vaddr[1] + b_pg_offset;
-		bcopy(a_cp, b_cp, cnt);
+		memcpy(b_cp, a_cp, cnt);
 		if (__predict_false(mapped))
 			pmap_unmap_io_transient(pages, vaddr, 2, false);
 		a_offset += cnt;
diff --git a/sys/arm/arm/pmap-v6.c b/sys/arm/arm/pmap-v6.c
index 2b0ebebefaec..5fcfc663e292 100644
--- a/sys/arm/arm/pmap-v6.c
+++ b/sys/arm/arm/pmap-v6.c
@@ -2194,7 +2194,7 @@ pte1_copy_nosync(pt1_entry_t *spte1p, pt1_entry_t *dpte1p, vm_offset_t sva,
 
 	idx = pte1_index(sva);
 	count = (pte1_index(eva) - idx + 1) * sizeof(pt1_entry_t);
-	bcopy(spte1p + idx, dpte1p + idx, count);
+	memcpy(dpte1p + idx, spte1p + idx, count);
 }
 
 static __inline void
@@ -2205,7 +2205,7 @@ pt2tab_copy_nosync(pt2_entry_t *spte2p, pt2_entry_t *dpte2p, vm_offset_t sva,
 
 	idx = pt2tab_index(sva);
 	count = (pt2tab_index(eva) - idx + 1) * sizeof(pt2_entry_t);
-	bcopy(spte2p + idx, dpte2p + idx, count);
+	memcpy(dpte2p + idx, spte2p + idx, count);
 }
 
 /*
@@ -5926,7 +5926,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size)
 /*
  *	pmap_copy_page copies the specified (machine independent)
  *	page by mapping the page into virtual memory and using
- *	bcopy to copy the page, one machine dependent page at a
+ *	memcpy to copy the page, one machine dependent page at a
  *	time.
  */
 void
@@ -5948,7 +5948,7 @@ pmap_copy_page(vm_page_t src, vm_page_t dst)
 	    PTE2_AP_KR | PTE2_NM, vm_page_pte2_attr(src)));
 	pte2_store(cmap2_pte2p, PTE2_KERN_NG(VM_PAGE_TO_PHYS(dst),
 	    PTE2_AP_KRW, vm_page_pte2_attr(dst)));
-	bcopy(pc->pc_cmap1_addr, pc->pc_cmap2_addr, PAGE_SIZE);
+	memcpy(pc->pc_cmap2_addr, pc->pc_cmap1_addr, PAGE_SIZE);
 	pte2_clear(cmap1_pte2p);
 	tlb_flush((vm_offset_t)pc->pc_cmap1_addr);
 	pte2_clear(cmap2_pte2p);
@@ -5994,7 +5994,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
 		tlb_flush_local((vm_offset_t)pc->pc_cmap2_addr);
 		a_cp = pc->pc_cmap1_addr + a_pg_offset;
 		b_cp = pc->pc_cmap2_addr + b_pg_offset;
-		bcopy(a_cp, b_cp, cnt);
+		memcpy(b_cp, a_cp, cnt);
 		a_offset += cnt;
 		b_offset += cnt;
 		xfersize -= cnt;
diff --git a/sys/arm64/arm64/pmap.c b/sys/arm64/arm64/pmap.c
index 2eabdef6d27c..2ef639965deb 100644
--- a/sys/arm64/arm64/pmap.c
+++ b/sys/arm64/arm64/pmap.c
@@ -6988,7 +6988,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size)
 /*
  *	pmap_copy_page copies the specified (machine independent)
  *	page by mapping the page into virtual memory and using
- *	bcopy to copy the page, one machine dependent page at a
+ *	memcpy to copy the page, one machine dependent page at a
  *	time.
  */
 void
@@ -7043,7 +7043,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
 		} else {
 			b_cp = (char *)PHYS_TO_DMAP(p_b) + b_pg_offset;
 		}
-		bcopy(a_cp, b_cp, cnt);
+		memcpy(b_cp, a_cp, cnt);
 		a_offset += cnt;
 		b_offset += cnt;
 		xfersize -= cnt;
diff --git a/sys/riscv/riscv/pmap.c b/sys/riscv/riscv/pmap.c
index 1f3fd8c24b81..0461400f2a7c 100644
--- a/sys/riscv/riscv/pmap.c
+++ b/sys/riscv/riscv/pmap.c
@@ -4055,7 +4055,7 @@ pmap_zero_page_area(vm_page_t m, int off, int size)
 /*
  *	pmap_copy_page copies the specified (machine independent)
  *	page by mapping the page into virtual memory and using
- *	bcopy to copy the page, one machine dependent page at a
+ *	memcpy to copy the page, one machine dependent page at a
  *	time.
  */
 void
@@ -4098,7 +4098,7 @@ pmap_copy_pages(vm_page_t ma[], vm_offset_t a_offset, vm_page_t mb[],
 		} else {
 			b_cp = (char *)PHYS_TO_DMAP(p_b) + b_pg_offset;
 		}
-		bcopy(a_cp, b_cp, cnt);
+		memcpy(b_cp, a_cp, cnt);
 		a_offset += cnt;
 		b_offset += cnt;
 		xfersize -= cnt;