Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

x86/mm: Disable 1GB direct mappings when disabling 2MB mappings

The kmemleak and debug_pagealloc features both disable using huge pages for
direct mappings so they can do cpa() on page level granularity in any context.

However they only do that for 2MB pages, which means 1GB pages can still be
used if the CPU supports it, unless disabled by a boot param, which is
non-obvious. Disable also 1GB pages when disabling 2MB pages.

Signed-off-by: Vlastimil Babka <vbabka@suse.cz>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Vegard Nossum <vegardno@ifi.uio.no>
Cc: linux-mm@kvack.org
Link: http://lkml.kernel.org/r/2be70c78-6130-855d-3dfa-d87bd1dd4fda@suse.cz
Signed-off-by: Ingo Molnar <mingo@kernel.org>

authored by

Vlastimil Babka and committed by
Ingo Molnar
d9ee35ac 8a524f80

+3 -3
+3 -3
arch/x86/mm/init.c
··· 161 161 162 162 static void __init probe_page_size_mask(void) 163 163 { 164 - #if !defined(CONFIG_KMEMCHECK) 165 164 /* 166 165 * For CONFIG_KMEMCHECK or pagealloc debugging, identity mapping will 167 166 * use small pages. 168 167 * This will simplify cpa(), which otherwise needs to support splitting 169 168 * large pages into small in interrupt context, etc. 170 169 */ 171 - if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled()) 170 + if (boot_cpu_has(X86_FEATURE_PSE) && !debug_pagealloc_enabled() && !IS_ENABLED(CONFIG_KMEMCHECK)) 172 171 page_size_mask |= 1 << PG_LEVEL_2M; 173 - #endif 172 + else 173 + direct_gbpages = 0; 174 174 175 175 /* Enable PSE if available */ 176 176 if (boot_cpu_has(X86_FEATURE_PSE))