diff options
author | Michael Ellerman | 2018-08-14 22:37:32 +1000 |
---|---|---|
committer | Michael Ellerman | 2018-10-20 13:26:47 +1100 |
commit | 232aa407633cef2b43806c1603fc8689aecf826c (patch) | |
tree | 8e997292282b96b7811be5117fa14c274668abb4 /arch/powerpc | |
parent | 57306c663d53f2e4fd856950703dc6bcfc98f7cb (diff) |
powerpc/mm/radix: Simplify split mapping logic
If we look closely at the logic in create_physical_mapping(), when
we're doing STRICT_KERNEL_RWX, we do the following steps:
- determine the gap from where we are to the end of the range
- choose an appropriate mapping_size based on the gap
- check if that mapping_size would overlap the __init_begin
boundary, and if not choose an appropriate mapping_size
We can simplify the logic by taking the __init_begin boundary into
account when we calculate the initial gap.
So add a next_boundary() function which tells us what the next
boundary is, either the __init_begin boundary or end. In future we can
add more boundaries.
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc')
-rw-r--r-- | arch/powerpc/mm/pgtable-radix.c | 32 |
1 files changed, 10 insertions, 22 deletions
diff --git a/arch/powerpc/mm/pgtable-radix.c b/arch/powerpc/mm/pgtable-radix.c index 030543451229..0e87733eed80 100644 --- a/arch/powerpc/mm/pgtable-radix.c +++ b/arch/powerpc/mm/pgtable-radix.c @@ -255,17 +255,21 @@ static inline void __meminit print_mapping(unsigned long start, pr_info("Mapped 0x%016lx-0x%016lx with %s pages\n", start, end, buf); } +static unsigned long next_boundary(unsigned long addr, unsigned long end) +{ +#ifdef CONFIG_STRICT_KERNEL_RWX + if (addr < __pa_symbol(__init_begin)) + return __pa_symbol(__init_begin); +#endif + return end; +} + static int __meminit create_physical_mapping(unsigned long start, unsigned long end, int nid) { unsigned long vaddr, addr, mapping_size = 0; pgprot_t prot; -#ifdef CONFIG_STRICT_KERNEL_RWX - int split_text_mapping = 1; -#else - int split_text_mapping = 0; -#endif int psize; start = _ALIGN_UP(start, PAGE_SIZE); @@ -273,7 +277,7 @@ static int __meminit create_physical_mapping(unsigned long start, unsigned long gap, previous_size; int rc; - gap = end - addr; + gap = next_boundary(addr, end) - addr; previous_size = mapping_size; if (IS_ALIGNED(addr, PUD_SIZE) && gap >= PUD_SIZE && @@ -289,22 +293,6 @@ static int __meminit create_physical_mapping(unsigned long start, psize = mmu_virtual_psize; } - if (split_text_mapping && (mapping_size == PUD_SIZE) && - (addr < __pa_symbol(__init_begin)) && - (addr + mapping_size) > __pa_symbol(__init_begin)) { - if (mmu_psize_defs[MMU_PAGE_2M].shift) - mapping_size = PMD_SIZE; - else - mapping_size = PAGE_SIZE; - } - - if (split_text_mapping && (mapping_size == PMD_SIZE) && - (addr < __pa_symbol(__init_begin)) && - (addr + mapping_size) > __pa_symbol(__init_begin)) { - mapping_size = PAGE_SIZE; - psize = mmu_virtual_psize; - } - if (mapping_size != previous_size) { print_mapping(start, addr, previous_size); start = addr; |