• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# SPDX-License-Identifier: GPL-2.0-only
2menu "Kernel hacking"
3
4menu "printk and dmesg options"
5
6config PRINTK_TIME
7	bool "Show timing information on printks"
8	depends on PRINTK
9	help
10	  Selecting this option causes time stamps of the printk()
11	  messages to be added to the output of the syslog() system
12	  call and at the console.
13
14	  The timestamp is always recorded internally, and exported
15	  to /dev/kmsg. This flag just specifies if the timestamp should
16	  be included, not that the timestamp is recorded.
17
18	  The behavior is also controlled by the kernel command line
19	  parameter printk.time=1. See Documentation/admin-guide/kernel-parameters.rst
20
21config PRINTK_CALLER
22	bool "Show caller information on printks"
23	depends on PRINTK
24	help
25	  Selecting this option causes printk() to add a caller "thread id" (if
26	  in task context) or a caller "processor id" (if not in task context)
27	  to every message.
28
29	  This option is intended for environments where multiple threads
30	  concurrently call printk() for many times, for it is difficult to
31	  interpret without knowing where these lines (or sometimes individual
32	  line which was divided into multiple lines due to race) came from.
33
34	  Since toggling after boot makes the code racy, currently there is
35	  no option to enable/disable at the kernel command line parameter or
36	  sysfs interface.
37
38config STACKTRACE_BUILD_ID
39	bool "Show build ID information in stacktraces"
40	depends on PRINTK
41	help
42	  Selecting this option adds build ID information for symbols in
43	  stacktraces printed with the printk format '%p[SR]b'.
44
45	  This option is intended for distros where debuginfo is not easily
46	  accessible but can be downloaded given the build ID of the vmlinux or
47	  kernel module where the function is located.
48
49config CONSOLE_LOGLEVEL_DEFAULT
50	int "Default console loglevel (1-15)"
51	range 1 15
52	default "7"
53	help
54	  Default loglevel to determine what will be printed on the console.
55
56	  Setting a default here is equivalent to passing in loglevel=<x> in
57	  the kernel bootargs. loglevel=<x> continues to override whatever
58	  value is specified here as well.
59
60	  Note: This does not affect the log level of un-prefixed printk()
61	  usage in the kernel. That is controlled by the MESSAGE_LOGLEVEL_DEFAULT
62	  option.
63
64config CONSOLE_LOGLEVEL_QUIET
65	int "quiet console loglevel (1-15)"
66	range 1 15
67	default "4"
68	help
69	  loglevel to use when "quiet" is passed on the kernel commandline.
70
71	  When "quiet" is passed on the kernel commandline this loglevel
72	  will be used as the loglevel. IOW passing "quiet" will be the
73	  equivalent of passing "loglevel=<CONSOLE_LOGLEVEL_QUIET>"
74
75config MESSAGE_LOGLEVEL_DEFAULT
76	int "Default message log level (1-7)"
77	range 1 7
78	default "4"
79	help
80	  Default log level for printk statements with no specified priority.
81
82	  This was hard-coded to KERN_WARNING since at least 2.6.10 but folks
83	  that are auditing their logs closely may want to set it to a lower
84	  priority.
85
86	  Note: This does not affect what message level gets printed on the console
87	  by default. To change that, use loglevel=<x> in the kernel bootargs,
88	  or pick a different CONSOLE_LOGLEVEL_DEFAULT configuration value.
89
90config BOOT_PRINTK_DELAY
91	bool "Delay each boot printk message by N milliseconds"
92	depends on DEBUG_KERNEL && PRINTK && GENERIC_CALIBRATE_DELAY
93	help
94	  This build option allows you to read kernel boot messages
95	  by inserting a short delay after each one.  The delay is
96	  specified in milliseconds on the kernel command line,
97	  using "boot_delay=N".
98
99	  It is likely that you would also need to use "lpj=M" to preset
100	  the "loops per jiffie" value.
101	  See a previous boot log for the "lpj" value to use for your
102	  system, and then set "lpj=M" before setting "boot_delay=N".
103	  NOTE:  Using this option may adversely affect SMP systems.
104	  I.e., processors other than the first one may not boot up.
105	  BOOT_PRINTK_DELAY also may cause LOCKUP_DETECTOR to detect
106	  what it believes to be lockup conditions.
107
108config DYNAMIC_DEBUG
109	bool "Enable dynamic printk() support"
110	default n
111	depends on PRINTK
112	depends on (DEBUG_FS || PROC_FS)
113	select DYNAMIC_DEBUG_CORE
114	help
115
116	  Compiles debug level messages into the kernel, which would not
117	  otherwise be available at runtime. These messages can then be
118	  enabled/disabled based on various levels of scope - per source file,
119	  function, module, format string, and line number. This mechanism
120	  implicitly compiles in all pr_debug() and dev_dbg() calls, which
121	  enlarges the kernel text size by about 2%.
122
123	  If a source file is compiled with DEBUG flag set, any
124	  pr_debug() calls in it are enabled by default, but can be
125	  disabled at runtime as below.  Note that DEBUG flag is
126	  turned on by many CONFIG_*DEBUG* options.
127
128	  Usage:
129
130	  Dynamic debugging is controlled via the 'dynamic_debug/control' file,
131	  which is contained in the 'debugfs' filesystem or procfs.
132	  Thus, the debugfs or procfs filesystem must first be mounted before
133	  making use of this feature.
134	  We refer the control file as: <debugfs>/dynamic_debug/control. This
135	  file contains a list of the debug statements that can be enabled. The
136	  format for each line of the file is:
137
138		filename:lineno [module]function flags format
139
140	  filename : source file of the debug statement
141	  lineno : line number of the debug statement
142	  module : module that contains the debug statement
143	  function : function that contains the debug statement
144	  flags : '=p' means the line is turned 'on' for printing
145	  format : the format used for the debug statement
146
147	  From a live system:
148
149		nullarbor:~ # cat <debugfs>/dynamic_debug/control
150		# filename:lineno [module]function flags format
151		fs/aio.c:222 [aio]__put_ioctx =_ "__put_ioctx:\040freeing\040%p\012"
152		fs/aio.c:248 [aio]ioctx_alloc =_ "ENOMEM:\040nr_events\040too\040high\012"
153		fs/aio.c:1770 [aio]sys_io_cancel =_ "calling\040cancel\012"
154
155	  Example usage:
156
157		// enable the message at line 1603 of file svcsock.c
158		nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' >
159						<debugfs>/dynamic_debug/control
160
161		// enable all the messages in file svcsock.c
162		nullarbor:~ # echo -n 'file svcsock.c +p' >
163						<debugfs>/dynamic_debug/control
164
165		// enable all the messages in the NFS server module
166		nullarbor:~ # echo -n 'module nfsd +p' >
167						<debugfs>/dynamic_debug/control
168
169		// enable all 12 messages in the function svc_process()
170		nullarbor:~ # echo -n 'func svc_process +p' >
171						<debugfs>/dynamic_debug/control
172
173		// disable all 12 messages in the function svc_process()
174		nullarbor:~ # echo -n 'func svc_process -p' >
175						<debugfs>/dynamic_debug/control
176
177	  See Documentation/admin-guide/dynamic-debug-howto.rst for additional
178	  information.
179
180config DYNAMIC_DEBUG_CORE
181	bool "Enable core function of dynamic debug support"
182	depends on PRINTK
183	depends on (DEBUG_FS || PROC_FS)
184	help
185	  Enable core functional support of dynamic debug. It is useful
186	  when you want to tie dynamic debug to your kernel modules with
187	  DYNAMIC_DEBUG_MODULE defined for each of them, especially for
188	  the case of embedded system where the kernel image size is
189	  sensitive for people.
190
191config SYMBOLIC_ERRNAME
192	bool "Support symbolic error names in printf"
193	default y if PRINTK
194	help
195	  If you say Y here, the kernel's printf implementation will
196	  be able to print symbolic error names such as ENOSPC instead
197	  of the number 28. It makes the kernel image slightly larger
198	  (about 3KB), but can make the kernel logs easier to read.
199
200config DEBUG_BUGVERBOSE
201	bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
202	depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
203	default y
204	help
205	  Say Y here to make BUG() panics output the file name and line number
206	  of the BUG call as well as the EIP and oops trace.  This aids
207	  debugging but costs about 70-100K of memory.
208
209endmenu # "printk and dmesg options"
210
211config DEBUG_KERNEL
212	bool "Kernel debugging"
213	help
214	  Say Y here if you are developing drivers or trying to debug and
215	  identify kernel problems.
216
217config DEBUG_MISC
218	bool "Miscellaneous debug code"
219	default DEBUG_KERNEL
220	depends on DEBUG_KERNEL
221	help
222	  Say Y here if you need to enable miscellaneous debug code that should
223	  be under a more specific debug option but isn't.
224
225menu "Compile-time checks and compiler options"
226
227config DEBUG_INFO
228	bool
229	help
230	  A kernel debug info option other than "None" has been selected
231	  in the "Debug information" choice below, indicating that debug
232	  information will be generated for build targets.
233
234# Clang is known to generate .{s,u}leb128 with symbol deltas with DWARF5, which
235# some targets may not support: https://sourceware.org/bugzilla/show_bug.cgi?id=27215
236config AS_HAS_NON_CONST_LEB128
237	def_bool $(as-instr,.uleb128 .Lexpr_end4 - .Lexpr_start3\n.Lexpr_start3:\n.Lexpr_end4:)
238
239choice
240	prompt "Debug information"
241	depends on DEBUG_KERNEL
242	help
243	  Selecting something other than "None" results in a kernel image
244	  that will include debugging info resulting in a larger kernel image.
245	  This adds debug symbols to the kernel and modules (gcc -g), and
246	  is needed if you intend to use kernel crashdump or binary object
247	  tools like crash, kgdb, LKCD, gdb, etc on the kernel.
248
249	  Choose which version of DWARF debug info to emit. If unsure,
250	  select "Toolchain default".
251
252config DEBUG_INFO_NONE
253	bool "Disable debug information"
254	help
255	  Do not build the kernel with debugging information, which will
256	  result in a faster and smaller build.
257
258config DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
259	bool "Rely on the toolchain's implicit default DWARF version"
260	select DEBUG_INFO
261	depends on !CC_IS_CLANG || AS_IS_LLVM || CLANG_VERSION < 140000 || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
262	help
263	  The implicit default version of DWARF debug info produced by a
264	  toolchain changes over time.
265
266	  This can break consumers of the debug info that haven't upgraded to
267	  support newer revisions, and prevent testing newer versions, but
268	  those should be less common scenarios.
269
270config DEBUG_INFO_DWARF4
271	bool "Generate DWARF Version 4 debuginfo"
272	select DEBUG_INFO
273	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502)
274	help
275	  Generate DWARF v4 debug info. This requires gcc 4.5+, binutils 2.35.2
276	  if using clang without clang's integrated assembler, and gdb 7.0+.
277
278	  If you have consumers of DWARF debug info that are not ready for
279	  newer revisions of DWARF, you may wish to choose this or have your
280	  config select this.
281
282config DEBUG_INFO_DWARF5
283	bool "Generate DWARF Version 5 debuginfo"
284	select DEBUG_INFO
285	depends on !CC_IS_CLANG || AS_IS_LLVM || (AS_IS_GNU && AS_VERSION >= 23502 && AS_HAS_NON_CONST_LEB128)
286	help
287	  Generate DWARF v5 debug info. Requires binutils 2.35.2, gcc 5.0+ (gcc
288	  5.0+ accepts the -gdwarf-5 flag but only had partial support for some
289	  draft features until 7.0), and gdb 8.0+.
290
291	  Changes to the structure of debug info in Version 5 allow for around
292	  15-18% savings in resulting image and debug info section sizes as
293	  compared to DWARF Version 4. DWARF Version 5 standardizes previous
294	  extensions such as accelerators for symbol indexing and the format
295	  for fission (.dwo/.dwp) files. Users may not want to select this
296	  config if they rely on tooling that has not yet been updated to
297	  support DWARF Version 5.
298
299endchoice # "Debug information"
300
301if DEBUG_INFO
302
303config DEBUG_INFO_REDUCED
304	bool "Reduce debugging information"
305	help
306	  If you say Y here gcc is instructed to generate less debugging
307	  information for structure types. This means that tools that
308	  need full debugging information (like kgdb or systemtap) won't
309	  be happy. But if you merely need debugging information to
310	  resolve line numbers there is no loss. Advantage is that
311	  build directory object sizes shrink dramatically over a full
312	  DEBUG_INFO build and compile times are reduced too.
313	  Only works with newer gcc versions.
314
315config DEBUG_INFO_COMPRESSED
316	bool "Compressed debugging information"
317	depends on $(cc-option,-gz=zlib)
318	depends on $(ld-option,--compress-debug-sections=zlib)
319	help
320	  Compress the debug information using zlib.  Requires GCC 5.0+ or Clang
321	  5.0+, binutils 2.26+, and zlib.
322
323	  Users of dpkg-deb via scripts/package/builddeb may find an increase in
324	  size of their debug .deb packages with this config set, due to the
325	  debug info being compressed with zlib, then the object files being
326	  recompressed with a different compression scheme. But this is still
327	  preferable to setting $KDEB_COMPRESS to "none" which would be even
328	  larger.
329
330config DEBUG_INFO_SPLIT
331	bool "Produce split debuginfo in .dwo files"
332	depends on $(cc-option,-gsplit-dwarf)
333	help
334	  Generate debug info into separate .dwo files. This significantly
335	  reduces the build directory size for builds with DEBUG_INFO,
336	  because it stores the information only once on disk in .dwo
337	  files instead of multiple times in object files and executables.
338	  In addition the debug information is also compressed.
339
340	  Requires recent gcc (4.7+) and recent gdb/binutils.
341	  Any tool that packages or reads debug information would need
342	  to know about the .dwo files and include them.
343	  Incompatible with older versions of ccache.
344
345config DEBUG_INFO_BTF
346	bool "Generate BTF typeinfo"
347	depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
348	depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
349	depends on BPF_SYSCALL
350	depends on !DEBUG_INFO_DWARF5 || PAHOLE_VERSION >= 121
351	help
352	  Generate deduplicated BTF type information from DWARF debug info.
353	  Turning this on expects presence of pahole tool, which will convert
354	  DWARF type info into equivalent deduplicated BTF type info.
355
356config PAHOLE_HAS_SPLIT_BTF
357	def_bool PAHOLE_VERSION >= 119
358
359config PAHOLE_HAS_BTF_TAG
360	def_bool PAHOLE_VERSION >= 123
361	depends on CC_IS_CLANG
362	help
363	  Decide whether pahole emits btf_tag attributes (btf_type_tag and
364	  btf_decl_tag) or not. Currently only clang compiler implements
365	  these attributes, so make the config depend on CC_IS_CLANG.
366
367config PAHOLE_HAS_LANG_EXCLUDE
368	def_bool PAHOLE_VERSION >= 124
369	help
370	  Support for the --lang_exclude flag which makes pahole exclude
371	  compilation units from the supplied language. Used in Kbuild to
372	  omit Rust CUs which are not supported in version 1.24 of pahole,
373	  otherwise it would emit malformed kernel and module binaries when
374	  using DEBUG_INFO_BTF_MODULES.
375
376config DEBUG_INFO_BTF_MODULES
377	def_bool y
378	depends on DEBUG_INFO_BTF && MODULES && PAHOLE_HAS_SPLIT_BTF
379	help
380	  Generate compact split BTF type information for kernel modules.
381
382config MODULE_ALLOW_BTF_MISMATCH
383	bool "Allow loading modules with non-matching BTF type info"
384	depends on DEBUG_INFO_BTF_MODULES
385	help
386	  For modules whose split BTF does not match vmlinux, load without
387	  BTF rather than refusing to load. The default behavior with
388	  module BTF enabled is to reject modules with such mismatches;
389	  this option will still load module BTF where possible but ignore
390	  it when a mismatch is found.
391
392config GDB_SCRIPTS
393	bool "Provide GDB scripts for kernel debugging"
394	help
395	  This creates the required links to GDB helper scripts in the
396	  build directory. If you load vmlinux into gdb, the helper
397	  scripts will be automatically imported by gdb as well, and
398	  additional functions are available to analyze a Linux kernel
399	  instance. See Documentation/dev-tools/gdb-kernel-debugging.rst
400	  for further details.
401
402endif # DEBUG_INFO
403
404config FRAME_WARN
405	int "Warn for stack frames larger than"
406	range 0 8192
407	default 0 if KMSAN
408	default 2048 if GCC_PLUGIN_LATENT_ENTROPY
409	default 2048 if PARISC
410	default 1536 if (!64BIT && XTENSA)
411	default 1280 if KASAN && !64BIT
412	default 1024 if !64BIT
413	default 2048 if 64BIT
414	help
415	  Tell the compiler to warn at build time for stack frames larger than this.
416	  Setting this too low will cause a lot of warnings.
417	  Setting it to 0 disables the warning.
418
419config STRIP_ASM_SYMS
420	bool "Strip assembler-generated symbols during link"
421	default n
422	help
423	  Strip internal assembler-generated symbols during a link (symbols
424	  that look like '.Lxxx') so they don't pollute the output of
425	  get_wchan() and suchlike.
426
427config READABLE_ASM
428	bool "Generate readable assembler code"
429	depends on DEBUG_KERNEL
430	depends on CC_IS_GCC
431	help
432	  Disable some compiler optimizations that tend to generate human unreadable
433	  assembler output. This may make the kernel slightly slower, but it helps
434	  to keep kernel developers who have to stare a lot at assembler listings
435	  sane.
436
437config HEADERS_INSTALL
438	bool "Install uapi headers to usr/include"
439	depends on !UML
440	help
441	  This option will install uapi headers (headers exported to user-space)
442	  into the usr/include directory for use during the kernel build.
443	  This is unneeded for building the kernel itself, but needed for some
444	  user-space program samples. It is also needed by some features such
445	  as uapi header sanity checks.
446
447config DEBUG_SECTION_MISMATCH
448	bool "Enable full Section mismatch analysis"
449	depends on CC_IS_GCC
450	help
451	  The section mismatch analysis checks if there are illegal
452	  references from one section to another section.
453	  During linktime or runtime, some sections are dropped;
454	  any use of code/data previously in these sections would
455	  most likely result in an oops.
456	  In the code, functions and variables are annotated with
457	  __init,, etc. (see the full list in include/linux/init.h),
458	  which results in the code/data being placed in specific sections.
459	  The section mismatch analysis is always performed after a full
460	  kernel build, and enabling this option causes the following
461	  additional step to occur:
462	  - Add the option -fno-inline-functions-called-once to gcc commands.
463	    When inlining a function annotated with __init in a non-init
464	    function, we would lose the section information and thus
465	    the analysis would not catch the illegal reference.
466	    This option tells gcc to inline less (but it does result in
467	    a larger kernel).
468
469config SECTION_MISMATCH_WARN_ONLY
470	bool "Make section mismatch errors non-fatal"
471	default y
472	help
473	  If you say N here, the build process will fail if there are any
474	  section mismatch, instead of just throwing warnings.
475
476	  If unsure, say Y.
477
478config DEBUG_FORCE_FUNCTION_ALIGN_64B
479	bool "Force all function address 64B aligned"
480	depends on EXPERT && (X86_64 || ARM64 || PPC32 || PPC64 || ARC)
481	help
482	  There are cases that a commit from one domain changes the function
483	  address alignment of other domains, and cause magic performance
484	  bump (regression or improvement). Enable this option will help to
485	  verify if the bump is caused by function alignment changes, while
486	  it will slightly increase the kernel size and affect icache usage.
487
488	  It is mainly for debug and performance tuning use.
489
490#
491# Select this config option from the architecture Kconfig, if it
492# is preferred to always offer frame pointers as a config
493# option on the architecture (regardless of KERNEL_DEBUG):
494#
495config ARCH_WANT_FRAME_POINTERS
496	bool
497
498config FRAME_POINTER
499	bool "Compile the kernel with frame pointers"
500	depends on DEBUG_KERNEL && (M68K || UML || SUPERH) || ARCH_WANT_FRAME_POINTERS
501	default y if (DEBUG_INFO && UML) || ARCH_WANT_FRAME_POINTERS
502	help
503	  If you say Y here the resulting kernel image will be slightly
504	  larger and slower, but it gives very useful debugging information
505	  in case of kernel bugs. (precise oopses/stacktraces/warnings)
506
507config OBJTOOL
508	bool
509
510config STACK_VALIDATION
511	bool "Compile-time stack metadata validation"
512	depends on HAVE_STACK_VALIDATION && UNWINDER_FRAME_POINTER
513	select OBJTOOL
514	default n
515	help
516	  Validate frame pointer rules at compile-time.  This helps ensure that
517	  runtime stack traces are more reliable.
518
519	  For more information, see
520	  tools/objtool/Documentation/objtool.txt.
521
522config NOINSTR_VALIDATION
523	bool
524	depends on HAVE_NOINSTR_VALIDATION && DEBUG_ENTRY
525	select OBJTOOL
526	default y
527
528config VMLINUX_MAP
529	bool "Generate vmlinux.map file when linking"
530	depends on EXPERT
531	help
532	  Selecting this option will pass "-Map=vmlinux.map" to ld
533	  when linking vmlinux. That file can be useful for verifying
534	  and debugging magic section games, and for seeing which
535	  pieces of code get eliminated with
536	  CONFIG_LD_DEAD_CODE_DATA_ELIMINATION.
537
538config DEBUG_FORCE_WEAK_PER_CPU
539	bool "Force weak per-cpu definitions"
540	depends on DEBUG_KERNEL
541	help
542	  s390 and alpha require percpu variables in modules to be
543	  defined weak to work around addressing range issue which
544	  puts the following two restrictions on percpu variable
545	  definitions.
546
547	  1. percpu symbols must be unique whether static or not
548	  2. percpu variables can't be defined inside a function
549
550	  To ensure that generic code follows the above rules, this
551	  option forces all percpu variables to be defined as weak.
552
553endmenu # "Compiler options"
554
555menu "Generic Kernel Debugging Instruments"
556
557config MAGIC_SYSRQ
558	bool "Magic SysRq key"
559	depends on !UML
560	help
561	  If you say Y here, you will have some control over the system even
562	  if the system crashes for example during kernel debugging (e.g., you
563	  will be able to flush the buffer cache to disk, reboot the system
564	  immediately or dump some status information). This is accomplished
565	  by pressing various keys while holding SysRq (Alt+PrintScreen). It
566	  also works on a serial console (on PC hardware at least), if you
567	  send a BREAK and then within 5 seconds a command keypress. The
568	  keys are documented in <file:Documentation/admin-guide/sysrq.rst>.
569	  Don't say Y unless you really know what this hack does.
570
571config MAGIC_SYSRQ_DEFAULT_ENABLE
572	hex "Enable magic SysRq key functions by default"
573	depends on MAGIC_SYSRQ
574	default 0x1
575	help
576	  Specifies which SysRq key functions are enabled by default.
577	  This may be set to 1 or 0 to enable or disable them all, or
578	  to a bitmask as described in Documentation/admin-guide/sysrq.rst.
579
580config MAGIC_SYSRQ_SERIAL
581	bool "Enable magic SysRq key over serial"
582	depends on MAGIC_SYSRQ
583	default y
584	help
585	  Many embedded boards have a disconnected TTL level serial which can
586	  generate some garbage that can lead to spurious false sysrq detects.
587	  This option allows you to decide whether you want to enable the
588	  magic SysRq key.
589
590config MAGIC_SYSRQ_SERIAL_SEQUENCE
591	string "Char sequence that enables magic SysRq over serial"
592	depends on MAGIC_SYSRQ_SERIAL
593	default ""
594	help
595	  Specifies a sequence of characters that can follow BREAK to enable
596	  SysRq on a serial console.
597
598	  If unsure, leave an empty string and the option will not be enabled.
599
600config DEBUG_FS
601	bool "Debug Filesystem"
602	help
603	  debugfs is a virtual file system that kernel developers use to put
604	  debugging files into.  Enable this option to be able to read and
605	  write to these files.
606
607	  For detailed documentation on the debugfs API, see
608	  Documentation/filesystems/.
609
610	  If unsure, say N.
611
612choice
613	prompt "Debugfs default access"
614	depends on DEBUG_FS
615	default DEBUG_FS_ALLOW_ALL
616	help
617	  This selects the default access restrictions for debugfs.
618	  It can be overridden with kernel command line option
619	  debugfs=[on,no-mount,off]. The restrictions apply for API access
620	  and filesystem registration.
621
622config DEBUG_FS_ALLOW_ALL
623	bool "Access normal"
624	help
625	  No restrictions apply. Both API and filesystem registration
626	  is on. This is the normal default operation.
627
628config DEBUG_FS_DISALLOW_MOUNT
629	bool "Do not register debugfs as filesystem"
630	help
631	  The API is open but filesystem is not loaded. Clients can still do
632	  their work and read with debug tools that do not need
633	  debugfs filesystem.
634
635config DEBUG_FS_ALLOW_NONE
636	bool "No access"
637	help
638	  Access is off. Clients get -PERM when trying to create nodes in
639	  debugfs tree and debugfs is not registered as a filesystem.
640	  Client can then back-off or continue without debugfs access.
641
642endchoice
643
644source "lib/Kconfig.kgdb"
645source "lib/Kconfig.ubsan"
646source "lib/Kconfig.kcsan"
647
648endmenu
649
650menu "Networking Debugging"
651
652source "net/Kconfig.debug"
653
654endmenu # "Networking Debugging"
655
656menu "Memory Debugging"
657
658source "mm/Kconfig.debug"
659
660config DEBUG_OBJECTS
661	bool "Debug object operations"
662	depends on DEBUG_KERNEL
663	help
664	  If you say Y here, additional code will be inserted into the
665	  kernel to track the life time of various objects and validate
666	  the operations on those objects.
667
668config DEBUG_OBJECTS_SELFTEST
669	bool "Debug objects selftest"
670	depends on DEBUG_OBJECTS
671	help
672	  This enables the selftest of the object debug code.
673
674config DEBUG_OBJECTS_FREE
675	bool "Debug objects in freed memory"
676	depends on DEBUG_OBJECTS
677	help
678	  This enables checks whether a k/v free operation frees an area
679	  which contains an object which has not been deactivated
680	  properly. This can make kmalloc/kfree-intensive workloads
681	  much slower.
682
683config DEBUG_OBJECTS_TIMERS
684	bool "Debug timer objects"
685	depends on DEBUG_OBJECTS
686	help
687	  If you say Y here, additional code will be inserted into the
688	  timer routines to track the life time of timer objects and
689	  validate the timer operations.
690
691config DEBUG_OBJECTS_WORK
692	bool "Debug work objects"
693	depends on DEBUG_OBJECTS
694	help
695	  If you say Y here, additional code will be inserted into the
696	  work queue routines to track the life time of work objects and
697	  validate the work operations.
698
699config DEBUG_OBJECTS_RCU_HEAD
700	bool "Debug RCU callbacks objects"
701	depends on DEBUG_OBJECTS
702	help
703	  Enable this to turn on debugging of RCU list heads (call_rcu() usage).
704
705config DEBUG_OBJECTS_PERCPU_COUNTER
706	bool "Debug percpu counter objects"
707	depends on DEBUG_OBJECTS
708	help
709	  If you say Y here, additional code will be inserted into the
710	  percpu counter routines to track the life time of percpu counter
711	  objects and validate the percpu counter operations.
712
713config DEBUG_OBJECTS_ENABLE_DEFAULT
714	int "debug_objects bootup default value (0-1)"
715	range 0 1
716	default "1"
717	depends on DEBUG_OBJECTS
718	help
719	  Debug objects boot parameter default value
720
721config SHRINKER_DEBUG
722	bool "Enable shrinker debugging support"
723	depends on DEBUG_FS
724	help
725	  Say Y to enable the shrinker debugfs interface which provides
726	  visibility into the kernel memory shrinkers subsystem.
727	  Disable it to avoid an extra memory footprint.
728
729config HAVE_DEBUG_KMEMLEAK
730	bool
731
732config DEBUG_KMEMLEAK
733	bool "Kernel memory leak detector"
734	depends on DEBUG_KERNEL && HAVE_DEBUG_KMEMLEAK
735	select DEBUG_FS
736	select STACKTRACE if STACKTRACE_SUPPORT
737	select KALLSYMS
738	select CRC32
739	help
740	  Say Y here if you want to enable the memory leak
741	  detector. The memory allocation/freeing is traced in a way
742	  similar to the Boehm's conservative garbage collector, the
743	  difference being that the orphan objects are not freed but
744	  only shown in /sys/kernel/debug/kmemleak. Enabling this
745	  feature will introduce an overhead to memory
746	  allocations. See Documentation/dev-tools/kmemleak.rst for more
747	  details.
748
749	  Enabling DEBUG_SLAB or SLUB_DEBUG may increase the chances
750	  of finding leaks due to the slab objects poisoning.
751
752	  In order to access the kmemleak file, debugfs needs to be
753	  mounted (usually at /sys/kernel/debug).
754
755config DEBUG_KMEMLEAK_MEM_POOL_SIZE
756	int "Kmemleak memory pool size"
757	depends on DEBUG_KMEMLEAK
758	range 200 1000000
759	default 16000
760	help
761	  Kmemleak must track all the memory allocations to avoid
762	  reporting false positives. Since memory may be allocated or
763	  freed before kmemleak is fully initialised, use a static pool
764	  of metadata objects to track such callbacks. After kmemleak is
765	  fully initialised, this memory pool acts as an emergency one
766	  if slab allocations fail.
767
768config DEBUG_KMEMLEAK_TEST
769	tristate "Simple test for the kernel memory leak detector"
770	depends on DEBUG_KMEMLEAK && m
771	help
772	  This option enables a module that explicitly leaks memory.
773
774	  If unsure, say N.
775
776config DEBUG_KMEMLEAK_DEFAULT_OFF
777	bool "Default kmemleak to off"
778	depends on DEBUG_KMEMLEAK
779	help
780	  Say Y here to disable kmemleak by default. It can then be enabled
781	  on the command line via kmemleak=on.
782
783config DEBUG_KMEMLEAK_AUTO_SCAN
784	bool "Enable kmemleak auto scan thread on boot up"
785	default y
786	depends on DEBUG_KMEMLEAK
787	help
788	  Depending on the cpu, kmemleak scan may be cpu intensive and can
789	  stall user tasks at times. This option enables/disables automatic
790	  kmemleak scan at boot up.
791
792	  Say N here to disable kmemleak auto scan thread to stop automatic
793	  scanning. Disabling this option disables automatic reporting of
794	  memory leaks.
795
796	  If unsure, say Y.
797
798config DEBUG_STACK_USAGE
799	bool "Stack utilization instrumentation"
800	depends on DEBUG_KERNEL && !IA64
801	help
802	  Enables the display of the minimum amount of free stack which each
803	  task has ever had available in the sysrq-T and sysrq-P debug output.
804
805	  This option will slow down process creation somewhat.
806
807config SCHED_STACK_END_CHECK
808	bool "Detect stack corruption on calls to schedule()"
809	depends on DEBUG_KERNEL
810	default n
811	help
812	  This option checks for a stack overrun on calls to schedule().
813	  If the stack end location is found to be over written always panic as
814	  the content of the corrupted region can no longer be trusted.
815	  This is to ensure no erroneous behaviour occurs which could result in
816	  data corruption or a sporadic crash at a later stage once the region
817	  is examined. The runtime overhead introduced is minimal.
818
819config ARCH_HAS_DEBUG_VM_PGTABLE
820	bool
821	help
822	  An architecture should select this when it can successfully
823	  build and run DEBUG_VM_PGTABLE.
824
825config DEBUG_VM_IRQSOFF
826	def_bool DEBUG_VM && !PREEMPT_RT
827
828config DEBUG_VM
829	bool "Debug VM"
830	depends on DEBUG_KERNEL
831	help
832	  Enable this to turn on extended checks in the virtual-memory system
833	  that may impact performance.
834
835	  If unsure, say N.
836
837config DEBUG_VM_MAPLE_TREE
838	bool "Debug VM maple trees"
839	depends on DEBUG_VM
840	select DEBUG_MAPLE_TREE
841	help
842	  Enable VM maple tree debugging information and extra validations.
843
844	  If unsure, say N.
845
846config DEBUG_VM_RB
847	bool "Debug VM red-black trees"
848	depends on DEBUG_VM
849	help
850	  Enable VM red-black tree debugging information and extra validations.
851
852	  If unsure, say N.
853
854config DEBUG_VM_PGFLAGS
855	bool "Debug page-flags operations"
856	depends on DEBUG_VM
857	help
858	  Enables extra validation on page flags operations.
859
860	  If unsure, say N.
861
862config DEBUG_VM_PGTABLE
863	bool "Debug arch page table for semantics compliance"
864	depends on MMU
865	depends on ARCH_HAS_DEBUG_VM_PGTABLE
866	default y if DEBUG_VM
867	help
868	  This option provides a debug method which can be used to test
869	  architecture page table helper functions on various platforms in
870	  verifying if they comply with expected generic MM semantics. This
871	  will help architecture code in making sure that any changes or
872	  new additions of these helpers still conform to expected
873	  semantics of the generic MM. Platforms will have to opt in for
874	  this through ARCH_HAS_DEBUG_VM_PGTABLE.
875
876	  If unsure, say N.
877
878config ARCH_HAS_DEBUG_VIRTUAL
879	bool
880
881config DEBUG_VIRTUAL
882	bool "Debug VM translations"
883	depends on DEBUG_KERNEL && ARCH_HAS_DEBUG_VIRTUAL
884	help
885	  Enable some costly sanity checks in virtual to page code. This can
886	  catch mistakes with virt_to_page() and friends.
887
888	  If unsure, say N.
889
890config DEBUG_NOMMU_REGIONS
891	bool "Debug the global anon/private NOMMU mapping region tree"
892	depends on DEBUG_KERNEL && !MMU
893	help
894	  This option causes the global tree of anonymous and private mapping
895	  regions to be regularly checked for invalid topology.
896
897config DEBUG_MEMORY_INIT
898	bool "Debug memory initialisation" if EXPERT
899	default !EXPERT
900	help
901	  Enable this for additional checks during memory initialisation.
902	  The sanity checks verify aspects of the VM such as the memory model
903	  and other information provided by the architecture. Verbose
904	  information will be printed at KERN_DEBUG loglevel depending
905	  on the mminit_loglevel= command-line option.
906
907	  If unsure, say Y
908
909config MEMORY_NOTIFIER_ERROR_INJECT
910	tristate "Memory hotplug notifier error injection module"
911	depends on MEMORY_HOTPLUG && NOTIFIER_ERROR_INJECTION
912	help
913	  This option provides the ability to inject artificial errors to
914	  memory hotplug notifier chain callbacks.  It is controlled through
915	  debugfs interface under /sys/kernel/debug/notifier-error-inject/memory
916
917	  If the notifier call chain should be failed with some events
918	  notified, write the error code to "actions/<notifier event>/error".
919
920	  Example: Inject memory hotplug offline error (-12 == -ENOMEM)
921
922	  # cd /sys/kernel/debug/notifier-error-inject/memory
923	  # echo -12 > actions/MEM_GOING_OFFLINE/error
924	  # echo offline > /sys/devices/system/memory/memoryXXX/state
925	  bash: echo: write error: Cannot allocate memory
926
927	  To compile this code as a module, choose M here: the module will
928	  be called memory-notifier-error-inject.
929
930	  If unsure, say N.
931
932config DEBUG_PER_CPU_MAPS
933	bool "Debug access to per_cpu maps"
934	depends on DEBUG_KERNEL
935	depends on SMP
936	help
937	  Say Y to verify that the per_cpu map being accessed has
938	  been set up. This adds a fair amount of code to kernel memory
939	  and decreases performance.
940
941	  Say N if unsure.
942
943config DEBUG_KMAP_LOCAL
944	bool "Debug kmap_local temporary mappings"
945	depends on DEBUG_KERNEL && KMAP_LOCAL
946	help
947	  This option enables additional error checking for the kmap_local
948	  infrastructure.  Disable for production use.
949
950config ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
951	bool
952
953config DEBUG_KMAP_LOCAL_FORCE_MAP
954	bool "Enforce kmap_local temporary mappings"
955	depends on DEBUG_KERNEL && ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
956	select KMAP_LOCAL
957	select DEBUG_KMAP_LOCAL
958	help
959	  This option enforces temporary mappings through the kmap_local
960	  mechanism for non-highmem pages and on non-highmem systems.
961	  Disable this for production systems!
962
963config DEBUG_HIGHMEM
964	bool "Highmem debugging"
965	depends on DEBUG_KERNEL && HIGHMEM
966	select DEBUG_KMAP_LOCAL_FORCE_MAP if ARCH_SUPPORTS_KMAP_LOCAL_FORCE_MAP
967	select DEBUG_KMAP_LOCAL
968	help
969	  This option enables additional error checking for high memory
970	  systems.  Disable for production systems.
971
972config HAVE_DEBUG_STACKOVERFLOW
973	bool
974
975config DEBUG_STACKOVERFLOW
976	bool "Check for stack overflows"
977	depends on DEBUG_KERNEL && HAVE_DEBUG_STACKOVERFLOW
978	help
979	  Say Y here if you want to check for overflows of kernel, IRQ
980	  and exception stacks (if your architecture uses them). This
981	  option will show detailed messages if free stack space drops
982	  below a certain limit.
983
984	  These kinds of bugs usually occur when call-chains in the
985	  kernel get too deep, especially when interrupts are
986	  involved.
987
988	  Use this in cases where you see apparently random memory
989	  corruption, especially if it appears in 'struct thread_info'
990
991	  If in doubt, say "N".
992
993source "lib/Kconfig.kasan"
994source "lib/Kconfig.kfence"
995source "lib/Kconfig.kmsan"
996
997endmenu # "Memory Debugging"
998
999config DEBUG_SHIRQ
1000	bool "Debug shared IRQ handlers"
1001	depends on DEBUG_KERNEL
1002	help
1003	  Enable this to generate a spurious interrupt just before a shared
1004	  interrupt handler is deregistered (generating one when registering
1005	  is currently disabled). Drivers need to handle this correctly. Some
1006	  don't and need to be caught.
1007
1008menu "Debug Oops, Lockups and Hangs"
1009
1010config PANIC_ON_OOPS
1011	bool "Panic on Oops"
1012	help
1013	  Say Y here to enable the kernel to panic when it oopses. This
1014	  has the same effect as setting oops=panic on the kernel command
1015	  line.
1016
1017	  This feature is useful to ensure that the kernel does not do
1018	  anything erroneous after an oops which could result in data
1019	  corruption or other issues.
1020
1021	  Say N if unsure.
1022
1023config PANIC_ON_OOPS_VALUE
1024	int
1025	range 0 1
1026	default 0 if !PANIC_ON_OOPS
1027	default 1 if PANIC_ON_OOPS
1028
1029config PANIC_TIMEOUT
1030	int "panic timeout"
1031	default 0
1032	help
1033	  Set the timeout value (in seconds) until a reboot occurs when
1034	  the kernel panics. If n = 0, then we wait forever. A timeout
1035	  value n > 0 will wait n seconds before rebooting, while a timeout
1036	  value n < 0 will reboot immediately.
1037
1038config LOCKUP_DETECTOR
1039	bool
1040
1041config SOFTLOCKUP_DETECTOR
1042	bool "Detect Soft Lockups"
1043	depends on DEBUG_KERNEL && !S390
1044	select LOCKUP_DETECTOR
1045	help
1046	  Say Y here to enable the kernel to act as a watchdog to detect
1047	  soft lockups.
1048
1049	  Softlockups are bugs that cause the kernel to loop in kernel
1050	  mode for more than 20 seconds, without giving other tasks a
1051	  chance to run.  The current stack trace is displayed upon
1052	  detection and the system will stay locked up.
1053
1054config BOOTPARAM_SOFTLOCKUP_PANIC
1055	bool "Panic (Reboot) On Soft Lockups"
1056	depends on SOFTLOCKUP_DETECTOR
1057	help
1058	  Say Y here to enable the kernel to panic on "soft lockups",
1059	  which are bugs that cause the kernel to loop in kernel
1060	  mode for more than 20 seconds (configurable using the watchdog_thresh
1061	  sysctl), without giving other tasks a chance to run.
1062
1063	  The panic can be used in combination with panic_timeout,
1064	  to cause the system to reboot automatically after a
1065	  lockup has been detected. This feature is useful for
1066	  high-availability systems that have uptime guarantees and
1067	  where a lockup must be resolved ASAP.
1068
1069	  Say N if unsure.
1070
1071config HARDLOCKUP_DETECTOR_PERF
1072	bool
1073	select SOFTLOCKUP_DETECTOR
1074
1075#
1076# Enables a timestamp based low pass filter to compensate for perf based
1077# hard lockup detection which runs too fast due to turbo modes.
1078#
1079config HARDLOCKUP_CHECK_TIMESTAMP
1080	bool
1081
1082#
1083# arch/ can define HAVE_HARDLOCKUP_DETECTOR_ARCH to provide their own hard
1084# lockup detector rather than the perf based detector.
1085#
1086config HARDLOCKUP_DETECTOR
1087	bool "Detect Hard Lockups"
1088	depends on DEBUG_KERNEL && !S390
1089	depends on HAVE_HARDLOCKUP_DETECTOR_PERF || HAVE_HARDLOCKUP_DETECTOR_ARCH
1090	select LOCKUP_DETECTOR
1091	select HARDLOCKUP_DETECTOR_PERF if HAVE_HARDLOCKUP_DETECTOR_PERF
1092	help
1093	  Say Y here to enable the kernel to act as a watchdog to detect
1094	  hard lockups.
1095
1096	  Hardlockups are bugs that cause the CPU to loop in kernel mode
1097	  for more than 10 seconds, without letting other interrupts have a
1098	  chance to run.  The current stack trace is displayed upon detection
1099	  and the system will stay locked up.
1100
1101config BOOTPARAM_HARDLOCKUP_PANIC
1102	bool "Panic (Reboot) On Hard Lockups"
1103	depends on HARDLOCKUP_DETECTOR
1104	help
1105	  Say Y here to enable the kernel to panic on "hard lockups",
1106	  which are bugs that cause the kernel to loop in kernel
1107	  mode with interrupts disabled for more than 10 seconds (configurable
1108	  using the watchdog_thresh sysctl).
1109
1110	  Say N if unsure.
1111
1112config DETECT_HUNG_TASK
1113	bool "Detect Hung Tasks"
1114	depends on DEBUG_KERNEL
1115	default SOFTLOCKUP_DETECTOR
1116	help
1117	  Say Y here to enable the kernel to detect "hung tasks",
1118	  which are bugs that cause the task to be stuck in
1119	  uninterruptible "D" state indefinitely.
1120
1121	  When a hung task is detected, the kernel will print the
1122	  current stack trace (which you should report), but the
1123	  task will stay in uninterruptible state. If lockdep is
1124	  enabled then all held locks will also be reported. This
1125	  feature has negligible overhead.
1126
1127config DEFAULT_HUNG_TASK_TIMEOUT
1128	int "Default timeout for hung task detection (in seconds)"
1129	depends on DETECT_HUNG_TASK
1130	default 120
1131	help
1132	  This option controls the default timeout (in seconds) used
1133	  to determine when a task has become non-responsive and should
1134	  be considered hung.
1135
1136	  It can be adjusted at runtime via the kernel.hung_task_timeout_secs
1137	  sysctl or by writing a value to
1138	  /proc/sys/kernel/hung_task_timeout_secs.
1139
1140	  A timeout of 0 disables the check.  The default is two minutes.
1141	  Keeping the default should be fine in most cases.
1142
1143config BOOTPARAM_HUNG_TASK_PANIC
1144	bool "Panic (Reboot) On Hung Tasks"
1145	depends on DETECT_HUNG_TASK
1146	help
1147	  Say Y here to enable the kernel to panic on "hung tasks",
1148	  which are bugs that cause the kernel to leave a task stuck
1149	  in uninterruptible "D" state.
1150
1151	  The panic can be used in combination with panic_timeout,
1152	  to cause the system to reboot automatically after a
1153	  hung task has been detected. This feature is useful for
1154	  high-availability systems that have uptime guarantees and
1155	  where a hung tasks must be resolved ASAP.
1156
1157	  Say N if unsure.
1158
1159config WQ_WATCHDOG
1160	bool "Detect Workqueue Stalls"
1161	depends on DEBUG_KERNEL
1162	help
1163	  Say Y here to enable stall detection on workqueues.  If a
1164	  worker pool doesn't make forward progress on a pending work
1165	  item for over a given amount of time, 30s by default, a
1166	  warning message is printed along with dump of workqueue
1167	  state.  This can be configured through kernel parameter
1168	  "workqueue.watchdog_thresh" and its sysfs counterpart.
1169
1170config TEST_LOCKUP
1171	tristate "Test module to generate lockups"
1172	depends on m
1173	help
1174	  This builds the "test_lockup" module that helps to make sure
1175	  that watchdogs and lockup detectors are working properly.
1176
1177	  Depending on module parameters it could emulate soft or hard
1178	  lockup, "hung task", or locking arbitrary lock for a long time.
1179	  Also it could generate series of lockups with cooling-down periods.
1180
1181	  If unsure, say N.
1182
1183endmenu # "Debug lockups and hangs"
1184
1185menu "Scheduler Debugging"
1186
1187config SCHED_DEBUG
1188	bool "Collect scheduler debugging info"
1189	depends on DEBUG_KERNEL && PROC_FS
1190	default y
1191	help
1192	  If you say Y here, the /proc/sched_debug file will be provided
1193	  that can help debug the scheduler. The runtime overhead of this
1194	  option is minimal.
1195
1196config SCHED_INFO
1197	bool
1198	default n
1199
1200config SCHEDSTATS
1201	bool "Collect scheduler statistics"
1202	depends on DEBUG_KERNEL && PROC_FS
1203	select SCHED_INFO
1204	help
1205	  If you say Y here, additional code will be inserted into the
1206	  scheduler and related routines to collect statistics about
1207	  scheduler behavior and provide them in /proc/schedstat.  These
1208	  stats may be useful for both tuning and debugging the scheduler
1209	  If you aren't debugging the scheduler or trying to tune a specific
1210	  application, you can say N to avoid the very slight overhead
1211	  this adds.
1212
1213endmenu
1214
1215config DEBUG_TIMEKEEPING
1216	bool "Enable extra timekeeping sanity checking"
1217	help
1218	  This option will enable additional timekeeping sanity checks
1219	  which may be helpful when diagnosing issues where timekeeping
1220	  problems are suspected.
1221
1222	  This may include checks in the timekeeping hotpaths, so this
1223	  option may have a (very small) performance impact to some
1224	  workloads.
1225
1226	  If unsure, say N.
1227
1228config DEBUG_PREEMPT
1229	bool "Debug preemptible kernel"
1230	depends on DEBUG_KERNEL && PREEMPTION && TRACE_IRQFLAGS_SUPPORT
1231	help
1232	  If you say Y here then the kernel will use a debug variant of the
1233	  commonly used smp_processor_id() function and will print warnings
1234	  if kernel code uses it in a preemption-unsafe way. Also, the kernel
1235	  will detect preemption count underflows.
1236
1237	  This option has potential to introduce high runtime overhead,
1238	  depending on workload as it triggers debugging routines for each
1239	  this_cpu operation. It should only be used for debugging purposes.
1240
1241menu "Lock Debugging (spinlocks, mutexes, etc...)"
1242
1243config LOCK_DEBUGGING_SUPPORT
1244	bool
1245	depends on TRACE_IRQFLAGS_SUPPORT && STACKTRACE_SUPPORT && LOCKDEP_SUPPORT
1246	default y
1247
1248config PROVE_LOCKING
1249	bool "Lock debugging: prove locking correctness"
1250	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1251	select LOCKDEP
1252	select DEBUG_SPINLOCK
1253	select DEBUG_MUTEXES if !PREEMPT_RT
1254	select DEBUG_RT_MUTEXES if RT_MUTEXES
1255	select DEBUG_RWSEMS
1256	select DEBUG_WW_MUTEX_SLOWPATH
1257	select DEBUG_LOCK_ALLOC
1258	select PREEMPT_COUNT if !ARCH_NO_PREEMPT
1259	select TRACE_IRQFLAGS
1260	default n
1261	help
1262	 This feature enables the kernel to prove that all locking
1263	 that occurs in the kernel runtime is mathematically
1264	 correct: that under no circumstance could an arbitrary (and
1265	 not yet triggered) combination of observed locking
1266	 sequences (on an arbitrary number of CPUs, running an
1267	 arbitrary number of tasks and interrupt contexts) cause a
1268	 deadlock.
1269
1270	 In short, this feature enables the kernel to report locking
1271	 related deadlocks before they actually occur.
1272
1273	 The proof does not depend on how hard and complex a
1274	 deadlock scenario would be to trigger: how many
1275	 participant CPUs, tasks and irq-contexts would be needed
1276	 for it to trigger. The proof also does not depend on
1277	 timing: if a race and a resulting deadlock is possible
1278	 theoretically (no matter how unlikely the race scenario
1279	 is), it will be proven so and will immediately be
1280	 reported by the kernel (once the event is observed that
1281	 makes the deadlock theoretically possible).
1282
1283	 If a deadlock is impossible (i.e. the locking rules, as
1284	 observed by the kernel, are mathematically correct), the
1285	 kernel reports nothing.
1286
1287	 NOTE: this feature can also be enabled for rwlocks, mutexes
1288	 and rwsems - in which case all dependencies between these
1289	 different locking variants are observed and mapped too, and
1290	 the proof of observed correctness is also maintained for an
1291	 arbitrary combination of these separate locking variants.
1292
1293	 For more details, see Documentation/locking/lockdep-design.rst.
1294
1295config PROVE_RAW_LOCK_NESTING
1296	bool "Enable raw_spinlock - spinlock nesting checks"
1297	depends on PROVE_LOCKING
1298	default n
1299	help
1300	 Enable the raw_spinlock vs. spinlock nesting checks which ensure
1301	 that the lock nesting rules for PREEMPT_RT enabled kernels are
1302	 not violated.
1303
1304	 NOTE: There are known nesting problems. So if you enable this
1305	 option expect lockdep splats until these problems have been fully
1306	 addressed which is work in progress. This config switch allows to
1307	 identify and analyze these problems. It will be removed and the
1308	 check permanently enabled once the main issues have been fixed.
1309
1310	 If unsure, select N.
1311
1312config LOCK_STAT
1313	bool "Lock usage statistics"
1314	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1315	select LOCKDEP
1316	select DEBUG_SPINLOCK
1317	select DEBUG_MUTEXES if !PREEMPT_RT
1318	select DEBUG_RT_MUTEXES if RT_MUTEXES
1319	select DEBUG_LOCK_ALLOC
1320	default n
1321	help
1322	 This feature enables tracking lock contention points
1323
1324	 For more details, see Documentation/locking/lockstat.rst
1325
1326	 This also enables lock events required by "perf lock",
1327	 subcommand of perf.
1328	 If you want to use "perf lock", you also need to turn on
1329	 CONFIG_EVENT_TRACING.
1330
1331	 CONFIG_LOCK_STAT defines "contended" and "acquired" lock events.
1332	 (CONFIG_LOCKDEP defines "acquire" and "release" events.)
1333
1334config DEBUG_RT_MUTEXES
1335	bool "RT Mutex debugging, deadlock detection"
1336	depends on DEBUG_KERNEL && RT_MUTEXES
1337	help
1338	 This allows rt mutex semantics violations and rt mutex related
1339	 deadlocks (lockups) to be detected and reported automatically.
1340
1341config DEBUG_SPINLOCK
1342	bool "Spinlock and rw-lock debugging: basic checks"
1343	depends on DEBUG_KERNEL
1344	select UNINLINE_SPIN_UNLOCK
1345	help
1346	  Say Y here and build SMP to catch missing spinlock initialization
1347	  and certain other kinds of spinlock errors commonly made.  This is
1348	  best used in conjunction with the NMI watchdog so that spinlock
1349	  deadlocks are also debuggable.
1350
1351config DEBUG_MUTEXES
1352	bool "Mutex debugging: basic checks"
1353	depends on DEBUG_KERNEL && !PREEMPT_RT
1354	help
1355	 This feature allows mutex semantics violations to be detected and
1356	 reported.
1357
1358config DEBUG_WW_MUTEX_SLOWPATH
1359	bool "Wait/wound mutex debugging: Slowpath testing"
1360	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1361	select DEBUG_LOCK_ALLOC
1362	select DEBUG_SPINLOCK
1363	select DEBUG_MUTEXES if !PREEMPT_RT
1364	select DEBUG_RT_MUTEXES if PREEMPT_RT
1365	help
1366	 This feature enables slowpath testing for w/w mutex users by
1367	 injecting additional -EDEADLK wound/backoff cases. Together with
1368	 the full mutex checks enabled with (CONFIG_PROVE_LOCKING) this
1369	 will test all possible w/w mutex interface abuse with the
1370	 exception of simply not acquiring all the required locks.
1371	 Note that this feature can introduce significant overhead, so
1372	 it really should not be enabled in a production or distro kernel,
1373	 even a debug kernel.  If you are a driver writer, enable it.  If
1374	 you are a distro, do not.
1375
1376config DEBUG_RWSEMS
1377	bool "RW Semaphore debugging: basic checks"
1378	depends on DEBUG_KERNEL
1379	help
1380	  This debugging feature allows mismatched rw semaphore locks
1381	  and unlocks to be detected and reported.
1382
1383config DEBUG_LOCK_ALLOC
1384	bool "Lock debugging: detect incorrect freeing of live locks"
1385	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1386	select DEBUG_SPINLOCK
1387	select DEBUG_MUTEXES if !PREEMPT_RT
1388	select DEBUG_RT_MUTEXES if RT_MUTEXES
1389	select LOCKDEP
1390	help
1391	 This feature will check whether any held lock (spinlock, rwlock,
1392	 mutex or rwsem) is incorrectly freed by the kernel, via any of the
1393	 memory-freeing routines (kfree(), kmem_cache_free(), free_pages(),
1394	 vfree(), etc.), whether a live lock is incorrectly reinitialized via
1395	 spin_lock_init()/mutex_init()/etc., or whether there is any lock
1396	 held during task exit.
1397
1398config LOCKDEP
1399	bool
1400	depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
1401	select STACKTRACE
1402	select KALLSYMS
1403	select KALLSYMS_ALL
1404
1405config LOCKDEP_SMALL
1406	bool
1407
1408config LOCKDEP_BITS
1409	int "Bitsize for MAX_LOCKDEP_ENTRIES"
1410	depends on LOCKDEP && !LOCKDEP_SMALL
1411	range 10 30
1412	default 15
1413	help
1414	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
1415
1416config LOCKDEP_CHAINS_BITS
1417	int "Bitsize for MAX_LOCKDEP_CHAINS"
1418	depends on LOCKDEP && !LOCKDEP_SMALL
1419	range 10 30
1420	default 16
1421	help
1422	  Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
1423
1424config LOCKDEP_STACK_TRACE_BITS
1425	int "Bitsize for MAX_STACK_TRACE_ENTRIES"
1426	depends on LOCKDEP && !LOCKDEP_SMALL
1427	range 10 30
1428	default 19
1429	help
1430	  Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
1431
1432config LOCKDEP_STACK_TRACE_HASH_BITS
1433	int "Bitsize for STACK_TRACE_HASH_SIZE"
1434	depends on LOCKDEP && !LOCKDEP_SMALL
1435	range 10 30
1436	default 14
1437	help
1438	  Try increasing this value if you need large MAX_STACK_TRACE_ENTRIES.
1439
1440config LOCKDEP_CIRCULAR_QUEUE_BITS
1441	int "Bitsize for elements in circular_queue struct"
1442	depends on LOCKDEP
1443	range 10 30
1444	default 12
1445	help
1446	  Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
1447
1448config DEBUG_LOCKDEP
1449	bool "Lock dependency engine debugging"
1450	depends on DEBUG_KERNEL && LOCKDEP
1451	select DEBUG_IRQFLAGS
1452	help
1453	  If you say Y here, the lock dependency engine will do
1454	  additional runtime checks to debug itself, at the price
1455	  of more runtime overhead.
1456
1457config DEBUG_ATOMIC_SLEEP
1458	bool "Sleep inside atomic section checking"
1459	select PREEMPT_COUNT
1460	depends on DEBUG_KERNEL
1461	depends on !ARCH_NO_PREEMPT
1462	help
1463	  If you say Y here, various routines which may sleep will become very
1464	  noisy if they are called inside atomic sections: when a spinlock is
1465	  held, inside an rcu read side critical section, inside preempt disabled
1466	  sections, inside an interrupt, etc...
1467
1468config DEBUG_LOCKING_API_SELFTESTS
1469	bool "Locking API boot-time self-tests"
1470	depends on DEBUG_KERNEL
1471	help
1472	  Say Y here if you want the kernel to run a short self-test during
1473	  bootup. The self-test checks whether common types of locking bugs
1474	  are detected by debugging mechanisms or not. (if you disable
1475	  lock debugging then those bugs won't be detected of course.)
1476	  The following locking APIs are covered: spinlocks, rwlocks,
1477	  mutexes and rwsems.
1478
1479config LOCK_TORTURE_TEST
1480	tristate "torture tests for locking"
1481	depends on DEBUG_KERNEL
1482	select TORTURE_TEST
1483	help
1484	  This option provides a kernel module that runs torture tests
1485	  on kernel locking primitives.  The kernel module may be built
1486	  after the fact on the running kernel to be tested, if desired.
1487
1488	  Say Y here if you want kernel locking-primitive torture tests
1489	  to be built into the kernel.
1490	  Say M if you want these torture tests to build as a module.
1491	  Say N if you are unsure.
1492
1493config WW_MUTEX_SELFTEST
1494	tristate "Wait/wound mutex selftests"
1495	help
1496	  This option provides a kernel module that runs tests on the
1497	  on the struct ww_mutex locking API.
1498
1499	  It is recommended to enable DEBUG_WW_MUTEX_SLOWPATH in conjunction
1500	  with this test harness.
1501
1502	  Say M if you want these self tests to build as a module.
1503	  Say N if you are unsure.
1504
1505config SCF_TORTURE_TEST
1506	tristate "torture tests for smp_call_function*()"
1507	depends on DEBUG_KERNEL
1508	select TORTURE_TEST
1509	help
1510	  This option provides a kernel module that runs torture tests
1511	  on the smp_call_function() family of primitives.  The kernel
1512	  module may be built after the fact on the running kernel to
1513	  be tested, if desired.
1514
1515config CSD_LOCK_WAIT_DEBUG
1516	bool "Debugging for csd_lock_wait(), called from smp_call_function*()"
1517	depends on DEBUG_KERNEL
1518	depends on 64BIT
1519	default n
1520	help
1521	  This option enables debug prints when CPUs are slow to respond
1522	  to the smp_call_function*() IPI wrappers.  These debug prints
1523	  include the IPI handler function currently executing (if any)
1524	  and relevant stack traces.
1525
1526endmenu # lock debugging
1527
1528config TRACE_IRQFLAGS
1529	depends on TRACE_IRQFLAGS_SUPPORT
1530	bool
1531	help
1532	  Enables hooks to interrupt enabling and disabling for
1533	  either tracing or lock debugging.
1534
1535config TRACE_IRQFLAGS_NMI
1536	def_bool y
1537	depends on TRACE_IRQFLAGS
1538	depends on TRACE_IRQFLAGS_NMI_SUPPORT
1539
1540config DEBUG_IRQFLAGS
1541	bool "Debug IRQ flag manipulation"
1542	help
1543	  Enables checks for potentially unsafe enabling or disabling of
1544	  interrupts, such as calling raw_local_irq_restore() when interrupts
1545	  are enabled.
1546
1547config STACKTRACE
1548	bool "Stack backtrace support"
1549	depends on STACKTRACE_SUPPORT
1550	help
1551	  This option causes the kernel to create a /proc/pid/stack for
1552	  every process, showing its current stack trace.
1553	  It is also used by various kernel debugging features that require
1554	  stack trace generation.
1555
1556config WARN_ALL_UNSEEDED_RANDOM
1557	bool "Warn for all uses of unseeded randomness"
1558	default n
1559	help
1560	  Some parts of the kernel contain bugs relating to their use of
1561	  cryptographically secure random numbers before it's actually possible
1562	  to generate those numbers securely. This setting ensures that these
1563	  flaws don't go unnoticed, by enabling a message, should this ever
1564	  occur. This will allow people with obscure setups to know when things
1565	  are going wrong, so that they might contact developers about fixing
1566	  it.
1567
1568	  Unfortunately, on some models of some architectures getting
1569	  a fully seeded CRNG is extremely difficult, and so this can
1570	  result in dmesg getting spammed for a surprisingly long
1571	  time.  This is really bad from a security perspective, and
1572	  so architecture maintainers really need to do what they can
1573	  to get the CRNG seeded sooner after the system is booted.
1574	  However, since users cannot do anything actionable to
1575	  address this, by default this option is disabled.
1576
1577	  Say Y here if you want to receive warnings for all uses of
1578	  unseeded randomness.  This will be of use primarily for
1579	  those developers interested in improving the security of
1580	  Linux kernels running on their architecture (or
1581	  subarchitecture).
1582
1583config DEBUG_KOBJECT
1584	bool "kobject debugging"
1585	depends on DEBUG_KERNEL
1586	help
1587	  If you say Y here, some extra kobject debugging messages will be sent
1588	  to the syslog.
1589
1590config DEBUG_KOBJECT_RELEASE
1591	bool "kobject release debugging"
1592	depends on DEBUG_OBJECTS_TIMERS
1593	help
1594	  kobjects are reference counted objects.  This means that their
1595	  last reference count put is not predictable, and the kobject can
1596	  live on past the point at which a driver decides to drop its
1597	  initial reference to the kobject gained on allocation.  An
1598	  example of this would be a struct device which has just been
1599	  unregistered.
1600
1601	  However, some buggy drivers assume that after such an operation,
1602	  the memory backing the kobject can be immediately freed.  This
1603	  goes completely against the principles of a refcounted object.
1604
1605	  If you say Y here, the kernel will delay the release of kobjects
1606	  on the last reference count to improve the visibility of this
1607	  kind of kobject release bug.
1608
1609config HAVE_DEBUG_BUGVERBOSE
1610	bool
1611
1612menu "Debug kernel data structures"
1613
1614config DEBUG_LIST
1615	bool "Debug linked list manipulation"
1616	depends on DEBUG_KERNEL || BUG_ON_DATA_CORRUPTION
1617	help
1618	  Enable this to turn on extended checks in the linked-list
1619	  walking routines.
1620
1621	  If unsure, say N.
1622
1623config DEBUG_PLIST
1624	bool "Debug priority linked list manipulation"
1625	depends on DEBUG_KERNEL
1626	help
1627	  Enable this to turn on extended checks in the priority-ordered
1628	  linked-list (plist) walking routines.  This checks the entire
1629	  list multiple times during each manipulation.
1630
1631	  If unsure, say N.
1632
1633config DEBUG_SG
1634	bool "Debug SG table operations"
1635	depends on DEBUG_KERNEL
1636	help
1637	  Enable this to turn on checks on scatter-gather tables. This can
1638	  help find problems with drivers that do not properly initialize
1639	  their sg tables.
1640
1641	  If unsure, say N.
1642
1643config DEBUG_NOTIFIERS
1644	bool "Debug notifier call chains"
1645	depends on DEBUG_KERNEL
1646	help
1647	  Enable this to turn on sanity checking for notifier call chains.
1648	  This is most useful for kernel developers to make sure that
1649	  modules properly unregister themselves from notifier chains.
1650	  This is a relatively cheap check but if you care about maximum
1651	  performance, say N.
1652
1653config BUG_ON_DATA_CORRUPTION
1654	bool "Trigger a BUG when data corruption is detected"
1655	select DEBUG_LIST
1656	help
1657	  Select this option if the kernel should BUG when it encounters
1658	  data corruption in kernel memory structures when they get checked
1659	  for validity.
1660
1661	  If unsure, say N.
1662
1663config DEBUG_MAPLE_TREE
1664	bool "Debug maple trees"
1665	depends on DEBUG_KERNEL
1666	help
1667	  Enable maple tree debugging information and extra validations.
1668
1669	  If unsure, say N.
1670
1671endmenu
1672
1673config DEBUG_CREDENTIALS
1674	bool "Debug credential management"
1675	depends on DEBUG_KERNEL
1676	help
1677	  Enable this to turn on some debug checking for credential
1678	  management.  The additional code keeps track of the number of
1679	  pointers from task_structs to any given cred struct, and checks to
1680	  see that this number never exceeds the usage count of the cred
1681	  struct.
1682
1683	  Furthermore, if SELinux is enabled, this also checks that the
1684	  security pointer in the cred struct is never seen to be invalid.
1685
1686	  If unsure, say N.
1687
1688source "kernel/rcu/Kconfig.debug"
1689
1690config DEBUG_WQ_FORCE_RR_CPU
1691	bool "Force round-robin CPU selection for unbound work items"
1692	depends on DEBUG_KERNEL
1693	default n
1694	help
1695	  Workqueue used to implicitly guarantee that work items queued
1696	  without explicit CPU specified are put on the local CPU.  This
1697	  guarantee is no longer true and while local CPU is still
1698	  preferred work items may be put on foreign CPUs.  Kernel
1699	  parameter "workqueue.debug_force_rr_cpu" is added to force
1700	  round-robin CPU selection to flush out usages which depend on the
1701	  now broken guarantee.  This config option enables the debug
1702	  feature by default.  When enabled, memory and cache locality will
1703	  be impacted.
1704
1705config CPU_HOTPLUG_STATE_CONTROL
1706	bool "Enable CPU hotplug state control"
1707	depends on DEBUG_KERNEL
1708	depends on HOTPLUG_CPU
1709	default n
1710	help
1711	  Allows to write steps between "offline" and "online" to the CPUs
1712	  sysfs target file so states can be stepped granular. This is a debug
1713	  option for now as the hotplug machinery cannot be stopped and
1714	  restarted at arbitrary points yet.
1715
1716	  Say N if your are unsure.
1717
1718config LATENCYTOP
1719	bool "Latency measuring infrastructure"
1720	depends on DEBUG_KERNEL
1721	depends on STACKTRACE_SUPPORT
1722	depends on PROC_FS
1723	depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
1724	select KALLSYMS
1725	select KALLSYMS_ALL
1726	select STACKTRACE
1727	select SCHEDSTATS
1728	help
1729	  Enable this option if you want to use the LatencyTOP tool
1730	  to find out which userspace is blocking on what kernel operations.
1731
1732source "kernel/trace/Kconfig"
1733
1734config PROVIDE_OHCI1394_DMA_INIT
1735	bool "Remote debugging over FireWire early on boot"
1736	depends on PCI && X86
1737	help
1738	  If you want to debug problems which hang or crash the kernel early
1739	  on boot and the crashing machine has a FireWire port, you can use
1740	  this feature to remotely access the memory of the crashed machine
1741	  over FireWire. This employs remote DMA as part of the OHCI1394
1742	  specification which is now the standard for FireWire controllers.
1743
1744	  With remote DMA, you can monitor the printk buffer remotely using
1745	  firescope and access all memory below 4GB using fireproxy from gdb.
1746	  Even controlling a kernel debugger is possible using remote DMA.
1747
1748	  Usage:
1749
1750	  If ohci1394_dma=early is used as boot parameter, it will initialize
1751	  all OHCI1394 controllers which are found in the PCI config space.
1752
1753	  As all changes to the FireWire bus such as enabling and disabling
1754	  devices cause a bus reset and thereby disable remote DMA for all
1755	  devices, be sure to have the cable plugged and FireWire enabled on
1756	  the debugging host before booting the debug target for debugging.
1757
1758	  This code (~1k) is freed after boot. By then, the firewire stack
1759	  in charge of the OHCI-1394 controllers should be used instead.
1760
1761	  See Documentation/core-api/debugging-via-ohci1394.rst for more information.
1762
1763source "samples/Kconfig"
1764
1765config ARCH_HAS_DEVMEM_IS_ALLOWED
1766	bool
1767
1768config STRICT_DEVMEM
1769	bool "Filter access to /dev/mem"
1770	depends on MMU && DEVMEM
1771	depends on ARCH_HAS_DEVMEM_IS_ALLOWED || GENERIC_LIB_DEVMEM_IS_ALLOWED
1772	default y if PPC || X86 || ARM64
1773	help
1774	  If this option is disabled, you allow userspace (root) access to all
1775	  of memory, including kernel and userspace memory. Accidental
1776	  access to this is obviously disastrous, but specific access can
1777	  be used by people debugging the kernel. Note that with PAT support
1778	  enabled, even in this case there are restrictions on /dev/mem
1779	  use due to the cache aliasing requirements.
1780
1781	  If this option is switched on, and IO_STRICT_DEVMEM=n, the /dev/mem
1782	  file only allows userspace access to PCI space and the BIOS code and
1783	  data regions.  This is sufficient for dosemu and X and all common
1784	  users of /dev/mem.
1785
1786	  If in doubt, say Y.
1787
1788config IO_STRICT_DEVMEM
1789	bool "Filter I/O access to /dev/mem"
1790	depends on STRICT_DEVMEM
1791	help
1792	  If this option is disabled, you allow userspace (root) access to all
1793	  io-memory regardless of whether a driver is actively using that
1794	  range.  Accidental access to this is obviously disastrous, but
1795	  specific access can be used by people debugging kernel drivers.
1796
1797	  If this option is switched on, the /dev/mem file only allows
1798	  userspace access to *idle* io-memory ranges (see /proc/iomem) This
1799	  may break traditional users of /dev/mem (dosemu, legacy X, etc...)
1800	  if the driver using a given range cannot be disabled.
1801
1802	  If in doubt, say Y.
1803
1804menu "$(SRCARCH) Debugging"
1805
1806source "arch/$(SRCARCH)/Kconfig.debug"
1807
1808endmenu
1809
1810menu "Kernel Testing and Coverage"
1811
1812source "lib/kunit/Kconfig"
1813
1814config NOTIFIER_ERROR_INJECTION
1815	tristate "Notifier error injection"
1816	depends on DEBUG_KERNEL
1817	select DEBUG_FS
1818	help
1819	  This option provides the ability to inject artificial errors to
1820	  specified notifier chain callbacks. It is useful to test the error
1821	  handling of notifier call chain failures.
1822
1823	  Say N if unsure.
1824
1825config PM_NOTIFIER_ERROR_INJECT
1826	tristate "PM notifier error injection module"
1827	depends on PM && NOTIFIER_ERROR_INJECTION
1828	default m if PM_DEBUG
1829	help
1830	  This option provides the ability to inject artificial errors to
1831	  PM notifier chain callbacks.  It is controlled through debugfs
1832	  interface /sys/kernel/debug/notifier-error-inject/pm
1833
1834	  If the notifier call chain should be failed with some events
1835	  notified, write the error code to "actions/<notifier event>/error".
1836
1837	  Example: Inject PM suspend error (-12 = -ENOMEM)
1838
1839	  # cd /sys/kernel/debug/notifier-error-inject/pm/
1840	  # echo -12 > actions/PM_SUSPEND_PREPARE/error
1841	  # echo mem > /sys/power/state
1842	  bash: echo: write error: Cannot allocate memory
1843
1844	  To compile this code as a module, choose M here: the module will
1845	  be called pm-notifier-error-inject.
1846
1847	  If unsure, say N.
1848
1849config OF_RECONFIG_NOTIFIER_ERROR_INJECT
1850	tristate "OF reconfig notifier error injection module"
1851	depends on OF_DYNAMIC && NOTIFIER_ERROR_INJECTION
1852	help
1853	  This option provides the ability to inject artificial errors to
1854	  OF reconfig notifier chain callbacks.  It is controlled
1855	  through debugfs interface under
1856	  /sys/kernel/debug/notifier-error-inject/OF-reconfig/
1857
1858	  If the notifier call chain should be failed with some events
1859	  notified, write the error code to "actions/<notifier event>/error".
1860
1861	  To compile this code as a module, choose M here: the module will
1862	  be called of-reconfig-notifier-error-inject.
1863
1864	  If unsure, say N.
1865
1866config NETDEV_NOTIFIER_ERROR_INJECT
1867	tristate "Netdev notifier error injection module"
1868	depends on NET && NOTIFIER_ERROR_INJECTION
1869	help
1870	  This option provides the ability to inject artificial errors to
1871	  netdevice notifier chain callbacks.  It is controlled through debugfs
1872	  interface /sys/kernel/debug/notifier-error-inject/netdev
1873
1874	  If the notifier call chain should be failed with some events
1875	  notified, write the error code to "actions/<notifier event>/error".
1876
1877	  Example: Inject netdevice mtu change error (-22 = -EINVAL)
1878
1879	  # cd /sys/kernel/debug/notifier-error-inject/netdev
1880	  # echo -22 > actions/NETDEV_CHANGEMTU/error
1881	  # ip link set eth0 mtu 1024
1882	  RTNETLINK answers: Invalid argument
1883
1884	  To compile this code as a module, choose M here: the module will
1885	  be called netdev-notifier-error-inject.
1886
1887	  If unsure, say N.
1888
1889config FUNCTION_ERROR_INJECTION
1890	bool "Fault-injections of functions"
1891	depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
1892	help
1893	  Add fault injections into various functions that are annotated with
1894	  ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return
1895	  value of theses functions. This is useful to test error paths of code.
1896
1897	  If unsure, say N
1898
1899config FAULT_INJECTION
1900	bool "Fault-injection framework"
1901	depends on DEBUG_KERNEL
1902	help
1903	  Provide fault-injection framework.
1904	  For more details, see Documentation/fault-injection/.
1905
1906config FAILSLAB
1907	bool "Fault-injection capability for kmalloc"
1908	depends on FAULT_INJECTION
1909	depends on SLAB || SLUB
1910	help
1911	  Provide fault-injection capability for kmalloc.
1912
1913config FAIL_PAGE_ALLOC
1914	bool "Fault-injection capability for alloc_pages()"
1915	depends on FAULT_INJECTION
1916	help
1917	  Provide fault-injection capability for alloc_pages().
1918
1919config FAULT_INJECTION_USERCOPY
1920	bool "Fault injection capability for usercopy functions"
1921	depends on FAULT_INJECTION
1922	help
1923	  Provides fault-injection capability to inject failures
1924	  in usercopy functions (copy_from_user(), get_user(), ...).
1925
1926config FAIL_MAKE_REQUEST
1927	bool "Fault-injection capability for disk IO"
1928	depends on FAULT_INJECTION && BLOCK
1929	help
1930	  Provide fault-injection capability for disk IO.
1931
1932config FAIL_IO_TIMEOUT
1933	bool "Fault-injection capability for faking disk interrupts"
1934	depends on FAULT_INJECTION && BLOCK
1935	help
1936	  Provide fault-injection capability on end IO handling. This
1937	  will make the block layer "forget" an interrupt as configured,
1938	  thus exercising the error handling.
1939
1940	  Only works with drivers that use the generic timeout handling,
1941	  for others it won't do anything.
1942
1943config FAIL_FUTEX
1944	bool "Fault-injection capability for futexes"
1945	select DEBUG_FS
1946	depends on FAULT_INJECTION && FUTEX
1947	help
1948	  Provide fault-injection capability for futexes.
1949
1950config FAULT_INJECTION_DEBUG_FS
1951	bool "Debugfs entries for fault-injection capabilities"
1952	depends on FAULT_INJECTION && SYSFS && DEBUG_FS
1953	help
1954	  Enable configuration of fault-injection capabilities via debugfs.
1955
1956config FAIL_FUNCTION
1957	bool "Fault-injection capability for functions"
1958	depends on FAULT_INJECTION_DEBUG_FS && FUNCTION_ERROR_INJECTION
1959	help
1960	  Provide function-based fault-injection capability.
1961	  This will allow you to override a specific function with a return
1962	  with given return value. As a result, function caller will see
1963	  an error value and have to handle it. This is useful to test the
1964	  error handling in various subsystems.
1965
1966config FAIL_MMC_REQUEST
1967	bool "Fault-injection capability for MMC IO"
1968	depends on FAULT_INJECTION_DEBUG_FS && MMC
1969	help
1970	  Provide fault-injection capability for MMC IO.
1971	  This will make the mmc core return data errors. This is
1972	  useful to test the error handling in the mmc block device
1973	  and to test how the mmc host driver handles retries from
1974	  the block device.
1975
1976config FAIL_SUNRPC
1977	bool "Fault-injection capability for SunRPC"
1978	depends on FAULT_INJECTION_DEBUG_FS && SUNRPC_DEBUG
1979	help
1980	  Provide fault-injection capability for SunRPC and
1981	  its consumers.
1982
1983config FAULT_INJECTION_STACKTRACE_FILTER
1984	bool "stacktrace filter for fault-injection capabilities"
1985	depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
1986	depends on !X86_64
1987	select STACKTRACE
1988	depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
1989	help
1990	  Provide stacktrace filter for fault-injection capabilities
1991
1992config ARCH_HAS_KCOV
1993	bool
1994	help
1995	  An architecture should select this when it can successfully
1996	  build and run with CONFIG_KCOV. This typically requires
1997	  disabling instrumentation for some early boot code.
1998
1999config CC_HAS_SANCOV_TRACE_PC
2000	def_bool $(cc-option,-fsanitize-coverage=trace-pc)
2001
2002
2003config KCOV
2004	bool "Code coverage for fuzzing"
2005	depends on ARCH_HAS_KCOV
2006	depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
2007	depends on !ARCH_WANTS_NO_INSTR || HAVE_NOINSTR_HACK || \
2008		   GCC_VERSION >= 120000 || CLANG_VERSION >= 130000
2009	select DEBUG_FS
2010	select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
2011	select OBJTOOL if HAVE_NOINSTR_HACK
2012	help
2013	  KCOV exposes kernel code coverage information in a form suitable
2014	  for coverage-guided fuzzing (randomized testing).
2015
2016	  If RANDOMIZE_BASE is enabled, PC values will not be stable across
2017	  different machines and across reboots. If you need stable PC values,
2018	  disable RANDOMIZE_BASE.
2019
2020	  For more details, see Documentation/dev-tools/kcov.rst.
2021
2022config KCOV_ENABLE_COMPARISONS
2023	bool "Enable comparison operands collection by KCOV"
2024	depends on KCOV
2025	depends on $(cc-option,-fsanitize-coverage=trace-cmp)
2026	help
2027	  KCOV also exposes operands of every comparison in the instrumented
2028	  code along with operand sizes and PCs of the comparison instructions.
2029	  These operands can be used by fuzzing engines to improve the quality
2030	  of fuzzing coverage.
2031
2032config KCOV_INSTRUMENT_ALL
2033	bool "Instrument all code by default"
2034	depends on KCOV
2035	default y
2036	help
2037	  If you are doing generic system call fuzzing (like e.g. syzkaller),
2038	  then you will want to instrument the whole kernel and you should
2039	  say y here. If you are doing more targeted fuzzing (like e.g.
2040	  filesystem fuzzing with AFL) then you will want to enable coverage
2041	  for more specific subsets of files, and should say n here.
2042
2043config KCOV_IRQ_AREA_SIZE
2044	hex "Size of interrupt coverage collection area in words"
2045	depends on KCOV
2046	default 0x40000
2047	help
2048	  KCOV uses preallocated per-cpu areas to collect coverage from
2049	  soft interrupts. This specifies the size of those areas in the
2050	  number of unsigned long words.
2051
2052menuconfig RUNTIME_TESTING_MENU
2053	bool "Runtime Testing"
2054	def_bool y
2055
2056if RUNTIME_TESTING_MENU
2057
2058config LKDTM
2059	tristate "Linux Kernel Dump Test Tool Module"
2060	depends on DEBUG_FS
2061	help
2062	This module enables testing of the different dumping mechanisms by
2063	inducing system failures at predefined crash points.
2064	If you don't need it: say N
2065	Choose M here to compile this code as a module. The module will be
2066	called lkdtm.
2067
2068	Documentation on how to use the module can be found in
2069	Documentation/fault-injection/provoke-crashes.rst
2070
2071config CPUMASK_KUNIT_TEST
2072	tristate "KUnit test for cpumask" if !KUNIT_ALL_TESTS
2073	depends on KUNIT
2074	default KUNIT_ALL_TESTS
2075	help
2076	  Enable to turn on cpumask tests, running at boot or module load time.
2077
2078	  For more information on KUnit and unit tests in general, please refer
2079	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2080
2081	  If unsure, say N.
2082
2083config TEST_LIST_SORT
2084	tristate "Linked list sorting test" if !KUNIT_ALL_TESTS
2085	depends on KUNIT
2086	default KUNIT_ALL_TESTS
2087	help
2088	  Enable this to turn on 'list_sort()' function test. This test is
2089	  executed only once during system boot (so affects only boot time),
2090	  or at module load time.
2091
2092	  If unsure, say N.
2093
2094config TEST_MIN_HEAP
2095	tristate "Min heap test"
2096	depends on DEBUG_KERNEL || m
2097	help
2098	  Enable this to turn on min heap function tests. This test is
2099	  executed only once during system boot (so affects only boot time),
2100	  or at module load time.
2101
2102	  If unsure, say N.
2103
2104config TEST_SORT
2105	tristate "Array-based sort test" if !KUNIT_ALL_TESTS
2106	depends on KUNIT
2107	select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
2108	default KUNIT_ALL_TESTS
2109	help
2110	  This option enables the self-test function of 'sort()' at boot,
2111	  or at module load time.
2112
2113	  If unsure, say N.
2114
2115config TEST_DIV64
2116	tristate "64bit/32bit division and modulo test"
2117	depends on DEBUG_KERNEL || m
2118	help
2119	  Enable this to turn on 'do_div()' function test. This test is
2120	  executed only once during system boot (so affects only boot time),
2121	  or at module load time.
2122
2123	  If unsure, say N.
2124
2125config KPROBES_SANITY_TEST
2126	tristate "Kprobes sanity tests" if !KUNIT_ALL_TESTS
2127	depends on DEBUG_KERNEL
2128	depends on KPROBES
2129	depends on KUNIT
2130	select STACKTRACE if ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
2131	default KUNIT_ALL_TESTS
2132	help
2133	  This option provides for testing basic kprobes functionality on
2134	  boot. Samples of kprobe and kretprobe are inserted and
2135	  verified for functionality.
2136
2137	  Say N if you are unsure.
2138
2139config FPROBE_SANITY_TEST
2140	bool "Self test for fprobe"
2141	depends on DEBUG_KERNEL
2142	depends on FPROBE
2143	depends on KUNIT=y
2144	help
2145	  This option will enable testing the fprobe when the system boot.
2146	  A series of tests are made to verify that the fprobe is functioning
2147	  properly.
2148
2149	  Say N if you are unsure.
2150
2151config BACKTRACE_SELF_TEST
2152	tristate "Self test for the backtrace code"
2153	depends on DEBUG_KERNEL
2154	help
2155	  This option provides a kernel module that can be used to test
2156	  the kernel stack backtrace code. This option is not useful
2157	  for distributions or general kernels, but only for kernel
2158	  developers working on architecture code.
2159
2160	  Note that if you want to also test saved backtraces, you will
2161	  have to enable STACKTRACE as well.
2162
2163	  Say N if you are unsure.
2164
2165config TEST_REF_TRACKER
2166	tristate "Self test for reference tracker"
2167	depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
2168	select REF_TRACKER
2169	help
2170	  This option provides a kernel module performing tests
2171	  using reference tracker infrastructure.
2172
2173	  Say N if you are unsure.
2174
2175config RBTREE_TEST
2176	tristate "Red-Black tree test"
2177	depends on DEBUG_KERNEL
2178	help
2179	  A benchmark measuring the performance of the rbtree library.
2180	  Also includes rbtree invariant checks.
2181
2182config REED_SOLOMON_TEST
2183	tristate "Reed-Solomon library test"
2184	depends on DEBUG_KERNEL || m
2185	select REED_SOLOMON
2186	select REED_SOLOMON_ENC16
2187	select REED_SOLOMON_DEC16
2188	help
2189	  This option enables the self-test function of rslib at boot,
2190	  or at module load time.
2191
2192	  If unsure, say N.
2193
2194config INTERVAL_TREE_TEST
2195	tristate "Interval tree test"
2196	depends on DEBUG_KERNEL
2197	select INTERVAL_TREE
2198	help
2199	  A benchmark measuring the performance of the interval tree library
2200
2201config PERCPU_TEST
2202	tristate "Per cpu operations test"
2203	depends on m && DEBUG_KERNEL
2204	help
2205	  Enable this option to build test module which validates per-cpu
2206	  operations.
2207
2208	  If unsure, say N.
2209
2210config ATOMIC64_SELFTEST
2211	tristate "Perform an atomic64_t self-test"
2212	help
2213	  Enable this option to test the atomic64_t functions at boot or
2214	  at module load time.
2215
2216	  If unsure, say N.
2217
2218config ASYNC_RAID6_TEST
2219	tristate "Self test for hardware accelerated raid6 recovery"
2220	depends on ASYNC_RAID6_RECOV
2221	select ASYNC_MEMCPY
2222	help
2223	  This is a one-shot self test that permutes through the
2224	  recovery of all the possible two disk failure scenarios for a
2225	  N-disk array.  Recovery is performed with the asynchronous
2226	  raid6 recovery routines, and will optionally use an offload
2227	  engine if one is available.
2228
2229	  If unsure, say N.
2230
2231config TEST_HEXDUMP
2232	tristate "Test functions located in the hexdump module at runtime"
2233
2234config STRING_SELFTEST
2235	tristate "Test string functions at runtime"
2236
2237config TEST_STRING_HELPERS
2238	tristate "Test functions located in the string_helpers module at runtime"
2239
2240config TEST_STRSCPY
2241	tristate "Test strscpy*() family of functions at runtime"
2242
2243config TEST_KSTRTOX
2244	tristate "Test kstrto*() family of functions at runtime"
2245
2246config TEST_PRINTF
2247	tristate "Test printf() family of functions at runtime"
2248
2249config TEST_SCANF
2250	tristate "Test scanf() family of functions at runtime"
2251
2252config TEST_BITMAP
2253	tristate "Test bitmap_*() family of functions at runtime"
2254	help
2255	  Enable this option to test the bitmap functions at boot.
2256
2257	  If unsure, say N.
2258
2259config TEST_UUID
2260	tristate "Test functions located in the uuid module at runtime"
2261
2262config TEST_XARRAY
2263	tristate "Test the XArray code at runtime"
2264
2265config TEST_MAPLE_TREE
2266	select DEBUG_MAPLE_TREE
2267	tristate "Test the Maple Tree code at runtime"
2268
2269config TEST_RHASHTABLE
2270	tristate "Perform selftest on resizable hash table"
2271	help
2272	  Enable this option to test the rhashtable functions at boot.
2273
2274	  If unsure, say N.
2275
2276config TEST_SIPHASH
2277	tristate "Perform selftest on siphash functions"
2278	help
2279	  Enable this option to test the kernel's siphash (<linux/siphash.h>) hash
2280	  functions on boot (or module load).
2281
2282	  This is intended to help people writing architecture-specific
2283	  optimized versions.  If unsure, say N.
2284
2285config TEST_IDA
2286	tristate "Perform selftest on IDA functions"
2287
2288config TEST_PARMAN
2289	tristate "Perform selftest on priority array manager"
2290	depends on PARMAN
2291	help
2292	  Enable this option to test priority array manager on boot
2293	  (or module load).
2294
2295	  If unsure, say N.
2296
2297config TEST_IRQ_TIMINGS
2298	bool "IRQ timings selftest"
2299	depends on IRQ_TIMINGS
2300	help
2301	  Enable this option to test the irq timings code on boot.
2302
2303	  If unsure, say N.
2304
2305config TEST_LKM
2306	tristate "Test module loading with 'hello world' module"
2307	depends on m
2308	help
2309	  This builds the "test_module" module that emits "Hello, world"
2310	  on printk when loaded. It is designed to be used for basic
2311	  evaluation of the module loading subsystem (for example when
2312	  validating module verification). It lacks any extra dependencies,
2313	  and will not normally be loaded by the system unless explicitly
2314	  requested by name.
2315
2316	  If unsure, say N.
2317
2318config TEST_BITOPS
2319	tristate "Test module for compilation of bitops operations"
2320	depends on m
2321	help
2322	  This builds the "test_bitops" module that is much like the
2323	  TEST_LKM module except that it does a basic exercise of the
2324	  set/clear_bit macros and get_count_order/long to make sure there are
2325	  no compiler warnings from C=1 sparse checker or -Wextra
2326	  compilations. It has no dependencies and doesn't run or load unless
2327	  explicitly requested by name.  for example: modprobe test_bitops.
2328
2329	  If unsure, say N.
2330
2331config TEST_VMALLOC
2332	tristate "Test module for stress/performance analysis of vmalloc allocator"
2333	default n
2334       depends on MMU
2335	depends on m
2336	help
2337	  This builds the "test_vmalloc" module that should be used for
2338	  stress and performance analysis. So, any new change for vmalloc
2339	  subsystem can be evaluated from performance and stability point
2340	  of view.
2341
2342	  If unsure, say N.
2343
2344config TEST_USER_COPY
2345	tristate "Test user/kernel boundary protections"
2346	depends on m
2347	help
2348	  This builds the "test_user_copy" module that runs sanity checks
2349	  on the copy_to/from_user infrastructure, making sure basic
2350	  user/kernel boundary testing is working. If it fails to load,
2351	  a regression has been detected in the user/kernel memory boundary
2352	  protections.
2353
2354	  If unsure, say N.
2355
2356config TEST_BPF
2357	tristate "Test BPF filter functionality"
2358	depends on m && NET
2359	help
2360	  This builds the "test_bpf" module that runs various test vectors
2361	  against the BPF interpreter or BPF JIT compiler depending on the
2362	  current setting. This is in particular useful for BPF JIT compiler
2363	  development, but also to run regression tests against changes in
2364	  the interpreter code. It also enables test stubs for eBPF maps and
2365	  verifier used by user space verifier testsuite.
2366
2367	  If unsure, say N.
2368
2369config TEST_BLACKHOLE_DEV
2370	tristate "Test blackhole netdev functionality"
2371	depends on m && NET
2372	help
2373	  This builds the "test_blackhole_dev" module that validates the
2374	  data path through this blackhole netdev.
2375
2376	  If unsure, say N.
2377
2378config FIND_BIT_BENCHMARK
2379	tristate "Test find_bit functions"
2380	help
2381	  This builds the "test_find_bit" module that measure find_*_bit()
2382	  functions performance.
2383
2384	  If unsure, say N.
2385
2386config TEST_FIRMWARE
2387	tristate "Test firmware loading via userspace interface"
2388	depends on FW_LOADER
2389	help
2390	  This builds the "test_firmware" module that creates a userspace
2391	  interface for testing firmware loading. This can be used to
2392	  control the triggering of firmware loading without needing an
2393	  actual firmware-using device. The contents can be rechecked by
2394	  userspace.
2395
2396	  If unsure, say N.
2397
2398config TEST_SYSCTL
2399	tristate "sysctl test driver"
2400	depends on PROC_SYSCTL
2401	help
2402	  This builds the "test_sysctl" module. This driver enables to test the
2403	  proc sysctl interfaces available to drivers safely without affecting
2404	  production knobs which might alter system functionality.
2405
2406	  If unsure, say N.
2407
2408config BITFIELD_KUNIT
2409	tristate "KUnit test bitfield functions at runtime" if !KUNIT_ALL_TESTS
2410	depends on KUNIT
2411	default KUNIT_ALL_TESTS
2412	help
2413	  Enable this option to test the bitfield functions at boot.
2414
2415	  KUnit tests run during boot and output the results to the debug log
2416	  in TAP format (http://testanything.org/). Only useful for kernel devs
2417	  running the KUnit test harness, and not intended for inclusion into a
2418	  production build.
2419
2420	  For more information on KUnit and unit tests in general please refer
2421	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2422
2423	  If unsure, say N.
2424
2425config HASH_KUNIT_TEST
2426	tristate "KUnit Test for integer hash functions" if !KUNIT_ALL_TESTS
2427	depends on KUNIT
2428	default KUNIT_ALL_TESTS
2429	help
2430	  Enable this option to test the kernel's string (<linux/stringhash.h>), and
2431	  integer (<linux/hash.h>) hash functions on boot.
2432
2433	  KUnit tests run during boot and output the results to the debug log
2434	  in TAP format (https://testanything.org/). Only useful for kernel devs
2435	  running the KUnit test harness, and not intended for inclusion into a
2436	  production build.
2437
2438	  For more information on KUnit and unit tests in general please refer
2439	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2440
2441	  This is intended to help people writing architecture-specific
2442	  optimized versions. If unsure, say N.
2443
2444config RESOURCE_KUNIT_TEST
2445	tristate "KUnit test for resource API" if !KUNIT_ALL_TESTS
2446	depends on KUNIT
2447	default KUNIT_ALL_TESTS
2448	help
2449	  This builds the resource API unit test.
2450	  Tests the logic of API provided by resource.c and ioport.h.
2451	  For more information on KUnit and unit tests in general please refer
2452	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2453
2454	  If unsure, say N.
2455
2456config SYSCTL_KUNIT_TEST
2457	tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
2458	depends on KUNIT
2459	default KUNIT_ALL_TESTS
2460	help
2461	  This builds the proc sysctl unit test, which runs on boot.
2462	  Tests the API contract and implementation correctness of sysctl.
2463	  For more information on KUnit and unit tests in general please refer
2464	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2465
2466	  If unsure, say N.
2467
2468config LIST_KUNIT_TEST
2469	tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TESTS
2470	depends on KUNIT
2471	default KUNIT_ALL_TESTS
2472	help
2473	  This builds the linked list KUnit test suite.
2474	  It tests that the API and basic functionality of the list_head type
2475	  and associated macros.
2476
2477	  KUnit tests run during boot and output the results to the debug log
2478	  in TAP format (https://testanything.org/). Only useful for kernel devs
2479	  running the KUnit test harness, and not intended for inclusion into a
2480	  production build.
2481
2482	  For more information on KUnit and unit tests in general please refer
2483	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2484
2485	  If unsure, say N.
2486
2487config LINEAR_RANGES_TEST
2488	tristate "KUnit test for linear_ranges"
2489	depends on KUNIT
2490	select LINEAR_RANGES
2491	help
2492	  This builds the linear_ranges unit test, which runs on boot.
2493	  Tests the linear_ranges logic correctness.
2494	  For more information on KUnit and unit tests in general please refer
2495	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2496
2497	  If unsure, say N.
2498
2499config CMDLINE_KUNIT_TEST
2500	tristate "KUnit test for cmdline API" if !KUNIT_ALL_TESTS
2501	depends on KUNIT
2502	default KUNIT_ALL_TESTS
2503	help
2504	  This builds the cmdline API unit test.
2505	  Tests the logic of API provided by cmdline.c.
2506	  For more information on KUnit and unit tests in general please refer
2507	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2508
2509	  If unsure, say N.
2510
2511config BITS_TEST
2512	tristate "KUnit test for bits.h" if !KUNIT_ALL_TESTS
2513	depends on KUNIT
2514	default KUNIT_ALL_TESTS
2515	help
2516	  This builds the bits unit test.
2517	  Tests the logic of macros defined in bits.h.
2518	  For more information on KUnit and unit tests in general please refer
2519	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2520
2521	  If unsure, say N.
2522
2523config SLUB_KUNIT_TEST
2524	tristate "KUnit test for SLUB cache error detection" if !KUNIT_ALL_TESTS
2525	depends on SLUB_DEBUG && KUNIT
2526	default KUNIT_ALL_TESTS
2527	help
2528	  This builds SLUB allocator unit test.
2529	  Tests SLUB cache debugging functionality.
2530	  For more information on KUnit and unit tests in general please refer
2531	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2532
2533	  If unsure, say N.
2534
2535config RATIONAL_KUNIT_TEST
2536	tristate "KUnit test for rational.c" if !KUNIT_ALL_TESTS
2537	depends on KUNIT && RATIONAL
2538	default KUNIT_ALL_TESTS
2539	help
2540	  This builds the rational math unit test.
2541	  For more information on KUnit and unit tests in general please refer
2542	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2543
2544	  If unsure, say N.
2545
2546config MEMCPY_KUNIT_TEST
2547	tristate "Test memcpy(), memmove(), and memset() functions at runtime" if !KUNIT_ALL_TESTS
2548	depends on KUNIT
2549	default KUNIT_ALL_TESTS
2550	help
2551	  Builds unit tests for memcpy(), memmove(), and memset() functions.
2552	  For more information on KUnit and unit tests in general please refer
2553	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2554
2555	  If unsure, say N.
2556
2557config IS_SIGNED_TYPE_KUNIT_TEST
2558	tristate "Test is_signed_type() macro" if !KUNIT_ALL_TESTS
2559	depends on KUNIT
2560	default KUNIT_ALL_TESTS
2561	help
2562	  Builds unit tests for the is_signed_type() macro.
2563
2564	  For more information on KUnit and unit tests in general please refer
2565	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2566
2567	  If unsure, say N.
2568
2569config OVERFLOW_KUNIT_TEST
2570	tristate "Test check_*_overflow() functions at runtime" if !KUNIT_ALL_TESTS
2571	depends on KUNIT
2572	default KUNIT_ALL_TESTS
2573	help
2574	  Builds unit tests for the check_*_overflow(), size_*(), allocation, and
2575	  related functions.
2576
2577	  For more information on KUnit and unit tests in general please refer
2578	  to the KUnit documentation in Documentation/dev-tools/kunit/.
2579
2580	  If unsure, say N.
2581
2582config STACKINIT_KUNIT_TEST
2583	tristate "Test level of stack variable initialization" if !KUNIT_ALL_TESTS
2584	depends on KUNIT
2585	default KUNIT_ALL_TESTS
2586	help
2587	  Test if the kernel is zero-initializing stack variables and
2588	  padding. Coverage is controlled by compiler flags,
2589	  CONFIG_INIT_STACK_ALL_PATTERN, CONFIG_INIT_STACK_ALL_ZERO,
2590	  CONFIG_GCC_PLUGIN_STRUCTLEAK, CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF,
2591	  or CONFIG_GCC_PLUGIN_STRUCTLEAK_BYREF_ALL.
2592
2593config FORTIFY_KUNIT_TEST
2594	tristate "Test fortified str*() and mem*() function internals at runtime" if !KUNIT_ALL_TESTS
2595	depends on KUNIT && FORTIFY_SOURCE
2596	default KUNIT_ALL_TESTS
2597	help
2598	  Builds unit tests for checking internals of FORTIFY_SOURCE as used
2599	  by the str*() and mem*() family of functions. For testing runtime
2600	  traps of FORTIFY_SOURCE, see LKDTM's "FORTIFY_*" tests.
2601
2602config HW_BREAKPOINT_KUNIT_TEST
2603	bool "Test hw_breakpoint constraints accounting" if !KUNIT_ALL_TESTS
2604	depends on HAVE_HW_BREAKPOINT
2605	depends on KUNIT=y
2606	default KUNIT_ALL_TESTS
2607	help
2608	  Tests for hw_breakpoint constraints accounting.
2609
2610	  If unsure, say N.
2611
2612config TEST_UDELAY
2613	tristate "udelay test driver"
2614	help
2615	  This builds the "udelay_test" module that helps to make sure
2616	  that udelay() is working properly.
2617
2618	  If unsure, say N.
2619
2620config TEST_STATIC_KEYS
2621	tristate "Test static keys"
2622	depends on m
2623	help
2624	  Test the static key interfaces.
2625
2626	  If unsure, say N.
2627
2628config TEST_DYNAMIC_DEBUG
2629	tristate "Test DYNAMIC_DEBUG"
2630	depends on DYNAMIC_DEBUG
2631	help
2632	  This module registers a tracer callback to count enabled
2633	  pr_debugs in a 'do_debugging' function, then alters their
2634	  enablements, calls the function, and compares counts.
2635
2636	  If unsure, say N.
2637
2638config TEST_KMOD
2639	tristate "kmod stress tester"
2640	depends on m
2641	depends on NETDEVICES && NET_CORE && INET # for TUN
2642	depends on BLOCK
2643	depends on PAGE_SIZE_LESS_THAN_256KB # for BTRFS
2644	select TEST_LKM
2645	select XFS_FS
2646	select TUN
2647	select BTRFS_FS
2648	help
2649	  Test the kernel's module loading mechanism: kmod. kmod implements
2650	  support to load modules using the Linux kernel's usermode helper.
2651	  This test provides a series of tests against kmod.
2652
2653	  Although technically you can either build test_kmod as a module or
2654	  into the kernel we disallow building it into the kernel since
2655	  it stress tests request_module() and this will very likely cause
2656	  some issues by taking over precious threads available from other
2657	  module load requests, ultimately this could be fatal.
2658
2659	  To run tests run:
2660
2661	  tools/testing/selftests/kmod/kmod.sh --help
2662
2663	  If unsure, say N.
2664
2665config TEST_DEBUG_VIRTUAL
2666	tristate "Test CONFIG_DEBUG_VIRTUAL feature"
2667	depends on DEBUG_VIRTUAL
2668	help
2669	  Test the kernel's ability to detect incorrect calls to
2670	  virt_to_phys() done against the non-linear part of the
2671	  kernel's virtual address map.
2672
2673	  If unsure, say N.
2674
2675config TEST_MEMCAT_P
2676	tristate "Test memcat_p() helper function"
2677	help
2678	  Test the memcat_p() helper for correctly merging two
2679	  pointer arrays together.
2680
2681	  If unsure, say N.
2682
2683config TEST_LIVEPATCH
2684	tristate "Test livepatching"
2685	default n
2686	depends on DYNAMIC_DEBUG
2687	depends on LIVEPATCH
2688	depends on m
2689	help
2690	  Test kernel livepatching features for correctness.  The tests will
2691	  load test modules that will be livepatched in various scenarios.
2692
2693	  To run all the livepatching tests:
2694
2695	  make -C tools/testing/selftests TARGETS=livepatch run_tests
2696
2697	  Alternatively, individual tests may be invoked:
2698
2699	  tools/testing/selftests/livepatch/test-callbacks.sh
2700	  tools/testing/selftests/livepatch/test-livepatch.sh
2701	  tools/testing/selftests/livepatch/test-shadow-vars.sh
2702
2703	  If unsure, say N.
2704
2705config TEST_OBJAGG
2706	tristate "Perform selftest on object aggreration manager"
2707	default n
2708	depends on OBJAGG
2709	help
2710	  Enable this option to test object aggregation manager on boot
2711	  (or module load).
2712
2713config TEST_MEMINIT
2714	tristate "Test heap/page initialization"
2715	help
2716	  Test if the kernel is zero-initializing heap and page allocations.
2717	  This can be useful to test init_on_alloc and init_on_free features.
2718
2719	  If unsure, say N.
2720
2721config TEST_HMM
2722	tristate "Test HMM (Heterogeneous Memory Management)"
2723	depends on TRANSPARENT_HUGEPAGE
2724	depends on DEVICE_PRIVATE
2725	select HMM_MIRROR
2726	select MMU_NOTIFIER
2727	help
2728	  This is a pseudo device driver solely for testing HMM.
2729	  Say M here if you want to build the HMM test module.
2730	  Doing so will allow you to run tools/testing/selftest/vm/hmm-tests.
2731
2732	  If unsure, say N.
2733
2734config TEST_FREE_PAGES
2735	tristate "Test freeing pages"
2736	help
2737	  Test that a memory leak does not occur due to a race between
2738	  freeing a block of pages and a speculative page reference.
2739	  Loading this module is safe if your kernel has the bug fixed.
2740	  If the bug is not fixed, it will leak gigabytes of memory and
2741	  probably OOM your system.
2742
2743config TEST_FPU
2744	tristate "Test floating point operations in kernel space"
2745	depends on X86 && !KCOV_INSTRUMENT_ALL
2746	help
2747	  Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu
2748	  which will trigger a sequence of floating point operations. This is used
2749	  for self-testing floating point control register setting in
2750	  kernel_fpu_begin().
2751
2752	  If unsure, say N.
2753
2754config TEST_CLOCKSOURCE_WATCHDOG
2755	tristate "Test clocksource watchdog in kernel space"
2756	depends on CLOCKSOURCE_WATCHDOG
2757	help
2758	  Enable this option to create a kernel module that will trigger
2759	  a test of the clocksource watchdog.  This module may be loaded
2760	  via modprobe or insmod in which case it will run upon being
2761	  loaded, or it may be built in, in which case it will run
2762	  shortly after boot.
2763
2764	  If unsure, say N.
2765
2766endif # RUNTIME_TESTING_MENU
2767
2768config ARCH_USE_MEMTEST
2769	bool
2770	help
2771	  An architecture should select this when it uses early_memtest()
2772	  during boot process.
2773
2774config MEMTEST
2775	bool "Memtest"
2776	depends on ARCH_USE_MEMTEST
2777	help
2778	  This option adds a kernel parameter 'memtest', which allows memtest
2779	  to be set and executed.
2780	        memtest=0, mean disabled; -- default
2781	        memtest=1, mean do 1 test pattern;
2782	        ...
2783	        memtest=17, mean do 17 test patterns.
2784	  If you are unsure how to answer this question, answer N.
2785
2786
2787
2788config HYPERV_TESTING
2789	bool "Microsoft Hyper-V driver testing"
2790	default n
2791	depends on HYPERV && DEBUG_FS
2792	help
2793	  Select this option to enable Hyper-V vmbus testing.
2794
2795endmenu # "Kernel Testing and Coverage"
2796
2797menu "Rust hacking"
2798
2799config RUST_DEBUG_ASSERTIONS
2800	bool "Debug assertions"
2801	depends on RUST
2802	help
2803	  Enables rustc's `-Cdebug-assertions` codegen option.
2804
2805	  This flag lets you turn `cfg(debug_assertions)` conditional
2806	  compilation on or off. This can be used to enable extra debugging
2807	  code in development but not in production. For example, it controls
2808	  the behavior of the standard library's `debug_assert!` macro.
2809
2810	  Note that this will apply to all Rust code, including `core`.
2811
2812	  If unsure, say N.
2813
2814config RUST_OVERFLOW_CHECKS
2815	bool "Overflow checks"
2816	default y
2817	depends on RUST
2818	help
2819	  Enables rustc's `-Coverflow-checks` codegen option.
2820
2821	  This flag allows you to control the behavior of runtime integer
2822	  overflow. When overflow-checks are enabled, a Rust panic will occur
2823	  on overflow.
2824
2825	  Note that this will apply to all Rust code, including `core`.
2826
2827	  If unsure, say Y.
2828
2829endmenu # "Rust"
2830
2831source "Documentation/Kconfig"
2832
2833endmenu # Kernel hacking
2834