With kernel commit 4ffe713b7587 ("powerpc/mm: Increase the max addressable
memory to 2PB"), MAX_PHYSMEM_BITS is bumped up to 51 for SPARSEMEM_VMEMMAP
and SPARSEMEM_EXTREME case. Make the appropriate update here.

Signed-off-by: Hari Bathini <[email protected]>
---
 defs.h  |    1 +
 ppc64.c |   33 ++++++++++++++++++++++++++-------
 2 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/defs.h b/defs.h
index b66ccad..9ce32c1 100644
--- a/defs.h
+++ b/defs.h
@@ -4093,6 +4093,7 @@ struct efi_memory_desc_t {
 #define _MAX_PHYSMEM_BITS      44
 #define _MAX_PHYSMEM_BITS_3_7   46
 #define _MAX_PHYSMEM_BITS_4_19  47
+#define _MAX_PHYSMEM_BITS_4_20  51
 
 #endif /* PPC64 */
 
diff --git a/ppc64.c b/ppc64.c
index 041480b..485fa9d 100644
--- a/ppc64.c
+++ b/ppc64.c
@@ -220,6 +220,31 @@ static int ppc64_is_vmaddr(ulong addr)
        return (vt->vmalloc_start && addr >= vt->vmalloc_start);
 }
 
+static int set_ppc64_max_physmem_bits(void)
+{
+       int dimension;
+
+       get_array_length("mem_section", &dimension, 0);
+
+       if ((machdep->flags & VMEMMAP) &&
+           (THIS_KERNEL_VERSION >= LINUX(4,20,0)) &&
+           !dimension && (machdep->pagesize == 65536)) {
+               /*
+                * SPARSEMEM_VMEMMAP & SPARSEMEM_EXTREME configurations with
+                * 64K pagesize and v4.20 kernel or later.
+                */
+               machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_20;
+       } else if ((machdep->flags & VMEMMAP) &&
+                  (THIS_KERNEL_VERSION >= LINUX(4,19,0))) {
+               /* SPARSEMEM_VMEMMAP & v4.19 kernel or later */
+               machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;
+       } else if (THIS_KERNEL_VERSION >= LINUX(3,7,0))
+               machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_3_7;
+       else
+               machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
+
+       return 0;
+}
 
 struct machine_specific ppc64_machine_specific = { 
        .hwintrstack = { 0 }, 
@@ -583,13 +608,7 @@ ppc64_init(int when)
                        ppc64_vmemmap_init();
 
                machdep->section_size_bits = _SECTION_SIZE_BITS;
-               if ((machdep->flags & VMEMMAP) &&
-                   (THIS_KERNEL_VERSION >= LINUX(4,19,0)))
-                       machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_4_19;
-               else if (THIS_KERNEL_VERSION >= LINUX(3,7,0))
-                       machdep->max_physmem_bits = _MAX_PHYSMEM_BITS_3_7;
-               else
-                       machdep->max_physmem_bits = _MAX_PHYSMEM_BITS;
+               set_ppc64_max_physmem_bits();
 
                ppc64_init_cpu_info();
                machdep->vmalloc_start = ppc64_vmalloc_start;

--
Crash-utility mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/crash-utility

Reply via email to