Skip to content

Commit 2b279c0

Browse files
chleroympe
authored andcommitted
powerpc/32s: Allow mapping with BATs with DEBUG_PAGEALLOC
DEBUG_PAGEALLOC only manages RW data. Text and RO data can still be mapped with BATs. In order to map with BATs, also enforce data alignment. Set by default to 256M which is a good compromise for keeping enough BATs for also KASAN and IMMR. Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/fd29c1718ee44d82115d0e835ced808eb4ccbf51.1589866984.git.christophe.leroy@csgroup.eu
1 parent a2feeb2 commit 2b279c0

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

arch/powerpc/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -797,6 +797,7 @@ config DATA_SHIFT
797797
range 17 28 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_BOOK3S_32
798798
range 19 23 if (STRICT_KERNEL_RWX || DEBUG_PAGEALLOC) && PPC_8xx
799799
default 22 if STRICT_KERNEL_RWX && PPC_BOOK3S_32
800+
default 18 if DEBUG_PAGEALLOC && PPC_BOOK3S_32
800801
default 23 if STRICT_KERNEL_RWX && PPC_8xx
801802
default 23 if DEBUG_PAGEALLOC && PPC_8xx && PIN_TLB_DATA
802803
default 19 if DEBUG_PAGEALLOC && PPC_8xx

arch/powerpc/mm/book3s32/mmu.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,12 @@ unsigned long __init mmu_mapin_ram(unsigned long base, unsigned long top)
170170
pr_debug("RAM mapped without BATs\n");
171171
return base;
172172
}
173+
if (debug_pagealloc_enabled()) {
174+
if (base >= border)
175+
return base;
176+
if (top >= border)
177+
top = border;
178+
}
173179

174180
if (!strict_kernel_rwx_enabled() || base >= border || top <= border)
175181
return __mmu_mapin_ram(base, top);

arch/powerpc/mm/init_32.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,10 +99,9 @@ static void __init MMU_setup(void)
9999
if (IS_ENABLED(CONFIG_PPC_8xx))
100100
return;
101101

102-
if (debug_pagealloc_enabled()) {
103-
__map_without_bats = 1;
102+
if (debug_pagealloc_enabled())
104103
__map_without_ltlbs = 1;
105-
}
104+
106105
if (strict_kernel_rwx_enabled())
107106
__map_without_ltlbs = 1;
108107
}

0 commit comments

Comments
 (0)