Commit 952bb32
committed
lkl: initialize mm constants before mem_init()
max_mapnr is accessed through the following call chain:
mem_init()
-> memblock_free_all()
-> free_low_memory_core_early()
-> memmap_init_reserved_pages()
-> reserve_bootmem_region()
-> pfn_valid()
-> (pfn - ARCH_PFN_OFFSET) < max_mapnr
In lkl, max_mapnr is currently initialized in mem_init(), but only after
memblock_free_all() runs. This means pfn_valid() can see an
uninitialized max_mapnr and incorrectly return false for pfns that
should be valid.
For example, reserve_bootmem_region() should mark such pages as
reserved, but due to this bug it does not.
Other architectures, such as riscv, x86, and arm64, initialize mm
constants before mem_init() from setup_arch(). Do the equivalent for lkl
by initializing max_pfn, max_low_pfn, min_low_pfn, and max_mapnr in
bootmem_init().
Signed-off-by: Ruihan Li <lrh2000@pku.edu.cn>1 parent 34d8dc9 commit 952bb32
1 file changed
+4
-5
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
50 | | - | |
51 | 49 | | |
52 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| |||
60 | 62 | | |
61 | 63 | | |
62 | 64 | | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | 65 | | |
67 | 66 | | |
68 | 67 | | |
| |||
0 commit comments