18c2ecf20Sopenharmony_ci# SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ciconfig PAGE_EXTENSION
38c2ecf20Sopenharmony_ci	bool "Extend memmap on extra space for more information on page"
48c2ecf20Sopenharmony_ci	help
58c2ecf20Sopenharmony_ci	  Extend memmap on extra space for more information on page. This
68c2ecf20Sopenharmony_ci	  could be used for debugging features that need to insert extra
78c2ecf20Sopenharmony_ci	  field for every page. This extension enables us to save memory
88c2ecf20Sopenharmony_ci	  by not allocating this extra memory according to boottime
98c2ecf20Sopenharmony_ci	  configuration.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciconfig DEBUG_PAGEALLOC
128c2ecf20Sopenharmony_ci	bool "Debug page memory allocations"
138c2ecf20Sopenharmony_ci	depends on DEBUG_KERNEL
148c2ecf20Sopenharmony_ci	depends on !HIBERNATION || ARCH_SUPPORTS_DEBUG_PAGEALLOC && !PPC && !SPARC
158c2ecf20Sopenharmony_ci	select PAGE_POISONING if !ARCH_SUPPORTS_DEBUG_PAGEALLOC
168c2ecf20Sopenharmony_ci	help
178c2ecf20Sopenharmony_ci	  Unmap pages from the kernel linear mapping after free_pages().
188c2ecf20Sopenharmony_ci	  Depending on runtime enablement, this results in a small or large
198c2ecf20Sopenharmony_ci	  slowdown, but helps to find certain types of memory corruption.
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci	  Also, the state of page tracking structures is checked more often as
228c2ecf20Sopenharmony_ci	  pages are being allocated and freed, as unexpected state changes
238c2ecf20Sopenharmony_ci	  often happen for same reasons as memory corruption (e.g. double free,
248c2ecf20Sopenharmony_ci	  use-after-free). The error reports for these checks can be augmented
258c2ecf20Sopenharmony_ci	  with stack traces of last allocation and freeing of the page, when
268c2ecf20Sopenharmony_ci	  PAGE_OWNER is also selected and enabled on boot.
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci	  For architectures which don't enable ARCH_SUPPORTS_DEBUG_PAGEALLOC,
298c2ecf20Sopenharmony_ci	  fill the pages with poison patterns after free_pages() and verify
308c2ecf20Sopenharmony_ci	  the patterns before alloc_pages(). Additionally, this option cannot
318c2ecf20Sopenharmony_ci	  be enabled in combination with hibernation as that would result in
328c2ecf20Sopenharmony_ci	  incorrect warnings of memory corruption after a resume because free
338c2ecf20Sopenharmony_ci	  pages are not saved to the suspend image.
348c2ecf20Sopenharmony_ci
358c2ecf20Sopenharmony_ci	  By default this option will have a small overhead, e.g. by not
368c2ecf20Sopenharmony_ci	  allowing the kernel mapping to be backed by large pages on some
378c2ecf20Sopenharmony_ci	  architectures. Even bigger overhead comes when the debugging is
388c2ecf20Sopenharmony_ci	  enabled by DEBUG_PAGEALLOC_ENABLE_DEFAULT or the debug_pagealloc
398c2ecf20Sopenharmony_ci	  command line parameter.
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ciconfig DEBUG_PAGEALLOC_ENABLE_DEFAULT
428c2ecf20Sopenharmony_ci	bool "Enable debug page memory allocations by default?"
438c2ecf20Sopenharmony_ci	depends on DEBUG_PAGEALLOC
448c2ecf20Sopenharmony_ci	help
458c2ecf20Sopenharmony_ci	  Enable debug page memory allocations by default? This value
468c2ecf20Sopenharmony_ci	  can be overridden by debug_pagealloc=off|on.
478c2ecf20Sopenharmony_ci
488c2ecf20Sopenharmony_ciconfig PAGE_OWNER
498c2ecf20Sopenharmony_ci	bool "Track page owner"
508c2ecf20Sopenharmony_ci	depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
518c2ecf20Sopenharmony_ci	select DEBUG_FS
528c2ecf20Sopenharmony_ci	select STACKTRACE
538c2ecf20Sopenharmony_ci	select STACKDEPOT
548c2ecf20Sopenharmony_ci	select PAGE_EXTENSION
558c2ecf20Sopenharmony_ci	help
568c2ecf20Sopenharmony_ci	  This keeps track of what call chain is the owner of a page, may
578c2ecf20Sopenharmony_ci	  help to find bare alloc_page(s) leaks. Even if you include this
588c2ecf20Sopenharmony_ci	  feature on your build, it is disabled in default. You should pass
598c2ecf20Sopenharmony_ci	  "page_owner=on" to boot parameter in order to enable it. Eats
608c2ecf20Sopenharmony_ci	  a fair amount of memory if enabled. See tools/vm/page_owner_sort.c
618c2ecf20Sopenharmony_ci	  for user-space helper.
628c2ecf20Sopenharmony_ci
638c2ecf20Sopenharmony_ci	  If unsure, say N.
648c2ecf20Sopenharmony_ci
658c2ecf20Sopenharmony_ciconfig PAGE_POISONING
668c2ecf20Sopenharmony_ci	bool "Poison pages after freeing"
678c2ecf20Sopenharmony_ci	select PAGE_POISONING_NO_SANITY if HIBERNATION
688c2ecf20Sopenharmony_ci	help
698c2ecf20Sopenharmony_ci	  Fill the pages with poison patterns after free_pages() and verify
708c2ecf20Sopenharmony_ci	  the patterns before alloc_pages. The filling of the memory helps
718c2ecf20Sopenharmony_ci	  reduce the risk of information leaks from freed data. This does
728c2ecf20Sopenharmony_ci	  have a potential performance impact if enabled with the
738c2ecf20Sopenharmony_ci	  "page_poison=1" kernel boot option.
748c2ecf20Sopenharmony_ci
758c2ecf20Sopenharmony_ci	  Note that "poison" here is not the same thing as the "HWPoison"
768c2ecf20Sopenharmony_ci	  for CONFIG_MEMORY_FAILURE. This is software poisoning only.
778c2ecf20Sopenharmony_ci
788c2ecf20Sopenharmony_ci	  If unsure, say N
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciconfig PAGE_POISONING_NO_SANITY
818c2ecf20Sopenharmony_ci	depends on PAGE_POISONING
828c2ecf20Sopenharmony_ci	bool "Only poison, don't sanity check"
838c2ecf20Sopenharmony_ci	help
848c2ecf20Sopenharmony_ci	   Skip the sanity checking on alloc, only fill the pages with
858c2ecf20Sopenharmony_ci	   poison on free. This reduces some of the overhead of the
868c2ecf20Sopenharmony_ci	   poisoning feature.
878c2ecf20Sopenharmony_ci
888c2ecf20Sopenharmony_ci	   If you are only interested in sanitization, say Y. Otherwise
898c2ecf20Sopenharmony_ci	   say N.
908c2ecf20Sopenharmony_ci
918c2ecf20Sopenharmony_ciconfig PAGE_POISONING_ZERO
928c2ecf20Sopenharmony_ci	bool "Use zero for poisoning instead of debugging value"
938c2ecf20Sopenharmony_ci	depends on PAGE_POISONING
948c2ecf20Sopenharmony_ci	help
958c2ecf20Sopenharmony_ci	   Instead of using the existing poison value, fill the pages with
968c2ecf20Sopenharmony_ci	   zeros. This makes it harder to detect when errors are occurring
978c2ecf20Sopenharmony_ci	   due to sanitization but the zeroing at free means that it is
988c2ecf20Sopenharmony_ci	   no longer necessary to write zeros when GFP_ZERO is used on
998c2ecf20Sopenharmony_ci	   allocation.
1008c2ecf20Sopenharmony_ci
1018c2ecf20Sopenharmony_ci	   If unsure, say N
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciconfig DEBUG_PAGE_REF
1048c2ecf20Sopenharmony_ci	bool "Enable tracepoint to track down page reference manipulation"
1058c2ecf20Sopenharmony_ci	depends on DEBUG_KERNEL
1068c2ecf20Sopenharmony_ci	depends on TRACEPOINTS
1078c2ecf20Sopenharmony_ci	help
1088c2ecf20Sopenharmony_ci	  This is a feature to add tracepoint for tracking down page reference
1098c2ecf20Sopenharmony_ci	  manipulation. This tracking is useful to diagnose functional failure
1108c2ecf20Sopenharmony_ci	  due to migration failures caused by page reference mismatches.  Be
1118c2ecf20Sopenharmony_ci	  careful when enabling this feature because it adds about 30 KB to the
1128c2ecf20Sopenharmony_ci	  kernel code.  However the runtime performance overhead is virtually
1138c2ecf20Sopenharmony_ci	  nil until the tracepoints are actually enabled.
1148c2ecf20Sopenharmony_ci
1158c2ecf20Sopenharmony_ciconfig DEBUG_RODATA_TEST
1168c2ecf20Sopenharmony_ci    bool "Testcase for the marking rodata read-only"
1178c2ecf20Sopenharmony_ci    depends on STRICT_KERNEL_RWX
1188c2ecf20Sopenharmony_ci	help
1198c2ecf20Sopenharmony_ci      This option enables a testcase for the setting rodata read-only.
1208c2ecf20Sopenharmony_ci
1218c2ecf20Sopenharmony_ciconfig ARCH_HAS_DEBUG_WX
1228c2ecf20Sopenharmony_ci	bool
1238c2ecf20Sopenharmony_ci
1248c2ecf20Sopenharmony_ciconfig DEBUG_WX
1258c2ecf20Sopenharmony_ci	bool "Warn on W+X mappings at boot"
1268c2ecf20Sopenharmony_ci	depends on ARCH_HAS_DEBUG_WX
1278c2ecf20Sopenharmony_ci	depends on MMU
1288c2ecf20Sopenharmony_ci	select PTDUMP_CORE
1298c2ecf20Sopenharmony_ci	help
1308c2ecf20Sopenharmony_ci	  Generate a warning if any W+X mappings are found at boot.
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ci	  This is useful for discovering cases where the kernel is leaving W+X
1338c2ecf20Sopenharmony_ci	  mappings after applying NX, as such mappings are a security risk.
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ci	  Look for a message in dmesg output like this:
1368c2ecf20Sopenharmony_ci
1378c2ecf20Sopenharmony_ci	    <arch>/mm: Checked W+X mappings: passed, no W+X pages found.
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci	  or like this, if the check failed:
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci	    <arch>/mm: Checked W+X mappings: failed, <N> W+X pages found.
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci	  Note that even if the check fails, your kernel is possibly
1448c2ecf20Sopenharmony_ci	  still fine, as W+X mappings are not a security hole in
1458c2ecf20Sopenharmony_ci	  themselves, what they do is that they make the exploitation
1468c2ecf20Sopenharmony_ci	  of other unfixed kernel bugs easier.
1478c2ecf20Sopenharmony_ci
1488c2ecf20Sopenharmony_ci	  There is no runtime or memory usage effect of this option
1498c2ecf20Sopenharmony_ci	  once the kernel has booted up - it's a one time check.
1508c2ecf20Sopenharmony_ci
1518c2ecf20Sopenharmony_ci	  If in doubt, say "Y".
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_ciconfig GENERIC_PTDUMP
1548c2ecf20Sopenharmony_ci	bool
1558c2ecf20Sopenharmony_ci
1568c2ecf20Sopenharmony_ciconfig PTDUMP_CORE
1578c2ecf20Sopenharmony_ci	bool
1588c2ecf20Sopenharmony_ci
1598c2ecf20Sopenharmony_ciconfig PTDUMP_DEBUGFS
1608c2ecf20Sopenharmony_ci	bool "Export kernel pagetable layout to userspace via debugfs"
1618c2ecf20Sopenharmony_ci	depends on DEBUG_KERNEL
1628c2ecf20Sopenharmony_ci	depends on DEBUG_FS
1638c2ecf20Sopenharmony_ci	depends on GENERIC_PTDUMP
1648c2ecf20Sopenharmony_ci	select PTDUMP_CORE
1658c2ecf20Sopenharmony_ci	help
1668c2ecf20Sopenharmony_ci	  Say Y here if you want to show the kernel pagetable layout in a
1678c2ecf20Sopenharmony_ci	  debugfs file. This information is only useful for kernel developers
1688c2ecf20Sopenharmony_ci	  who are working in architecture specific areas of the kernel.
1698c2ecf20Sopenharmony_ci	  It is probably not a good idea to enable this feature in a production
1708c2ecf20Sopenharmony_ci	  kernel.
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ci	  If in doubt, say N.
173