git: 1364e7d0921b - main - powerpc64: Fix disappearing low memory on radix MMU systems (POWER9)

From: Timothy Pearson <tpearson_at_FreeBSD.org>
Date: Thu, 05 Feb 2026 16:42:06 UTC
The branch main has been updated by tpearson:

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

commit 1364e7d0921bfd79738dae80748d836730e39056
Author:     Timothy Pearson <tpearson@FreeBSD.org>
AuthorDate: 2026-02-04 05:16:39 +0000
Commit:     Timothy Pearson <tpearson@FreeBSD.org>
CommitDate: 2026-02-05 16:42:01 +0000

    powerpc64: Fix disappearing low memory on radix MMU systems (POWER9)
    
    The FreeBSD radix implementation piggybacks on the physical memory
    allocation function from the HPT implementation, but did not share
    the same state information for number of physical memory ranges.
    This led to a situation where the HPT physical memory allocator
    would attempt to shift the physical memory ranges in the shared
    range table, but would use the wrong number of entries, thus
    overwriting the large segment of low memory that should have been
    available for e.g. 32-bit DMA.
    
    Incorrect physical memory map:
    
    real memory  = 33997058048 (32422 MB)
    available KVA = 34359619583 (32767 MB)
    Physical memory chunk(s):
    0x0000000000003000 - 0x0000000000002fff, 0 bytes (0 pages)
    0x000000000000e000 - 0x000000000000ffff, 8192 bytes (2 pages)
    0x0000000000094000 - 0x0000000000ffffff, 16171008 bytes (3948 pages)
    0x0000000100000000 - 0x00000007a2042fff, 28487987200 bytes (6955075 pages)
    0x00000007d0006000 - 0x00000007fc72dfff, 745701376 bytes (182056 pages)
    0x00000007fdc00000 - 0x00000007ff79ffff, 28966912 bytes (7072 pages)
    0x00000007ff7d1000 - 0x00000007ff7effff, 126976 bytes (31 pages)
    avail memory = 29190103040 (27837 MB)
    FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs
    
    Correct physical memory map:
    
    real memory  = 33997058048 (32422 MB)
    available KVA = 34359619583 (32767 MB)
    Physical memory chunk(s):
    0x0000000000003000 - 0x0000000000002fff, 0 bytes (0 pages)
    0x000000000000e000 - 0x000000000000ffff, 8192 bytes (2 pages)
    0x0000000000094000 - 0x0000000000ffffff, 16171008 bytes (3948 pages)
    0x0000000002000000 - 0x000000000284ffff, 8716288 bytes (2128 pages)
    0x0000000004627000 - 0x000000002fffffff, 731746304 bytes (178649 pages)
    0x0000000034040000 - 0x00000000efffffff, 3153854464 bytes (769984 pages)
    0x0000000100000000 - 0x00000007982ecfff, 28323008512 bytes (6914797 pages)
    0x00000007cc20a000 - 0x00000007fc72dfff, 810696704 bytes (197924 pages)
    0x00000007fdc00000 - 0x00000007ff79ffff, 28966912 bytes (7072 pages)
    0x00000007ff7d1000 - 0x00000007ff7effff, 126976 bytes (31 pages)
    avail memory = 32984436736 (31456 MB)
    FreeBSD/SMP: Multiprocessor System Detected: 16 CPUs
    
    Signed-off-by: Timothy Pearson <tpearson@raptorengineering.com>
    Sponsored-by: Raptor Computing Systems, LLC
---
 sys/powerpc/aim/mmu_oea64.c | 3 ++-
 sys/powerpc/aim/mmu_oea64.h | 1 +
 sys/powerpc/aim/mmu_radix.c | 1 -
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/sys/powerpc/aim/mmu_oea64.c b/sys/powerpc/aim/mmu_oea64.c
index c82c5c539de2..a7042ffb02a9 100644
--- a/sys/powerpc/aim/mmu_oea64.c
+++ b/sys/powerpc/aim/mmu_oea64.c
@@ -164,9 +164,10 @@ extern void *slbtrap, *slbtrapend;
 static struct	mem_region *regions;
 static struct	mem_region *pregions;
 static struct	numa_mem_region *numa_pregions;
-static u_int	phys_avail_count;
 static int	regions_sz, pregions_sz, numapregions_sz;
 
+u_int	phys_avail_count;
+
 extern void bs_remap_earlyboot(void);
 
 /*
diff --git a/sys/powerpc/aim/mmu_oea64.h b/sys/powerpc/aim/mmu_oea64.h
index 38b743159980..bc93cf4d521d 100644
--- a/sys/powerpc/aim/mmu_oea64.h
+++ b/sys/powerpc/aim/mmu_oea64.h
@@ -139,5 +139,6 @@ extern u_long		moea64_pteg_count;
 extern u_long		moea64_pteg_mask;
 extern int		n_slbs;
 extern bool		moea64_has_lp_4k_16m;
+extern u_int		phys_avail_count;
 
 #endif /* _POWERPC_AIM_MMU_OEA64_H */
diff --git a/sys/powerpc/aim/mmu_radix.c b/sys/powerpc/aim/mmu_radix.c
index a12142fc2d7b..85008de83870 100644
--- a/sys/powerpc/aim/mmu_radix.c
+++ b/sys/powerpc/aim/mmu_radix.c
@@ -632,7 +632,6 @@ static unsigned int isa3_base_pid;
  */
 static struct	mem_region *regions, *pregions;
 static struct	numa_mem_region *numa_pregions;
-static u_int	phys_avail_count;
 static int	regions_sz, pregions_sz, numa_pregions_sz;
 static struct pate *isa3_parttab;
 static struct prte *isa3_proctab;