Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 23 Apr 2026 18:16:22 +0000
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: c49cbf849dee - main - powerpc aim64: Return vm_paddr_t from moea64_bootstrap_alloc
Message-ID:  <69ea61f6.450b8.4a1d980a@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by jhb:

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

commit c49cbf849dee9121ed3b972df56d240068d0423e
Author:     John Baldwin <jhb@FreeBSD.org>
AuthorDate: 2026-04-23 17:05:54 +0000
Commit:     John Baldwin <jhb@FreeBSD.org>
CommitDate: 2026-04-23 17:05:54 +0000

    powerpc aim64: Return vm_paddr_t from moea64_bootstrap_alloc
    
    Consistently use vm_paddr_t for the type returned from
    moea64_bootstrap_alloc and avoid temporarily smuggling it via a
    pointer.  Instead, be explicit in the places that assume a 1:1
    mapping.
    
    Effort:         CHERI upstreaming
    Reviewed by:    kib
    Sponsored by:   AFRL, DARPA
    Pull Request:   https://github.com/freebsd/freebsd-src/pull/2068
---
 sys/powerpc/aim/mmu_oea64.c     | 17 ++++++++++-------
 sys/powerpc/aim/mmu_oea64.h     |  2 +-
 sys/powerpc/aim/mmu_radix.c     |  2 +-
 sys/powerpc/aim/moea64_native.c | 15 +++++++--------
 4 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index ac0444ddade0..ebc1f68bc063 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -1022,6 +1022,7 @@ moea64_early_bootstrap(vm_offset_t kernelstart, vm_offset_t kernelend)
 void
 moea64_mid_bootstrap(vm_offset_t kernelstart, vm_offset_t kernelend)
 {
+	vm_paddr_t	pa;
 	int		i;
 
 	/*
@@ -1054,14 +1055,15 @@ moea64_mid_bootstrap(vm_offset_t kernelstart, vm_offset_t kernelend)
 		    moea64_bpvo_pool_size*sizeof(struct pvo_entry) / 1048576);
 	}
 
-	moea64_bpvo_pool = (struct pvo_entry *)moea64_bootstrap_alloc(
-		moea64_bpvo_pool_size*sizeof(struct pvo_entry), PAGE_SIZE);
+	pa = moea64_bootstrap_alloc(
+	    moea64_bpvo_pool_size * sizeof(struct pvo_entry), PAGE_SIZE);
 	moea64_bpvo_pool_index = 0;
 
 	/* Place at address usable through the direct map */
 	if (hw_direct_map)
-		moea64_bpvo_pool = (struct pvo_entry *)
-		    PHYS_TO_DMAP((uintptr_t)moea64_bpvo_pool);
+		moea64_bpvo_pool = (struct pvo_entry *)PHYS_TO_DMAP(pa);
+	else
+		moea64_bpvo_pool = (struct pvo_entry *)pa;
 
 	/*
 	 * Make sure kernel vsid is allocated as well as VSID 0.
@@ -1106,7 +1108,8 @@ moea64_late_bootstrap(vm_offset_t kernelstart, vm_offset_t kernelend)
 	phandle_t	mmu;
 	ssize_t		sz;
 	int		i;
-	vm_offset_t	pa, va;
+	vm_paddr_t	pa;
+	vm_offset_t	va;
 	void		*dpcpu;
 
 	/*
@@ -2805,10 +2808,10 @@ moea64_remove_all(vm_page_t m)
  * Can only be called from moea64_bootstrap before avail start and end are
  * calculated.
  */
-vm_offset_t
+vm_paddr_t
 moea64_bootstrap_alloc(vm_size_t size, vm_size_t align)
 {
-	vm_offset_t	s, e;
+	vm_paddr_t	s, e;
 	int		i, j;
 
 	size = round_page(size);
diff --git a/sys/powerpc/aim/mmu_oea64.h b/sys/powerpc/aim/mmu_oea64.h
index bc93cf4d521d..1cb9072312b0 100644
--- a/sys/powerpc/aim/mmu_oea64.h
+++ b/sys/powerpc/aim/mmu_oea64.h
@@ -46,7 +46,7 @@ extern const struct mmu_kobj oea64_mmu;
  */
 
 /* Allocate physical memory for use in moea64_bootstrap. */
-vm_offset_t	moea64_bootstrap_alloc(vm_size_t size, vm_size_t align);
+vm_paddr_t	moea64_bootstrap_alloc(vm_size_t size, vm_size_t align);
 /* Set an LPTE structure to match the contents of a PVO */
 void	moea64_pte_from_pvo(const struct pvo_entry *pvo, struct lpte *lpte);
 
diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index 8b4c8ddcc578..cdfb979e2f87 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -893,7 +893,7 @@ pagezero(vm_offset_t va)
 static uint64_t
 allocpages(int n)
 {
-	u_int64_t ret;
+	vm_paddr_t ret;
 
 	ret = moea64_bootstrap_alloc(n * PAGE_SIZE, PAGE_SIZE);
 	for (int i = 0; i < n; i++)
diff --git a/sys/powerpc/aim/moea64_native.c b/sys/powerpc/aim/moea64_native.c
index b79da6c462ac..169a4da7598b 100644
--- a/sys/powerpc/aim/moea64_native.c
+++ b/sys/powerpc/aim/moea64_native.c
@@ -608,17 +608,16 @@ moea64_bootstrap_native(vm_offset_t kernelstart, vm_offset_t kernelend)
 	 * its own size. Pick the larger of the two, which works on all
 	 * systems.
 	 */
-	moea64_pteg_table = (struct lpte *)moea64_bootstrap_alloc(size, 
-	    MAX(256*1024, size));
+	pa = moea64_bootstrap_alloc(size, MAX(256*1024, size));
 	if (hw_direct_map)
-		moea64_pteg_table =
-		    (struct lpte *)PHYS_TO_DMAP((vm_offset_t)moea64_pteg_table);
+		moea64_pteg_table = (struct lpte *)PHYS_TO_DMAP(pa);
+	else
+		moea64_pteg_table = (struct lpte *)pa;
+
 	/* Allocate partition table (ISA 3.0). */
 	if (cpu_features2 & PPC_FEATURE2_ARCH_3_00) {
-		moea64_part_table =
-		    (struct pate *)moea64_bootstrap_alloc(PART_SIZE, PART_SIZE);
-		moea64_part_table =
-		    (struct pate *)PHYS_TO_DMAP((vm_offset_t)moea64_part_table);
+		pa = moea64_bootstrap_alloc(PART_SIZE, PART_SIZE);
+		moea64_part_table = (struct pate *)PHYS_TO_DMAP(pa);
 	}
 	DISABLE_TRANS(msr);
 	bzero(__DEVOLATILE(void *, moea64_pteg_table), moea64_pteg_count *


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?69ea61f6.450b8.4a1d980a>