]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
arm64: mm: fix incorrect assignment of 'max_mapnr'
authorMuchun Song <smuchun@gmail.com>
Sat, 30 Mar 2019 13:13:46 +0000 (21:13 +0800)
committerWill Deacon <will.deacon@arm.com>
Mon, 1 Apr 2019 14:35:48 +0000 (15:35 +0100)
Although we don't actually make use of the 'max_mapnr' global variable,
we do set it to a junk value for !CONFIG_FLATMEM configurations that
leave mem_map uninitialised.

To avoid somebody tripping over this in future, set 'max_mapnr' using
max_pfn, which is calculated directly from the memblock information.

Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Muchun Song <smuchun@gmail.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
arch/arm64/mm/init.c

index 6bc135042f5e4dc244dbf14e8ea953121931ad2b..c29b17b520cd7c9cad843dae40ba3ed90578732b 100644 (file)
@@ -535,7 +535,7 @@ void __init mem_init(void)
        else
                swiotlb_force = SWIOTLB_NO_FORCE;
 
-       set_max_mapnr(pfn_to_page(max_pfn) - mem_map);
+       set_max_mapnr(max_pfn - PHYS_PFN_OFFSET);
 
 #ifndef CONFIG_SPARSEMEM_VMEMMAP
        free_unused_memmap();