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