162306a36Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only 262306a36Sopenharmony_ciconfig PAGE_EXTENSION 362306a36Sopenharmony_ci bool "Extend memmap on extra space for more information on page" 462306a36Sopenharmony_ci help 562306a36Sopenharmony_ci Extend memmap on extra space for more information on page. This 662306a36Sopenharmony_ci could be used for debugging features that need to insert extra 762306a36Sopenharmony_ci field for every page. This extension enables us to save memory 862306a36Sopenharmony_ci by not allocating this extra memory according to boottime 962306a36Sopenharmony_ci configuration. 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciconfig DEBUG_PAGEALLOC 1262306a36Sopenharmony_ci bool "Debug page memory allocations" 1362306a36Sopenharmony_ci depends on DEBUG_KERNEL 1462306a36Sopenharmony_ci depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC 1562306a36Sopenharmony_ci select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC 1662306a36Sopenharmony_ci help 1762306a36Sopenharmony_ci Unmap pages from the kernel linear mapping after free_pages(). 1862306a36Sopenharmony_ci Depending on runtime enablement, this results in a small or large 1962306a36Sopenharmony_ci slowdown, but helps to find certain types of memory corruption. 2062306a36Sopenharmony_ci 2162306a36Sopenharmony_ci Also, the state of page tracking structures is checked more often as 2262306a36Sopenharmony_ci pages are being allocated and freed, as unexpected state changes 2362306a36Sopenharmony_ci often happen for same reasons as memory corruption (e.g. double free, 2462306a36Sopenharmony_ci use-after-free). The error reports for these checks can be augmented 2562306a36Sopenharmony_ci with stack traces of last allocation and freeing of the page, when 2662306a36Sopenharmony_ci PAGE_OWNER is also selected and enabled on boot. 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC, 2962306a36Sopenharmony_ci fill the pages with poison patterns after free_pages() and verify 3062306a36Sopenharmony_ci the patterns before alloc_pages(). Additionally, this option cannot 3162306a36Sopenharmony_ci be enabled in combination with hibernation as that would result in 3262306a36Sopenharmony_ci incorrect warnings of memory corruption after a resume because free 3362306a36Sopenharmony_ci pages are not saved to the suspend image. 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci By default this option will have a small overhead, e.g. by not 3662306a36Sopenharmony_ci allowing the kernel mapping to be backed by large pages on some 3762306a36Sopenharmony_ci architectures. Even bigger overhead comes when the debugging is 3862306a36Sopenharmony_ci enabled by DEBUG_PAGEALLOC_ENABLE_DEFAULT or the debug_pagealloc 3962306a36Sopenharmony_ci command line parameter. 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ciconfig DEBUG_PAGEALLOC_ENABLE_DEFAULT 4262306a36Sopenharmony_ci bool "Enable debug page memory allocations by default?" 4362306a36Sopenharmony_ci depends on DEBUG_PAGEALLOC 4462306a36Sopenharmony_ci help 4562306a36Sopenharmony_ci Enable debug page memory allocations by default? This value 4662306a36Sopenharmony_ci can be overridden by debug_pagealloc=off|on. 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ciconfig DEBUG_SLAB 4962306a36Sopenharmony_ci bool "Debug slab memory allocations" 5062306a36Sopenharmony_ci depends on DEBUG_KERNEL && SLAB 5162306a36Sopenharmony_ci help 5262306a36Sopenharmony_ci Say Y here to have the kernel do limited verification on memory 5362306a36Sopenharmony_ci allocation as well as poisoning memory on free to catch use of freed 5462306a36Sopenharmony_ci memory. This can make kmalloc/kfree-intensive workloads much slower. 5562306a36Sopenharmony_ci 5662306a36Sopenharmony_ciconfig SLUB_DEBUG 5762306a36Sopenharmony_ci default y 5862306a36Sopenharmony_ci bool "Enable SLUB debugging support" if EXPERT 5962306a36Sopenharmony_ci depends on SLUB && SYSFS && !SLUB_TINY 6062306a36Sopenharmony_ci select STACKDEPOT if STACKTRACE_SUPPORT 6162306a36Sopenharmony_ci help 6262306a36Sopenharmony_ci SLUB has extensive debug support features. Disabling these can 6362306a36Sopenharmony_ci result in significant savings in code size. While /sys/kernel/slab 6462306a36Sopenharmony_ci will still exist (with SYSFS enabled), it will not provide e.g. cache 6562306a36Sopenharmony_ci validation. 6662306a36Sopenharmony_ci 6762306a36Sopenharmony_ciconfig SLUB_DEBUG_ON 6862306a36Sopenharmony_ci bool "SLUB debugging on by default" 6962306a36Sopenharmony_ci depends on SLUB && SLUB_DEBUG 7062306a36Sopenharmony_ci select STACKDEPOT_ALWAYS_INIT if STACKTRACE_SUPPORT 7162306a36Sopenharmony_ci default n 7262306a36Sopenharmony_ci help 7362306a36Sopenharmony_ci Boot with debugging on by default. SLUB boots by default with 7462306a36Sopenharmony_ci the runtime debug capabilities switched off. Enabling this is 7562306a36Sopenharmony_ci equivalent to specifying the "slub_debug" parameter on boot. 7662306a36Sopenharmony_ci There is no support for more fine grained debug control like 7762306a36Sopenharmony_ci possible with slub_debug=xxx. SLUB debugging may be switched 7862306a36Sopenharmony_ci off in a kernel built with CONFIG_SLUB_DEBUG_ON by specifying 7962306a36Sopenharmony_ci "slub_debug=-". 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ciconfig PAGE_OWNER 8262306a36Sopenharmony_ci bool "Track page owner" 8362306a36Sopenharmony_ci depends on DEBUG_KERNEL && STACKTRACE_SUPPORT 8462306a36Sopenharmony_ci select DEBUG_FS 8562306a36Sopenharmony_ci select STACKTRACE 8662306a36Sopenharmony_ci select STACKDEPOT 8762306a36Sopenharmony_ci select PAGE_EXTENSION 8862306a36Sopenharmony_ci help 8962306a36Sopenharmony_ci This keeps track of what call chain is the owner of a page, may 9062306a36Sopenharmony_ci help to find bare alloc_page(s) leaks. Even if you include this 9162306a36Sopenharmony_ci feature on your build, it is disabled in default. You should pass 9262306a36Sopenharmony_ci "page_owner=on" to boot parameter in order to enable it. Eats 9362306a36Sopenharmony_ci a fair amount of memory if enabled. See tools/mm/page_owner_sort.c 9462306a36Sopenharmony_ci for user-space helper. 9562306a36Sopenharmony_ci 9662306a36Sopenharmony_ci If unsure, say N. 9762306a36Sopenharmony_ci 9862306a36Sopenharmony_ciconfig PAGE_TABLE_CHECK 9962306a36Sopenharmony_ci bool "Check for invalid mappings in user page tables" 10062306a36Sopenharmony_ci depends on ARCH_SUPPORTS_PAGE_TABLE_CHECK 10162306a36Sopenharmony_ci depends on EXCLUSIVE_SYSTEM_RAM 10262306a36Sopenharmony_ci select PAGE_EXTENSION 10362306a36Sopenharmony_ci help 10462306a36Sopenharmony_ci Check that anonymous page is not being mapped twice with read write 10562306a36Sopenharmony_ci permissions. Check that anonymous and file pages are not being 10662306a36Sopenharmony_ci erroneously shared. Since the checking is performed at the time 10762306a36Sopenharmony_ci entries are added and removed to user page tables, leaking, corruption 10862306a36Sopenharmony_ci and double mapping problems are detected synchronously. 10962306a36Sopenharmony_ci 11062306a36Sopenharmony_ci If unsure say "n". 11162306a36Sopenharmony_ci 11262306a36Sopenharmony_ciconfig PAGE_TABLE_CHECK_ENFORCED 11362306a36Sopenharmony_ci bool "Enforce the page table checking by default" 11462306a36Sopenharmony_ci depends on PAGE_TABLE_CHECK 11562306a36Sopenharmony_ci help 11662306a36Sopenharmony_ci Always enable page table checking. By default the page table checking 11762306a36Sopenharmony_ci is disabled, and can be optionally enabled via page_table_check=on 11862306a36Sopenharmony_ci kernel parameter. This config enforces that page table check is always 11962306a36Sopenharmony_ci enabled. 12062306a36Sopenharmony_ci 12162306a36Sopenharmony_ci If unsure say "n". 12262306a36Sopenharmony_ci 12362306a36Sopenharmony_ciconfig PAGE_POISONING 12462306a36Sopenharmony_ci bool "Poison pages after freeing" 12562306a36Sopenharmony_ci help 12662306a36Sopenharmony_ci Fill the pages with poison patterns after free_pages() and verify 12762306a36Sopenharmony_ci the patterns before alloc_pages. The filling of the memory helps 12862306a36Sopenharmony_ci reduce the risk of information leaks from freed data. This does 12962306a36Sopenharmony_ci have a potential performance impact if enabled with the 13062306a36Sopenharmony_ci "page_poison=1" kernel boot option. 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_ci Note that "poison" here is not the same thing as the "HWPoison" 13362306a36Sopenharmony_ci for CONFIG_MEMORY_FAILURE. This is software poisoning only. 13462306a36Sopenharmony_ci 13562306a36Sopenharmony_ci If you are only interested in sanitization of freed pages without 13662306a36Sopenharmony_ci checking the poison pattern on alloc, you can boot the kernel with 13762306a36Sopenharmony_ci "init_on_free=1" instead of enabling this. 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci If unsure, say N 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ciconfig DEBUG_PAGE_REF 14262306a36Sopenharmony_ci bool "Enable tracepoint to track down page reference manipulation" 14362306a36Sopenharmony_ci depends on DEBUG_KERNEL 14462306a36Sopenharmony_ci depends on TRACEPOINTS 14562306a36Sopenharmony_ci help 14662306a36Sopenharmony_ci This is a feature to add tracepoint for tracking down page reference 14762306a36Sopenharmony_ci manipulation. This tracking is useful to diagnose functional failure 14862306a36Sopenharmony_ci due to migration failures caused by page reference mismatches. Be 14962306a36Sopenharmony_ci careful when enabling this feature because it adds about 30 KB to the 15062306a36Sopenharmony_ci kernel code. However the runtime performance overhead is virtually 15162306a36Sopenharmony_ci nil until the tracepoints are actually enabled. 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_ciconfig DEBUG_RODATA_TEST 15462306a36Sopenharmony_ci bool "Testcase for the marking rodata read-only" 15562306a36Sopenharmony_ci depends on STRICT_KERNEL_RWX 15662306a36Sopenharmony_ci help 15762306a36Sopenharmony_ci This option enables a testcase for the setting rodata read-only. 15862306a36Sopenharmony_ci 15962306a36Sopenharmony_ciconfig ARCH_HAS_DEBUG_WX 16062306a36Sopenharmony_ci bool 16162306a36Sopenharmony_ci 16262306a36Sopenharmony_ciconfig DEBUG_WX 16362306a36Sopenharmony_ci bool "Warn on W+X mappings at boot" 16462306a36Sopenharmony_ci depends on ARCH_HAS_DEBUG_WX 16562306a36Sopenharmony_ci depends on MMU 16662306a36Sopenharmony_ci select PTDUMP_CORE 16762306a36Sopenharmony_ci help 16862306a36Sopenharmony_ci Generate a warning if any W+X mappings are found at boot. 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ci This is useful for discovering cases where the kernel is leaving W+X 17162306a36Sopenharmony_ci mappings after applying NX, as such mappings are a security risk. 17262306a36Sopenharmony_ci 17362306a36Sopenharmony_ci Look for a message in dmesg output like this: 17462306a36Sopenharmony_ci 17562306a36Sopenharmony_ci <arch>/mm: Checked W+X mappings: passed, no W+X pages found. 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci or like this, if the check failed: 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ci <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found. 18062306a36Sopenharmony_ci 18162306a36Sopenharmony_ci Note that even if the check fails, your kernel is possibly 18262306a36Sopenharmony_ci still fine, as W+X mappings are not a security hole in 18362306a36Sopenharmony_ci themselves, what they do is that they make the exploitation 18462306a36Sopenharmony_ci of other unfixed kernel bugs easier. 18562306a36Sopenharmony_ci 18662306a36Sopenharmony_ci There is no runtime or memory usage effect of this option 18762306a36Sopenharmony_ci once the kernel has booted up - it's a one time check. 18862306a36Sopenharmony_ci 18962306a36Sopenharmony_ci If in doubt, say "Y". 19062306a36Sopenharmony_ci 19162306a36Sopenharmony_ciconfig GENERIC_PTDUMP 19262306a36Sopenharmony_ci bool 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ciconfig PTDUMP_CORE 19562306a36Sopenharmony_ci bool 19662306a36Sopenharmony_ci 19762306a36Sopenharmony_ciconfig PTDUMP_DEBUGFS 19862306a36Sopenharmony_ci bool "Export kernel pagetable layout to userspace via debugfs" 19962306a36Sopenharmony_ci depends on DEBUG_KERNEL 20062306a36Sopenharmony_ci depends on DEBUG_FS 20162306a36Sopenharmony_ci depends on GENERIC_PTDUMP 20262306a36Sopenharmony_ci select PTDUMP_CORE 20362306a36Sopenharmony_ci help 20462306a36Sopenharmony_ci Say Y here if you want to show the kernel pagetable layout in a 20562306a36Sopenharmony_ci debugfs file. This information is only useful for kernel developers 20662306a36Sopenharmony_ci who are working in architecture specific areas of the kernel. 20762306a36Sopenharmony_ci It is probably not a good idea to enable this feature in a production 20862306a36Sopenharmony_ci kernel. 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci If in doubt, say N. 21162306a36Sopenharmony_ci 21262306a36Sopenharmony_ciconfig HAVE_DEBUG_KMEMLEAK 21362306a36Sopenharmony_ci bool 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_ciconfig DEBUG_KMEMLEAK 21662306a36Sopenharmony_ci bool "Kernel memory leak detector" 21762306a36Sopenharmony_ci depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK 21862306a36Sopenharmony_ci select DEBUG_FS 21962306a36Sopenharmony_ci select STACKTRACE if STACKTRACE_SUPPORT 22062306a36Sopenharmony_ci select KALLSYMS 22162306a36Sopenharmony_ci select CRC32 22262306a36Sopenharmony_ci select STACKDEPOT 22362306a36Sopenharmony_ci select STACKDEPOT_ALWAYS_INIT if !DEBUG_KMEMLEAK_DEFAULT_OFF 22462306a36Sopenharmony_ci help 22562306a36Sopenharmony_ci Say Y here if you want to enable the memory leak 22662306a36Sopenharmony_ci detector. The memory allocation/freeing is traced in a way 22762306a36Sopenharmony_ci similar to the Boehm's conservative garbage collector, the 22862306a36Sopenharmony_ci difference being that the orphan objects are not freed but 22962306a36Sopenharmony_ci only shown in /sys/kernel/debug/kmemleak. Enabling this 23062306a36Sopenharmony_ci feature will introduce an overhead to memory 23162306a36Sopenharmony_ci allocations. See Documentation/dev-tools/kmemleak.rst for more 23262306a36Sopenharmony_ci details. 23362306a36Sopenharmony_ci 23462306a36Sopenharmony_ci Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances 23562306a36Sopenharmony_ci of finding leaks due to the slab objects poisoning. 23662306a36Sopenharmony_ci 23762306a36Sopenharmony_ci In order to access the kmemleak file, debugfs needs to be 23862306a36Sopenharmony_ci mounted (usually at /sys/kernel/debug). 23962306a36Sopenharmony_ci 24062306a36Sopenharmony_ciconfig DEBUG_KMEMLEAK_MEM_POOL_SIZE 24162306a36Sopenharmony_ci int "Kmemleak memory pool size" 24262306a36Sopenharmony_ci depends on DEBUG_KMEMLEAK 24362306a36Sopenharmony_ci range 200 1000000 24462306a36Sopenharmony_ci default 16000 24562306a36Sopenharmony_ci help 24662306a36Sopenharmony_ci Kmemleak must track all the memory allocations to avoid 24762306a36Sopenharmony_ci reporting false positives. Since memory may be allocated or 24862306a36Sopenharmony_ci freed before kmemleak is fully initialised, use a static pool 24962306a36Sopenharmony_ci of metadata objects to track such callbacks. After kmemleak is 25062306a36Sopenharmony_ci fully initialised, this memory pool acts as an emergency one 25162306a36Sopenharmony_ci if slab allocations fail. 25262306a36Sopenharmony_ci 25362306a36Sopenharmony_ciconfig DEBUG_KMEMLEAK_DEFAULT_OFF 25462306a36Sopenharmony_ci bool "Default kmemleak to off" 25562306a36Sopenharmony_ci depends on DEBUG_KMEMLEAK 25662306a36Sopenharmony_ci help 25762306a36Sopenharmony_ci Say Y here to disable kmemleak by default. It can then be enabled 25862306a36Sopenharmony_ci on the command line via kmemleak=on. 25962306a36Sopenharmony_ci 26062306a36Sopenharmony_ciconfig DEBUG_KMEMLEAK_AUTO_SCAN 26162306a36Sopenharmony_ci bool "Enable kmemleak auto scan thread on boot up" 26262306a36Sopenharmony_ci default y 26362306a36Sopenharmony_ci depends on DEBUG_KMEMLEAK 26462306a36Sopenharmony_ci help 26562306a36Sopenharmony_ci Depending on the cpu, kmemleak scan may be cpu intensive and can 26662306a36Sopenharmony_ci stall user tasks at times. This option enables/disables automatic 26762306a36Sopenharmony_ci kmemleak scan at boot up. 26862306a36Sopenharmony_ci 26962306a36Sopenharmony_ci Say N here to disable kmemleak auto scan thread to stop automatic 27062306a36Sopenharmony_ci scanning. Disabling this option disables automatic reporting of 27162306a36Sopenharmony_ci memory leaks. 27262306a36Sopenharmony_ci 27362306a36Sopenharmony_ci If unsure, say Y. 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ciconfig PER_VMA_LOCK_STATS 27662306a36Sopenharmony_ci bool "Statistics for per-vma locks" 27762306a36Sopenharmony_ci depends on PER_VMA_LOCK 27862306a36Sopenharmony_ci help 27962306a36Sopenharmony_ci Say Y here to enable success, retry and failure counters of page 28062306a36Sopenharmony_ci faults handled under protection of per-vma locks. When enabled, the 28162306a36Sopenharmony_ci counters are exposed in /proc/vmstat. This information is useful for 28262306a36Sopenharmony_ci kernel developers to evaluate effectiveness of per-vma locks and to 28362306a36Sopenharmony_ci identify pathological cases. Counting these events introduces a small 28462306a36Sopenharmony_ci overhead in the page fault path. 28562306a36Sopenharmony_ci 28662306a36Sopenharmony_ci If in doubt, say N. 287