lkl: initialize mm constants before mem_init()#622
Open
lrh2000 wants to merge 1 commit intolkl:masterfrom
Open
lkl: initialize mm constants before mem_init()#622lrh2000 wants to merge 1 commit intolkl:masterfrom
lrh2000 wants to merge 1 commit intolkl:masterfrom
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
max_mapnr is accessed through the following call chain:
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().