hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/lib/Kconfig.debug
....@@ -1,3 +1,4 @@
1
+# SPDX-License-Identifier: GPL-2.0-only
12 menu "Kernel hacking"
23
34 menu "printk and dmesg options"
....@@ -19,14 +20,24 @@
1920
2021 config PRINTK_TIME_FROM_ARM_ARCH_TIMER
2122 bool "Timing from ARM architected timer"
22
- depends on PRINTK_TIME && ARM_ARCH_TIMER
23
+ depends on PRINTK_TIME && ARM_ARCH_TIMER && NO_GKI
2324
24
-config PRINTK_PROCESS
25
- bool "Show process information on printks"
25
+config PRINTK_CALLER
26
+ bool "Show caller information on printks"
2627 depends on PRINTK
2728 help
28
- Selecting this option causes process to be
29
- included in printk output. Or add printk.process=1 at boot-time.
29
+ Selecting this option causes printk() to add a caller "thread id" (if
30
+ in task context) or a caller "processor id" (if not in task context)
31
+ to every message.
32
+
33
+ This option is intended for environments where multiple threads
34
+ concurrently call printk() for many times, for it is difficult to
35
+ interpret without knowing where these lines (or sometimes individual
36
+ line which was divided into multiple lines due to race) came from.
37
+
38
+ Since toggling after boot makes the code racy, currently there is
39
+ no option to enable/disable at the kernel command line parameter or
40
+ sysfs interface.
3041
3142 config CONSOLE_LOGLEVEL_DEFAULT
3243 int "Default console loglevel (1-15)"
....@@ -92,6 +103,7 @@
92103 default n
93104 depends on PRINTK
94105 depends on (DEBUG_FS || PROC_FS)
106
+ select DYNAMIC_DEBUG_CORE
95107 help
96108
97109 Compiles debug level messages into the kernel, which would not
....@@ -122,8 +134,8 @@
122134 lineno : line number of the debug statement
123135 module : module that contains the debug statement
124136 function : function that contains the debug statement
125
- flags : '=p' means the line is turned 'on' for printing
126
- format : the format used for the debug statement
137
+ flags : '=p' means the line is turned 'on' for printing
138
+ format : the format used for the debug statement
127139
128140 From a live system:
129141
....@@ -158,6 +170,35 @@
158170 See Documentation/admin-guide/dynamic-debug-howto.rst for additional
159171 information.
160172
173
+config DYNAMIC_DEBUG_CORE
174
+ bool "Enable core function of dynamic debug support"
175
+ depends on PRINTK
176
+ depends on (DEBUG_FS || PROC_FS)
177
+ help
178
+ Enable core functional support of dynamic debug. It is useful
179
+ when you want to tie dynamic debug to your kernel modules with
180
+ DYNAMIC_DEBUG_MODULE defined for each of them, especially for
181
+ the case of embedded system where the kernel image size is
182
+ sensitive for people.
183
+
184
+config SYMBOLIC_ERRNAME
185
+ bool "Support symbolic error names in printf"
186
+ default y if PRINTK
187
+ help
188
+ If you say Y here, the kernel's printf implementation will
189
+ be able to print symbolic error names such as ENOSPC instead
190
+ of the number 28. It makes the kernel image slightly larger
191
+ (about 3KB), but can make the kernel logs easier to read.
192
+
193
+config DEBUG_BUGVERBOSE
194
+ bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
195
+ depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
196
+ default y
197
+ help
198
+ Say Y here to make BUG() panics output the file name and line number
199
+ of the BUG call as well as the EIP and oops trace. This aids
200
+ debugging but costs about 70-100K of memory.
201
+
161202 endmenu # "printk and dmesg options"
162203
163204 menu "Compile-time checks and compiler options"
....@@ -166,7 +207,7 @@
166207 bool "Compile the kernel with debug info"
167208 depends on DEBUG_KERNEL && !COMPILE_TEST
168209 help
169
- If you say Y here the resulting kernel image will include
210
+ If you say Y here the resulting kernel image will include
170211 debugging info resulting in a larger kernel image.
171212 This adds debug symbols to the kernel and modules (gcc -g), and
172213 is needed if you intend to use kernel crashdump or binary object
....@@ -175,9 +216,10 @@
175216
176217 If unsure, say N.
177218
219
+if DEBUG_INFO
220
+
178221 config DEBUG_INFO_REDUCED
179222 bool "Reduce debugging information"
180
- depends on DEBUG_INFO
181223 help
182224 If you say Y here gcc is instructed to generate less debugging
183225 information for structure types. This means that tools that
....@@ -188,9 +230,24 @@
188230 DEBUG_INFO build and compile times are reduced too.
189231 Only works with newer gcc versions.
190232
233
+config DEBUG_INFO_COMPRESSED
234
+ bool "Compressed debugging information"
235
+ depends on $(cc-option,-gz=zlib)
236
+ depends on $(ld-option,--compress-debug-sections=zlib)
237
+ help
238
+ Compress the debug information using zlib. Requires GCC 5.0+ or Clang
239
+ 5.0+, binutils 2.26+, and zlib.
240
+
241
+ Users of dpkg-deb via scripts/package/builddeb may find an increase in
242
+ size of their debug .deb packages with this config set, due to the
243
+ debug info being compressed with zlib, then the object files being
244
+ recompressed with a different compression scheme. But this is still
245
+ preferable to setting $KDEB_COMPRESS to "none" which would be even
246
+ larger.
247
+
191248 config DEBUG_INFO_SPLIT
192249 bool "Produce split debuginfo in .dwo files"
193
- depends on DEBUG_INFO
250
+ depends on $(cc-option,-gsplit-dwarf)
194251 help
195252 Generate debug info into separate .dwo files. This significantly
196253 reduces the build directory size for builds with DEBUG_INFO,
....@@ -205,16 +262,24 @@
205262
206263 config DEBUG_INFO_DWARF4
207264 bool "Generate dwarf4 debuginfo"
208
- depends on DEBUG_INFO
265
+ depends on $(cc-option,-gdwarf-4)
209266 help
210267 Generate dwarf4 debug info. This requires recent versions
211268 of gcc and gdb. It makes the debug information larger.
212269 But it significantly improves the success of resolving
213270 variables in gdb on optimized code.
214271
272
+config DEBUG_INFO_BTF
273
+ bool "Generate BTF typeinfo"
274
+ depends on !DEBUG_INFO_SPLIT && !DEBUG_INFO_REDUCED
275
+ depends on !GCC_PLUGIN_RANDSTRUCT || COMPILE_TEST
276
+ help
277
+ Generate deduplicated BTF type information from DWARF debug info.
278
+ Turning this on expects presence of pahole tool, which will convert
279
+ DWARF type info into equivalent deduplicated BTF type info.
280
+
215281 config GDB_SCRIPTS
216282 bool "Provide GDB scripts for kernel debugging"
217
- depends on DEBUG_INFO
218283 help
219284 This creates the required links to GDB helper scripts in the
220285 build directory. If you load vmlinux into gdb, the helper
....@@ -222,6 +287,8 @@
222287 additional functions are available to analyze a Linux kernel
223288 instance. See Documentation/dev-tools/gdb-kernel-debugging.rst
224289 for further details.
290
+
291
+endif # DEBUG_INFO
225292
226293 config ENABLE_MUST_CHECK
227294 bool "Enable __must_check logic"
....@@ -232,17 +299,18 @@
232299 attribute warn_unused_result" messages.
233300
234301 config FRAME_WARN
235
- int "Warn for stack frames larger than (needs gcc 4.4)"
302
+ int "Warn for stack frames larger than"
236303 range 0 8192
237304 default 2048 if GCC_PLUGIN_LATENT_ENTROPY
238
- default 1280 if (!64BIT && PARISC)
239
- default 1024 if (!64BIT && !PARISC)
305
+ default 2048 if PARISC
306
+ default 1536 if (!64BIT && XTENSA)
307
+ default 1280 if KASAN && !64BIT
308
+ default 1024 if !64BIT
240309 default 2048 if 64BIT
241310 help
242311 Tell gcc to warn at build time for stack frames larger than this.
243312 Setting this too low will cause a lot of warnings.
244313 Setting it to 0 disables the warning.
245
- Requires gcc 4.4
246314
247315 config STRIP_ASM_SYMS
248316 bool "Strip assembler-generated symbols during link"
....@@ -253,72 +321,23 @@
253321 get_wchan() and suchlike.
254322
255323 config READABLE_ASM
256
- bool "Generate readable assembler code"
257
- depends on DEBUG_KERNEL
258
- help
259
- Disable some compiler optimizations that tend to generate human unreadable
260
- assembler output. This may make the kernel slightly slower, but it helps
261
- to keep kernel developers who have to stare a lot at assembler listings
262
- sane.
263
-
264
-config UNUSED_SYMBOLS
265
- bool "Enable unused/obsolete exported symbols"
266
- default y if X86
324
+ bool "Generate readable assembler code"
325
+ depends on DEBUG_KERNEL
267326 help
268
- Unused but exported symbols make the kernel needlessly bigger. For
269
- that reason most of these unused exports will soon be removed. This
270
- option is provided temporarily to provide a transition period in case
271
- some external kernel module needs one of these symbols anyway. If you
272
- encounter such a case in your module, consider if you are actually
273
- using the right API. (rationale: since nobody in the kernel is using
274
- this in a module, there is a pretty good chance it's actually the
275
- wrong interface to use). If you really need the symbol, please send a
276
- mail to the linux kernel mailing list mentioning the symbol and why
277
- you really need it, and what the merge plan to the mainline kernel for
278
- your module is.
327
+ Disable some compiler optimizations that tend to generate human unreadable
328
+ assembler output. This may make the kernel slightly slower, but it helps
329
+ to keep kernel developers who have to stare a lot at assembler listings
330
+ sane.
279331
280
-config PAGE_OWNER
281
- bool "Track page owner"
282
- depends on DEBUG_KERNEL && STACKTRACE_SUPPORT
283
- select DEBUG_FS
284
- select STACKTRACE
285
- select STACKDEPOT
286
- select PAGE_EXTENSION
287
- help
288
- This keeps track of what call chain is the owner of a page, may
289
- help to find bare alloc_page(s) leaks. Even if you include this
290
- feature on your build, it is disabled in default. You should pass
291
- "page_owner=on" to boot parameter in order to enable it. Eats
292
- a fair amount of memory if enabled. See tools/vm/page_owner_sort.c
293
- for user-space helper.
294
-
295
- If unsure, say N.
296
-
297
-config DEBUG_FS
298
- bool "Debug Filesystem"
299
- help
300
- debugfs is a virtual file system that kernel developers use to put
301
- debugging files into. Enable this option to be able to read and
302
- write to these files.
303
-
304
- For detailed documentation on the debugfs API, see
305
- Documentation/filesystems/.
306
-
307
- If unsure, say N.
308
-
309
-config HEADERS_CHECK
310
- bool "Run 'make headers_check' when building vmlinux"
332
+config HEADERS_INSTALL
333
+ bool "Install uapi headers to usr/include"
311334 depends on !UML
312335 help
313
- This option will extract the user-visible kernel headers whenever
314
- building the kernel, and will run basic sanity checks on them to
315
- ensure that exported files do not attempt to include files which
316
- were not exported, etc.
317
-
318
- If you're making modifications to header files which are
319
- relevant for userspace, say 'Y', and check the headers
320
- exported to $(INSTALL_HDR_PATH) (usually 'usr/include' in
321
- your build tree), to make sure they're suitable.
336
+ This option will install uapi headers (headers exported to user-space)
337
+ into the usr/include directory for use during the kernel build.
338
+ This is unneeded for building the kernel itself, but needed for some
339
+ user-space program samples. It is also needed by some features such
340
+ as uapi header sanity checks.
322341
323342 config DEBUG_SECTION_MISMATCH
324343 bool "Enable full Section mismatch analysis"
....@@ -333,23 +352,13 @@
333352 which results in the code/data being placed in specific sections.
334353 The section mismatch analysis is always performed after a full
335354 kernel build, and enabling this option causes the following
336
- additional steps to occur:
355
+ additional step to occur:
337356 - Add the option -fno-inline-functions-called-once to gcc commands.
338357 When inlining a function annotated with __init in a non-init
339358 function, we would lose the section information and thus
340359 the analysis would not catch the illegal reference.
341360 This option tells gcc to inline less (but it does result in
342361 a larger kernel).
343
- - Run the section mismatch analysis for each module/built-in.a file.
344
- When we run the section mismatch analysis on vmlinux.o, we
345
- lose valuable information about where the mismatch was
346
- introduced.
347
- Running the analysis for each module/built-in.a file
348
- tells where the mismatch happens much closer to the
349
- source. The drawback is that the same mismatch is
350
- reported at least twice.
351
- - Enable verbose reporting from modpost in order to help resolve
352
- the section mismatches that are reported.
353362
354363 config SECTION_MISMATCH_WARN_ONLY
355364 bool "Make section mismatch errors non-fatal"
....@@ -359,6 +368,17 @@
359368 section mismatch, instead of just throwing warnings.
360369
361370 If unsure, say Y.
371
+
372
+config DEBUG_FORCE_FUNCTION_ALIGN_32B
373
+ bool "Force all function address 32B aligned" if EXPERT
374
+ help
375
+ There are cases that a commit from one domain changes the function
376
+ address alignment of other domains, and cause magic performance
377
+ bump (regression or improvement). Enable this option will help to
378
+ verify if the bump is caused by function alignment changes, while
379
+ it will slightly increase the kernel size and affect icache usage.
380
+
381
+ It is mainly for debug and performance tuning use.
362382
363383 #
364384 # Select this config option from the architecture Kconfig, if it
....@@ -392,6 +412,11 @@
392412 For more information, see
393413 tools/objtool/Documentation/stack-validation.txt.
394414
415
+config VMLINUX_VALIDATION
416
+ bool
417
+ depends on STACK_VALIDATION && DEBUG_ENTRY && !PARAVIRT
418
+ default y
419
+
395420 config DEBUG_FORCE_WEAK_PER_CPU
396421 bool "Force weak per-cpu definitions"
397422 depends on DEBUG_KERNEL
....@@ -408,6 +433,8 @@
408433 option forces all percpu variables to be defined as weak.
409434
410435 endmenu # "Compiler options"
436
+
437
+menu "Generic Kernel Debugging Instruments"
411438
412439 config MAGIC_SYSRQ
413440 bool "Magic SysRq key"
....@@ -442,15 +469,84 @@
442469 This option allows you to decide whether you want to enable the
443470 magic SysRq key.
444471
472
+config MAGIC_SYSRQ_SERIAL_SEQUENCE
473
+ string "Char sequence that enables magic SysRq over serial"
474
+ depends on MAGIC_SYSRQ_SERIAL
475
+ default ""
476
+ help
477
+ Specifies a sequence of characters that can follow BREAK to enable
478
+ SysRq on a serial console.
479
+
480
+ If unsure, leave an empty string and the option will not be enabled.
481
+
482
+config DEBUG_FS
483
+ bool "Debug Filesystem"
484
+ help
485
+ debugfs is a virtual file system that kernel developers use to put
486
+ debugging files into. Enable this option to be able to read and
487
+ write to these files.
488
+
489
+ For detailed documentation on the debugfs API, see
490
+ Documentation/filesystems/.
491
+
492
+ If unsure, say N.
493
+
494
+choice
495
+ prompt "Debugfs default access"
496
+ depends on DEBUG_FS
497
+ default DEBUG_FS_ALLOW_ALL
498
+ help
499
+ This selects the default access restrictions for debugfs.
500
+ It can be overridden with kernel command line option
501
+ debugfs=[on,no-mount,off]. The restrictions apply for API access
502
+ and filesystem registration.
503
+
504
+config DEBUG_FS_ALLOW_ALL
505
+ bool "Access normal"
506
+ help
507
+ No restrictions apply. Both API and filesystem registration
508
+ is on. This is the normal default operation.
509
+
510
+config DEBUG_FS_DISALLOW_MOUNT
511
+ bool "Do not register debugfs as filesystem"
512
+ help
513
+ The API is open but filesystem is not loaded. Clients can still do
514
+ their work and read with debug tools that do not need
515
+ debugfs filesystem.
516
+
517
+config DEBUG_FS_ALLOW_NONE
518
+ bool "No access"
519
+ help
520
+ Access is off. Clients get -PERM when trying to create nodes in
521
+ debugfs tree and debugfs is not registered as a filesystem.
522
+ Client can then back-off or continue without debugfs access.
523
+
524
+endchoice
525
+
526
+source "lib/Kconfig.kgdb"
527
+source "lib/Kconfig.ubsan"
528
+source "lib/Kconfig.kcsan"
529
+
530
+endmenu
531
+
445532 config DEBUG_KERNEL
446533 bool "Kernel debugging"
447534 help
448535 Say Y here if you are developing drivers or trying to debug and
449536 identify kernel problems.
450537
538
+config DEBUG_MISC
539
+ bool "Miscellaneous debug code"
540
+ default DEBUG_KERNEL
541
+ depends on DEBUG_KERNEL
542
+ help
543
+ Say Y here if you need to enable miscellaneous debug code that should
544
+ be under a more specific debug option but isn't.
545
+
546
+
451547 menu "Memory Debugging"
452548
453
-source mm/Kconfig.debug
549
+source "mm/Kconfig.debug"
454550
455551 config DEBUG_OBJECTS
456552 bool "Debug object operations"
....@@ -507,11 +603,11 @@
507603
508604 config DEBUG_OBJECTS_ENABLE_DEFAULT
509605 int "debug_objects bootup default value (0-1)"
510
- range 0 1
511
- default "1"
512
- depends on DEBUG_OBJECTS
513
- help
514
- Debug objects boot parameter default value
606
+ range 0 1
607
+ default "1"
608
+ depends on DEBUG_OBJECTS
609
+ help
610
+ Debug objects boot parameter default value
515611
516612 config DEBUG_SLAB
517613 bool "Debug slab memory allocations"
....@@ -520,10 +616,6 @@
520616 Say Y here to have the kernel do limited verification on memory
521617 allocation as well as poisoning memory on free to catch use of freed
522618 memory. This can make kmalloc/kfree-intensive workloads much slower.
523
-
524
-config DEBUG_SLAB_LEAK
525
- bool "Memory leak debugging"
526
- depends on DEBUG_SLAB
527619
528620 config SLUB_DEBUG_ON
529621 bool "SLUB debugging on by default"
....@@ -577,17 +669,18 @@
577669 In order to access the kmemleak file, debugfs needs to be
578670 mounted (usually at /sys/kernel/debug).
579671
580
-config DEBUG_KMEMLEAK_EARLY_LOG_SIZE
581
- int "Maximum kmemleak early log entries"
672
+config DEBUG_KMEMLEAK_MEM_POOL_SIZE
673
+ int "Kmemleak memory pool size"
582674 depends on DEBUG_KMEMLEAK
583
- range 200 40000
675
+ range 200 1000000
584676 default 16000
585677 help
586678 Kmemleak must track all the memory allocations to avoid
587679 reporting false positives. Since memory may be allocated or
588
- freed before kmemleak is initialised, an early log buffer is
589
- used to store these actions. If kmemleak reports "early log
590
- buffer exceeded", please increase this value.
680
+ freed before kmemleak is fully initialised, use a static pool
681
+ of metadata objects to track such callbacks. After kmemleak is
682
+ fully initialised, this memory pool acts as an emergency one
683
+ if slab allocations fail.
591684
592685 config DEBUG_KMEMLEAK_TEST
593686 tristate "Simple test for the kernel memory leak detector"
....@@ -604,6 +697,21 @@
604697 Say Y here to disable kmemleak by default. It can then be enabled
605698 on the command line via kmemleak=on.
606699
700
+config DEBUG_KMEMLEAK_AUTO_SCAN
701
+ bool "Enable kmemleak auto scan thread on boot up"
702
+ default y
703
+ depends on DEBUG_KMEMLEAK
704
+ help
705
+ Depending on the cpu, kmemleak scan may be cpu intensive and can
706
+ stall user tasks at times. This option enables/disables automatic
707
+ kmemleak scan at boot up.
708
+
709
+ Say N here to disable kmemleak auto scan thread to stop automatic
710
+ scanning. Disabling this option disables automatic reporting of
711
+ memory leaks.
712
+
713
+ If unsure, say Y.
714
+
607715 config DEBUG_STACK_USAGE
608716 bool "Stack utilization instrumentation"
609717 depends on DEBUG_KERNEL && !IA64
....@@ -613,12 +721,30 @@
613721
614722 This option will slow down process creation somewhat.
615723
724
+config SCHED_STACK_END_CHECK
725
+ bool "Detect stack corruption on calls to schedule()"
726
+ depends on DEBUG_KERNEL
727
+ default n
728
+ help
729
+ This option checks for a stack overrun on calls to schedule().
730
+ If the stack end location is found to be over written always panic as
731
+ the content of the corrupted region can no longer be trusted.
732
+ This is to ensure no erroneous behaviour occurs which could result in
733
+ data corruption or a sporadic crash at a later stage once the region
734
+ is examined. The runtime overhead introduced is minimal.
735
+
736
+config ARCH_HAS_DEBUG_VM_PGTABLE
737
+ bool
738
+ help
739
+ An architecture should select this when it can successfully
740
+ build and run DEBUG_VM_PGTABLE.
741
+
616742 config DEBUG_VM
617743 bool "Debug VM"
618744 depends on DEBUG_KERNEL
619745 help
620746 Enable this to turn on extended checks in the virtual-memory system
621
- that may impact performance.
747
+ that may impact performance.
622748
623749 If unsure, say N.
624750
....@@ -645,6 +771,22 @@
645771 depends on DEBUG_VM
646772 help
647773 Enables extra validation on page flags operations.
774
+
775
+ If unsure, say N.
776
+
777
+config DEBUG_VM_PGTABLE
778
+ bool "Debug arch page table for semantics compliance"
779
+ depends on MMU
780
+ depends on ARCH_HAS_DEBUG_VM_PGTABLE
781
+ default y if DEBUG_VM
782
+ help
783
+ This option provides a debug method which can be used to test
784
+ architecture page table helper functions on various platforms in
785
+ verifying if they comply with expected generic MM semantics. This
786
+ will help architecture code in making sure that any changes or
787
+ new additions of these helpers still conform to expected
788
+ semantics of the generic MM. Platforms will have to opt in for
789
+ this through ARCH_HAS_DEBUG_VM_PGTABLE.
648790
649791 If unsure, say N.
650792
....@@ -726,7 +868,7 @@
726868 config DEBUG_STACKOVERFLOW
727869 bool "Check for stack overflows"
728870 depends on DEBUG_KERNEL && HAVE_DEBUG_STACKOVERFLOW
729
- ---help---
871
+ help
730872 Say Y here if you want to check for overflows of kernel, IRQ
731873 and exception stacks (if your architecture uses them). This
732874 option will show detailed messages if free stack space drops
....@@ -742,66 +884,48 @@
742884 If in doubt, say "N".
743885
744886 source "lib/Kconfig.kasan"
887
+source "lib/Kconfig.kfence"
745888
746889 endmenu # "Memory Debugging"
747
-
748
-config ARCH_HAS_KCOV
749
- bool
750
- help
751
- An architecture should select this when it can successfully
752
- build and run with CONFIG_KCOV. This typically requires
753
- disabling instrumentation for some early boot code.
754
-
755
-config CC_HAS_SANCOV_TRACE_PC
756
- def_bool $(cc-option,-fsanitize-coverage=trace-pc)
757
-
758
-config KCOV
759
- bool "Code coverage for fuzzing"
760
- depends on ARCH_HAS_KCOV
761
- depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
762
- select DEBUG_FS
763
- select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
764
- help
765
- KCOV exposes kernel code coverage information in a form suitable
766
- for coverage-guided fuzzing (randomized testing).
767
-
768
- If RANDOMIZE_BASE is enabled, PC values will not be stable across
769
- different machines and across reboots. If you need stable PC values,
770
- disable RANDOMIZE_BASE.
771
-
772
- For more details, see Documentation/dev-tools/kcov.rst.
773
-
774
-config KCOV_ENABLE_COMPARISONS
775
- bool "Enable comparison operands collection by KCOV"
776
- depends on KCOV
777
- depends on $(cc-option,-fsanitize-coverage=trace-cmp)
778
- help
779
- KCOV also exposes operands of every comparison in the instrumented
780
- code along with operand sizes and PCs of the comparison instructions.
781
- These operands can be used by fuzzing engines to improve the quality
782
- of fuzzing coverage.
783
-
784
-config KCOV_INSTRUMENT_ALL
785
- bool "Instrument all code by default"
786
- depends on KCOV
787
- default y
788
- help
789
- If you are doing generic system call fuzzing (like e.g. syzkaller),
790
- then you will want to instrument the whole kernel and you should
791
- say y here. If you are doing more targeted fuzzing (like e.g.
792
- filesystem fuzzing with AFL) then you will want to enable coverage
793
- for more specific subsets of files, and should say n here.
794890
795891 config DEBUG_SHIRQ
796892 bool "Debug shared IRQ handlers"
797893 depends on DEBUG_KERNEL
798894 help
799
- Enable this to generate a spurious interrupt as soon as a shared
800
- interrupt handler is registered, and just before one is deregistered.
801
- Drivers ought to be able to handle interrupts coming in at those
802
- points; some don't and need to be caught.
895
+ Enable this to generate a spurious interrupt just before a shared
896
+ interrupt handler is deregistered (generating one when registering
897
+ is currently disabled). Drivers need to handle this correctly. Some
898
+ don't and need to be caught.
803899
804
-menu "Debug Lockups and Hangs"
900
+menu "Debug Oops, Lockups and Hangs"
901
+
902
+config PANIC_ON_OOPS
903
+ bool "Panic on Oops"
904
+ help
905
+ Say Y here to enable the kernel to panic when it oopses. This
906
+ has the same effect as setting oops=panic on the kernel command
907
+ line.
908
+
909
+ This feature is useful to ensure that the kernel does not do
910
+ anything erroneous after an oops which could result in data
911
+ corruption or other issues.
912
+
913
+ Say N if unsure.
914
+
915
+config PANIC_ON_OOPS_VALUE
916
+ int
917
+ range 0 1
918
+ default 0 if !PANIC_ON_OOPS
919
+ default 1 if PANIC_ON_OOPS
920
+
921
+config PANIC_TIMEOUT
922
+ int "panic timeout"
923
+ default 0
924
+ help
925
+ Set the timeout value (in seconds) until a reboot occurs when
926
+ the kernel panics. If n = 0, then we wait forever. A timeout
927
+ value n > 0 will wait n seconds before rebooting, while a timeout
928
+ value n < 0 will reboot immediately.
805929
806930 config LOCKUP_DETECTOR
807931 bool
....@@ -860,6 +984,7 @@
860984 #
861985 config HAVE_HARDLOCKUP_DETECTOR_OTHER_CPU
862986 def_bool y
987
+ depends on NO_GKI
863988 depends on SMP
864989 depends on !HAVE_HARDLOCKUP_DETECTOR_PERF && !HAVE_HARDLOCKUP_DETECTOR_ARCH
865990
....@@ -966,35 +1091,22 @@
9661091 state. This can be configured through kernel parameter
9671092 "workqueue.watchdog_thresh" and its sysfs counterpart.
9681093
1094
+config TEST_LOCKUP
1095
+ tristate "Test module to generate lockups"
1096
+ depends on m
1097
+ help
1098
+ This builds the "test_lockup" module that helps to make sure
1099
+ that watchdogs and lockup detectors are working properly.
1100
+
1101
+ Depending on module parameters it could emulate soft or hard
1102
+ lockup, "hung task", or locking arbitrary lock for a long time.
1103
+ Also it could generate series of lockups with cooling-down periods.
1104
+
1105
+ If unsure, say N.
1106
+
9691107 endmenu # "Debug lockups and hangs"
9701108
971
-config PANIC_ON_OOPS
972
- bool "Panic on Oops"
973
- help
974
- Say Y here to enable the kernel to panic when it oopses. This
975
- has the same effect as setting oops=panic on the kernel command
976
- line.
977
-
978
- This feature is useful to ensure that the kernel does not do
979
- anything erroneous after an oops which could result in data
980
- corruption or other issues.
981
-
982
- Say N if unsure.
983
-
984
-config PANIC_ON_OOPS_VALUE
985
- int
986
- range 0 1
987
- default 0 if !PANIC_ON_OOPS
988
- default 1 if PANIC_ON_OOPS
989
-
990
-config PANIC_TIMEOUT
991
- int "panic timeout"
992
- default 0
993
- help
994
- Set the timeout value (in seconds) until a reboot occurs when the
995
- the kernel panics. If n = 0, then we wait forever. A timeout
996
- value n > 0 will wait n seconds before rebooting, while a timeout
997
- value n < 0 will reboot immediately.
1109
+menu "Scheduler Debugging"
9981110
9991111 config SCHED_DEBUG
10001112 bool "Collect scheduler debugging info"
....@@ -1022,17 +1134,7 @@
10221134 application, you can say N to avoid the very slight overhead
10231135 this adds.
10241136
1025
-config SCHED_STACK_END_CHECK
1026
- bool "Detect stack corruption on calls to schedule()"
1027
- depends on DEBUG_KERNEL
1028
- default n
1029
- help
1030
- This option checks for a stack overrun on calls to schedule().
1031
- If the stack end location is found to be over written always panic as
1032
- the content of the corrupted region can no longer be trusted.
1033
- This is to ensure no erroneous behaviour occurs which could result in
1034
- data corruption or a sporadic crash at a later stage once the region
1035
- is examined. The runtime overhead introduced is minimal.
1137
+endmenu
10361138
10371139 config DEBUG_TIMEKEEPING
10381140 bool "Enable extra timekeeping sanity checking"
....@@ -1049,7 +1151,7 @@
10491151
10501152 config DEBUG_PREEMPT
10511153 bool "Debug preemptible kernel"
1052
- depends on DEBUG_KERNEL && PREEMPT && TRACE_IRQFLAGS_SUPPORT
1154
+ depends on DEBUG_KERNEL && PREEMPTION && TRACE_IRQFLAGS_SUPPORT
10531155 default y
10541156 help
10551157 If you say Y here then the kernel will use a debug variant of the
....@@ -1071,9 +1173,10 @@
10711173 select DEBUG_SPINLOCK
10721174 select DEBUG_MUTEXES
10731175 select DEBUG_RT_MUTEXES if RT_MUTEXES
1074
- select DEBUG_RWSEMS if RWSEM_SPIN_ON_OWNER
1176
+ select DEBUG_RWSEMS
10751177 select DEBUG_WW_MUTEX_SLOWPATH
10761178 select DEBUG_LOCK_ALLOC
1179
+ select PREEMPT_COUNT if !ARCH_NO_PREEMPT
10771180 select TRACE_IRQFLAGS
10781181 default n
10791182 help
....@@ -1108,7 +1211,24 @@
11081211 the proof of observed correctness is also maintained for an
11091212 arbitrary combination of these separate locking variants.
11101213
1111
- For more details, see Documentation/locking/lockdep-design.txt.
1214
+ For more details, see Documentation/locking/lockdep-design.rst.
1215
+
1216
+config PROVE_RAW_LOCK_NESTING
1217
+ bool "Enable raw_spinlock - spinlock nesting checks"
1218
+ depends on PROVE_LOCKING
1219
+ default n
1220
+ help
1221
+ Enable the raw_spinlock vs. spinlock nesting checks which ensure
1222
+ that the lock nesting rules for PREEMPT_RT enabled kernels are
1223
+ not violated.
1224
+
1225
+ NOTE: There are known nesting problems. So if you enable this
1226
+ option expect lockdep splats until these problems have been fully
1227
+ addressed which is work in progress. This config switch allows to
1228
+ identify and analyze these problems. It will be removed and the
1229
+ check permanentely enabled once the main issues have been fixed.
1230
+
1231
+ If unsure, select N.
11121232
11131233 config LOCK_STAT
11141234 bool "Lock usage statistics"
....@@ -1122,7 +1242,7 @@
11221242 help
11231243 This feature enables tracking lock contention points
11241244
1125
- For more details, see Documentation/locking/lockstat.txt
1245
+ For more details, see Documentation/locking/lockstat.rst
11261246
11271247 This also enables lock events required by "perf lock",
11281248 subcommand of perf.
....@@ -1175,10 +1295,10 @@
11751295
11761296 config DEBUG_RWSEMS
11771297 bool "RW Semaphore debugging: basic checks"
1178
- depends on DEBUG_KERNEL && RWSEM_SPIN_ON_OWNER
1298
+ depends on DEBUG_KERNEL
11791299 help
1180
- This debugging feature allows mismatched rw semaphore locks and unlocks
1181
- to be detected and reported.
1300
+ This debugging feature allows mismatched rw semaphore locks
1301
+ and unlocks to be detected and reported.
11821302
11831303 config DEBUG_LOCK_ALLOC
11841304 bool "Lock debugging: detect incorrect freeing of live locks"
....@@ -1199,12 +1319,51 @@
11991319 bool
12001320 depends on DEBUG_KERNEL && LOCK_DEBUGGING_SUPPORT
12011321 select STACKTRACE
1202
- select FRAME_POINTER if !MIPS && !PPC && !ARM_UNWIND && !S390 && !MICROBLAZE && !ARC && !X86
12031322 select KALLSYMS
12041323 select KALLSYMS_ALL
12051324
12061325 config LOCKDEP_SMALL
12071326 bool
1327
+
1328
+config LOCKDEP_BITS
1329
+ int "Bitsize for MAX_LOCKDEP_ENTRIES"
1330
+ depends on LOCKDEP && !LOCKDEP_SMALL
1331
+ range 10 30
1332
+ default 15
1333
+ help
1334
+ Try increasing this value if you hit "BUG: MAX_LOCKDEP_ENTRIES too low!" message.
1335
+
1336
+config LOCKDEP_CHAINS_BITS
1337
+ int "Bitsize for MAX_LOCKDEP_CHAINS"
1338
+ depends on LOCKDEP && !LOCKDEP_SMALL
1339
+ range 10 30
1340
+ default 16
1341
+ help
1342
+ Try increasing this value if you hit "BUG: MAX_LOCKDEP_CHAINS too low!" message.
1343
+
1344
+config LOCKDEP_STACK_TRACE_BITS
1345
+ int "Bitsize for MAX_STACK_TRACE_ENTRIES"
1346
+ depends on LOCKDEP && !LOCKDEP_SMALL
1347
+ range 10 30
1348
+ default 19
1349
+ help
1350
+ Try increasing this value if you hit "BUG: MAX_STACK_TRACE_ENTRIES too low!" message.
1351
+
1352
+config LOCKDEP_STACK_TRACE_HASH_BITS
1353
+ int "Bitsize for STACK_TRACE_HASH_SIZE"
1354
+ depends on LOCKDEP && !LOCKDEP_SMALL
1355
+ range 10 30
1356
+ default 14
1357
+ help
1358
+ Try increasing this value if you need large MAX_STACK_TRACE_ENTRIES.
1359
+
1360
+config LOCKDEP_CIRCULAR_QUEUE_BITS
1361
+ int "Bitsize for elements in circular_queue struct"
1362
+ depends on LOCKDEP
1363
+ range 10 30
1364
+ default 12
1365
+ help
1366
+ Try increasing this value if you hit "lockdep bfs error:-1" warning due to __cq_enqueue() failure.
12081367
12091368 config DEBUG_LOCKDEP
12101369 bool "Lock dependency engine debugging"
....@@ -1227,7 +1386,7 @@
12271386
12281387 config DEBUG_LOCKING_API_SELFTESTS
12291388 bool "Locking API boot-time self-tests"
1230
- depends on DEBUG_KERNEL && !PREEMPT_RT_FULL
1389
+ depends on DEBUG_KERNEL
12311390 help
12321391 Say Y here if you want the kernel to run a short self-test during
12331392 bootup. The self-test checks whether common types of locking bugs
....@@ -1262,13 +1421,40 @@
12621421 Say M if you want these self tests to build as a module.
12631422 Say N if you are unsure.
12641423
1424
+config SCF_TORTURE_TEST
1425
+ tristate "torture tests for smp_call_function*()"
1426
+ depends on DEBUG_KERNEL
1427
+ select TORTURE_TEST
1428
+ help
1429
+ This option provides a kernel module that runs torture tests
1430
+ on the smp_call_function() family of primitives. The kernel
1431
+ module may be built after the fact on the running kernel to
1432
+ be tested, if desired.
1433
+
1434
+config CSD_LOCK_WAIT_DEBUG
1435
+ bool "Debugging for csd_lock_wait(), called from smp_call_function*()"
1436
+ depends on DEBUG_KERNEL
1437
+ depends on 64BIT
1438
+ default n
1439
+ help
1440
+ This option enables debug prints when CPUs are slow to respond
1441
+ to the smp_call_function*() IPI wrappers. These debug prints
1442
+ include the IPI handler function currently executing (if any)
1443
+ and relevant stack traces.
1444
+
12651445 endmenu # lock debugging
12661446
12671447 config TRACE_IRQFLAGS
1448
+ depends on TRACE_IRQFLAGS_SUPPORT
12681449 bool
12691450 help
12701451 Enables hooks to interrupt enabling and disabling for
12711452 either tracing or lock debugging.
1453
+
1454
+config TRACE_IRQFLAGS_NMI
1455
+ def_bool y
1456
+ depends on TRACE_IRQFLAGS
1457
+ depends on TRACE_IRQFLAGS_NMI_SUPPORT
12721458
12731459 config STACKTRACE
12741460 bool "Stack backtrace support"
....@@ -1298,8 +1484,7 @@
12981484 so architecture maintainers really need to do what they can
12991485 to get the CRNG seeded sooner after the system is booted.
13001486 However, since users cannot do anything actionable to
1301
- address this, by default the kernel will issue only a single
1302
- warning for the first use of unseeded randomness.
1487
+ address this, by default this option is disabled.
13031488
13041489 Say Y here if you want to receive warnings for all uses of
13051490 unseeded randomness. This will be of use primarily for
....@@ -1312,7 +1497,7 @@
13121497 depends on DEBUG_KERNEL
13131498 help
13141499 If you say Y here, some extra kobject debugging messages will be sent
1315
- to the syslog.
1500
+ to the syslog.
13161501
13171502 config DEBUG_KOBJECT_RELEASE
13181503 bool "kobject release debugging"
....@@ -1336,14 +1521,7 @@
13361521 config HAVE_DEBUG_BUGVERBOSE
13371522 bool
13381523
1339
-config DEBUG_BUGVERBOSE
1340
- bool "Verbose BUG() reporting (adds 70K)" if DEBUG_KERNEL && EXPERT
1341
- depends on BUG && (GENERIC_BUG || HAVE_DEBUG_BUGVERBOSE)
1342
- default y
1343
- help
1344
- Say Y here to make BUG() panics output the file name and line number
1345
- of the BUG call as well as the EIP and oops trace. This aids
1346
- debugging but costs about 70-100K of memory.
1524
+menu "Debug kernel data structures"
13471525
13481526 config DEBUG_LIST
13491527 bool "Debug linked list manipulation"
....@@ -1354,7 +1532,7 @@
13541532
13551533 If unsure, say N.
13561534
1357
-config DEBUG_PI_LIST
1535
+config DEBUG_PLIST
13581536 bool "Debug priority linked list manipulation"
13591537 depends on DEBUG_KERNEL
13601538 help
....@@ -1383,6 +1561,18 @@
13831561 modules properly unregister themselves from notifier chains.
13841562 This is a relatively cheap check but if you care about maximum
13851563 performance, say N.
1564
+
1565
+config BUG_ON_DATA_CORRUPTION
1566
+ bool "Trigger a BUG when data corruption is detected"
1567
+ select DEBUG_LIST
1568
+ help
1569
+ Select this option if the kernel should BUG when it encounters
1570
+ data corruption in kernel memory structures when they get checked
1571
+ for validity.
1572
+
1573
+ If unsure, say N.
1574
+
1575
+endmenu
13861576
13871577 config DEBUG_CREDENTIALS
13881578 bool "Debug credential management"
....@@ -1417,7 +1607,7 @@
14171607 be impacted.
14181608
14191609 config DEBUG_BLOCK_EXT_DEVT
1420
- bool "Force extended block device numbers and spread them"
1610
+ bool "Force extended block device numbers and spread them"
14211611 depends on DEBUG_KERNEL
14221612 depends on BLOCK
14231613 default n
....@@ -1455,6 +1645,103 @@
14551645 restarted at arbitrary points yet.
14561646
14571647 Say N if your are unsure.
1648
+
1649
+config LATENCYTOP
1650
+ bool "Latency measuring infrastructure"
1651
+ depends on DEBUG_KERNEL
1652
+ depends on STACKTRACE_SUPPORT
1653
+ depends on PROC_FS
1654
+ depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
1655
+ select KALLSYMS
1656
+ select KALLSYMS_ALL
1657
+ select STACKTRACE
1658
+ select SCHEDSTATS
1659
+ select SCHED_DEBUG
1660
+ help
1661
+ Enable this option if you want to use the LatencyTOP tool
1662
+ to find out which userspace is blocking on what kernel operations.
1663
+
1664
+source "kernel/trace/Kconfig"
1665
+
1666
+config PROVIDE_OHCI1394_DMA_INIT
1667
+ bool "Remote debugging over FireWire early on boot"
1668
+ depends on PCI && X86
1669
+ help
1670
+ If you want to debug problems which hang or crash the kernel early
1671
+ on boot and the crashing machine has a FireWire port, you can use
1672
+ this feature to remotely access the memory of the crashed machine
1673
+ over FireWire. This employs remote DMA as part of the OHCI1394
1674
+ specification which is now the standard for FireWire controllers.
1675
+
1676
+ With remote DMA, you can monitor the printk buffer remotely using
1677
+ firescope and access all memory below 4GB using fireproxy from gdb.
1678
+ Even controlling a kernel debugger is possible using remote DMA.
1679
+
1680
+ Usage:
1681
+
1682
+ If ohci1394_dma=early is used as boot parameter, it will initialize
1683
+ all OHCI1394 controllers which are found in the PCI config space.
1684
+
1685
+ As all changes to the FireWire bus such as enabling and disabling
1686
+ devices cause a bus reset and thereby disable remote DMA for all
1687
+ devices, be sure to have the cable plugged and FireWire enabled on
1688
+ the debugging host before booting the debug target for debugging.
1689
+
1690
+ This code (~1k) is freed after boot. By then, the firewire stack
1691
+ in charge of the OHCI-1394 controllers should be used instead.
1692
+
1693
+ See Documentation/core-api/debugging-via-ohci1394.rst for more information.
1694
+
1695
+source "samples/Kconfig"
1696
+
1697
+config ARCH_HAS_DEVMEM_IS_ALLOWED
1698
+ bool
1699
+
1700
+config STRICT_DEVMEM
1701
+ bool "Filter access to /dev/mem"
1702
+ depends on MMU && DEVMEM
1703
+ depends on ARCH_HAS_DEVMEM_IS_ALLOWED
1704
+ default y if PPC || X86 || ARM64
1705
+ help
1706
+ If this option is disabled, you allow userspace (root) access to all
1707
+ of memory, including kernel and userspace memory. Accidental
1708
+ access to this is obviously disastrous, but specific access can
1709
+ be used by people debugging the kernel. Note that with PAT support
1710
+ enabled, even in this case there are restrictions on /dev/mem
1711
+ use due to the cache aliasing requirements.
1712
+
1713
+ If this option is switched on, and IO_STRICT_DEVMEM=n, the /dev/mem
1714
+ file only allows userspace access to PCI space and the BIOS code and
1715
+ data regions. This is sufficient for dosemu and X and all common
1716
+ users of /dev/mem.
1717
+
1718
+ If in doubt, say Y.
1719
+
1720
+config IO_STRICT_DEVMEM
1721
+ bool "Filter I/O access to /dev/mem"
1722
+ depends on STRICT_DEVMEM
1723
+ help
1724
+ If this option is disabled, you allow userspace (root) access to all
1725
+ io-memory regardless of whether a driver is actively using that
1726
+ range. Accidental access to this is obviously disastrous, but
1727
+ specific access can be used by people debugging kernel drivers.
1728
+
1729
+ If this option is switched on, the /dev/mem file only allows
1730
+ userspace access to *idle* io-memory ranges (see /proc/iomem) This
1731
+ may break traditional users of /dev/mem (dosemu, legacy X, etc...)
1732
+ if the driver using a given range cannot be disabled.
1733
+
1734
+ If in doubt, say Y.
1735
+
1736
+menu "$(SRCARCH) Debugging"
1737
+
1738
+source "arch/$(SRCARCH)/Kconfig.debug"
1739
+
1740
+endmenu
1741
+
1742
+menu "Kernel Testing and Coverage"
1743
+
1744
+source "lib/kunit/Kconfig"
14581745
14591746 config NOTIFIER_ERROR_INJECTION
14601747 tristate "Notifier error injection"
....@@ -1532,8 +1819,14 @@
15321819 If unsure, say N.
15331820
15341821 config FUNCTION_ERROR_INJECTION
1535
- def_bool y
1822
+ bool "Fault-injections of functions"
15361823 depends on HAVE_FUNCTION_ERROR_INJECTION && KPROBES
1824
+ help
1825
+ Add fault injections into various functions that are annotated with
1826
+ ALLOW_ERROR_INJECTION() in the kernel. BPF may also modify the return
1827
+ value of theses functions. This is useful to test error paths of code.
1828
+
1829
+ If unsure, say N
15371830
15381831 config FAULT_INJECTION
15391832 bool "Fault-injection framework"
....@@ -1550,10 +1843,17 @@
15501843 Provide fault-injection capability for kmalloc.
15511844
15521845 config FAIL_PAGE_ALLOC
1553
- bool "Fault-injection capabilitiy for alloc_pages()"
1846
+ bool "Fault-injection capability for alloc_pages()"
15541847 depends on FAULT_INJECTION
15551848 help
15561849 Provide fault-injection capability for alloc_pages().
1850
+
1851
+config FAULT_INJECTION_USERCOPY
1852
+ bool "Fault injection capability for usercopy functions"
1853
+ depends on FAULT_INJECTION
1854
+ help
1855
+ Provides fault-injection capability to inject failures
1856
+ in usercopy functions (copy_from_user(), get_user(), ...).
15571857
15581858 config FAIL_MAKE_REQUEST
15591859 bool "Fault-injection capability for disk IO"
....@@ -1610,91 +1910,67 @@
16101910 depends on FAULT_INJECTION_DEBUG_FS && STACKTRACE_SUPPORT
16111911 depends on !X86_64
16121912 select STACKTRACE
1613
- select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC && !X86
1913
+ depends on FRAME_POINTER || MIPS || PPC || S390 || MICROBLAZE || ARM || ARC || X86
16141914 help
16151915 Provide stacktrace filter for fault-injection capabilities
16161916
1617
-config LATENCYTOP
1618
- bool "Latency measuring infrastructure"
1619
- depends on DEBUG_KERNEL
1620
- depends on STACKTRACE_SUPPORT
1621
- depends on PROC_FS
1622
- select FRAME_POINTER if !MIPS && !PPC && !S390 && !MICROBLAZE && !ARM_UNWIND && !ARC && !X86
1623
- select KALLSYMS
1624
- select KALLSYMS_ALL
1625
- select STACKTRACE
1626
- select SCHEDSTATS
1627
- select SCHED_DEBUG
1917
+config ARCH_HAS_KCOV
1918
+ bool
16281919 help
1629
- Enable this option if you want to use the LatencyTOP tool
1630
- to find out which userspace is blocking on what kernel operations.
1920
+ An architecture should select this when it can successfully
1921
+ build and run with CONFIG_KCOV. This typically requires
1922
+ disabling instrumentation for some early boot code.
16311923
1632
-source kernel/trace/Kconfig
1924
+config CC_HAS_SANCOV_TRACE_PC
1925
+ def_bool $(cc-option,-fsanitize-coverage=trace-pc)
16331926
1634
-config PROVIDE_OHCI1394_DMA_INIT
1635
- bool "Remote debugging over FireWire early on boot"
1636
- depends on PCI && X86
1927
+
1928
+config KCOV
1929
+ bool "Code coverage for fuzzing"
1930
+ depends on ARCH_HAS_KCOV
1931
+ depends on CC_HAS_SANCOV_TRACE_PC || GCC_PLUGINS
1932
+ select DEBUG_FS
1933
+ select GCC_PLUGIN_SANCOV if !CC_HAS_SANCOV_TRACE_PC
1934
+ select SKB_EXTENSIONS if NET
16371935 help
1638
- If you want to debug problems which hang or crash the kernel early
1639
- on boot and the crashing machine has a FireWire port, you can use
1640
- this feature to remotely access the memory of the crashed machine
1641
- over FireWire. This employs remote DMA as part of the OHCI1394
1642
- specification which is now the standard for FireWire controllers.
1936
+ KCOV exposes kernel code coverage information in a form suitable
1937
+ for coverage-guided fuzzing (randomized testing).
16431938
1644
- With remote DMA, you can monitor the printk buffer remotely using
1645
- firescope and access all memory below 4GB using fireproxy from gdb.
1646
- Even controlling a kernel debugger is possible using remote DMA.
1939
+ If RANDOMIZE_BASE is enabled, PC values will not be stable across
1940
+ different machines and across reboots. If you need stable PC values,
1941
+ disable RANDOMIZE_BASE.
16471942
1648
- Usage:
1943
+ For more details, see Documentation/dev-tools/kcov.rst.
16491944
1650
- If ohci1394_dma=early is used as boot parameter, it will initialize
1651
- all OHCI1394 controllers which are found in the PCI config space.
1652
-
1653
- As all changes to the FireWire bus such as enabling and disabling
1654
- devices cause a bus reset and thereby disable remote DMA for all
1655
- devices, be sure to have the cable plugged and FireWire enabled on
1656
- the debugging host before booting the debug target for debugging.
1657
-
1658
- This code (~1k) is freed after boot. By then, the firewire stack
1659
- in charge of the OHCI-1394 controllers should be used instead.
1660
-
1661
- See Documentation/debugging-via-ohci1394.txt for more information.
1662
-
1663
-config DMA_API_DEBUG
1664
- bool "Enable debugging of DMA-API usage"
1665
- select NEED_DMA_MAP_STATE
1945
+config KCOV_ENABLE_COMPARISONS
1946
+ bool "Enable comparison operands collection by KCOV"
1947
+ depends on KCOV
1948
+ depends on $(cc-option,-fsanitize-coverage=trace-cmp)
16661949 help
1667
- Enable this option to debug the use of the DMA API by device drivers.
1668
- With this option you will be able to detect common bugs in device
1669
- drivers like double-freeing of DMA mappings or freeing mappings that
1670
- were never allocated.
1950
+ KCOV also exposes operands of every comparison in the instrumented
1951
+ code along with operand sizes and PCs of the comparison instructions.
1952
+ These operands can be used by fuzzing engines to improve the quality
1953
+ of fuzzing coverage.
16711954
1672
- This also attempts to catch cases where a page owned by DMA is
1673
- accessed by the cpu in a way that could cause data corruption. For
1674
- example, this enables cow_user_page() to check that the source page is
1675
- not undergoing DMA.
1676
-
1677
- This option causes a performance degradation. Use only if you want to
1678
- debug device drivers and dma interactions.
1679
-
1680
- If unsure, say N.
1681
-
1682
-config DMA_API_DEBUG_SG
1683
- bool "Debug DMA scatter-gather usage"
1955
+config KCOV_INSTRUMENT_ALL
1956
+ bool "Instrument all code by default"
1957
+ depends on KCOV
16841958 default y
1685
- depends on DMA_API_DEBUG
16861959 help
1687
- Perform extra checking that callers of dma_map_sg() have respected the
1688
- appropriate segment length/boundary limits for the given device when
1689
- preparing DMA scatterlists.
1960
+ If you are doing generic system call fuzzing (like e.g. syzkaller),
1961
+ then you will want to instrument the whole kernel and you should
1962
+ say y here. If you are doing more targeted fuzzing (like e.g.
1963
+ filesystem fuzzing with AFL) then you will want to enable coverage
1964
+ for more specific subsets of files, and should say n here.
16901965
1691
- This is particularly likely to have been overlooked in cases where the
1692
- dma_map_sg() API is used for general bulk mapping of pages rather than
1693
- preparing literal scatter-gather descriptors, where there is a risk of
1694
- unexpected behaviour from DMA API implementations if the scatterlist
1695
- is technically out-of-spec.
1696
-
1697
- If unsure, say N.
1966
+config KCOV_IRQ_AREA_SIZE
1967
+ hex "Size of interrupt coverage collection area in words"
1968
+ depends on KCOV
1969
+ default 0x40000
1970
+ help
1971
+ KCOV uses preallocated per-cpu areas to collect coverage from
1972
+ soft interrupts. This specifies the size of those areas in the
1973
+ number of unsigned long words.
16981974
16991975 menuconfig RUNTIME_TESTING_MENU
17001976 bool "Runtime Testing"
....@@ -1705,7 +1981,6 @@
17051981 config LKDTM
17061982 tristate "Linux Kernel Dump Test Tool Module"
17071983 depends on DEBUG_FS
1708
- depends on BLOCK
17091984 help
17101985 This module enables testing of the different dumping mechanisms by
17111986 inducing system failures at predefined crash points.
....@@ -1714,13 +1989,23 @@
17141989 called lkdtm.
17151990
17161991 Documentation on how to use the module can be found in
1717
- Documentation/fault-injection/provoke-crashes.txt
1992
+ Documentation/fault-injection/provoke-crashes.rst
17181993
17191994 config TEST_LIST_SORT
17201995 tristate "Linked list sorting test"
17211996 depends on DEBUG_KERNEL || m
17221997 help
17231998 Enable this to turn on 'list_sort()' function test. This test is
1999
+ executed only once during system boot (so affects only boot time),
2000
+ or at module load time.
2001
+
2002
+ If unsure, say N.
2003
+
2004
+config TEST_MIN_HEAP
2005
+ tristate "Min heap test"
2006
+ depends on DEBUG_KERNEL || m
2007
+ help
2008
+ Enable this to turn on min heap function tests. This test is
17242009 executed only once during system boot (so affects only boot time),
17252010 or at module load time.
17262011
....@@ -1767,6 +2052,18 @@
17672052 A benchmark measuring the performance of the rbtree library.
17682053 Also includes rbtree invariant checks.
17692054
2055
+config REED_SOLOMON_TEST
2056
+ tristate "Reed-Solomon library test"
2057
+ depends on DEBUG_KERNEL || m
2058
+ select REED_SOLOMON
2059
+ select REED_SOLOMON_ENC16
2060
+ select REED_SOLOMON_DEC16
2061
+ help
2062
+ This option enables the self-test function of rslib at boot,
2063
+ or at module load time.
2064
+
2065
+ If unsure, say N.
2066
+
17702067 config INTERVAL_TREE_TEST
17712068 tristate "Interval tree test"
17722069 depends on DEBUG_KERNEL
....@@ -1795,7 +2092,7 @@
17952092 tristate "Self test for hardware accelerated raid6 recovery"
17962093 depends on ASYNC_RAID6_RECOV
17972094 select ASYNC_MEMCPY
1798
- ---help---
2095
+ help
17992096 This is a one-shot self test that permutes through the
18002097 recovery of all the possible two disk failure scenarios for a
18012098 N-disk array. Recovery is performed with the asynchronous
....@@ -1810,6 +2107,9 @@
18102107 config TEST_STRING_HELPERS
18112108 tristate "Test functions located in the string_helpers module at runtime"
18122109
2110
+config TEST_STRSCPY
2111
+ tristate "Test strscpy*() family of functions at runtime"
2112
+
18132113 config TEST_KSTRTOX
18142114 tristate "Test kstrto*() family of functions at runtime"
18152115
....@@ -1823,15 +2123,11 @@
18232123
18242124 If unsure, say N.
18252125
1826
-config TEST_BITFIELD
1827
- tristate "Test bitfield functions at runtime"
1828
- help
1829
- Enable this option to test the bitfield functions at boot.
1830
-
1831
- If unsure, say N.
1832
-
18332126 config TEST_UUID
18342127 tristate "Test functions located in the uuid module at runtime"
2128
+
2129
+config TEST_XARRAY
2130
+ tristate "Test the XArray code at runtime"
18352131
18362132 config TEST_OVERFLOW
18372133 tristate "Test check_*_overflow() functions at runtime"
....@@ -1865,6 +2161,14 @@
18652161
18662162 If unsure, say N.
18672163
2164
+config TEST_IRQ_TIMINGS
2165
+ bool "IRQ timings selftest"
2166
+ depends on IRQ_TIMINGS
2167
+ help
2168
+ Enable this option to test the irq timings code on boot.
2169
+
2170
+ If unsure, say N.
2171
+
18682172 config TEST_LKM
18692173 tristate "Test module loading with 'hello world' module"
18702174 depends on m
....@@ -1875,6 +2179,32 @@
18752179 validating module verification). It lacks any extra dependencies,
18762180 and will not normally be loaded by the system unless explicitly
18772181 requested by name.
2182
+
2183
+ If unsure, say N.
2184
+
2185
+config TEST_BITOPS
2186
+ tristate "Test module for compilation of bitops operations"
2187
+ depends on m
2188
+ help
2189
+ This builds the "test_bitops" module that is much like the
2190
+ TEST_LKM module except that it does a basic exercise of the
2191
+ set/clear_bit macros and get_count_order/long to make sure there are
2192
+ no compiler warnings from C=1 sparse checker or -Wextra
2193
+ compilations. It has no dependencies and doesn't run or load unless
2194
+ explicitly requested by name. for example: modprobe test_bitops.
2195
+
2196
+ If unsure, say N.
2197
+
2198
+config TEST_VMALLOC
2199
+ tristate "Test module for stress/performance analysis of vmalloc allocator"
2200
+ default n
2201
+ depends on MMU
2202
+ depends on m
2203
+ help
2204
+ This builds the "test_vmalloc" module that should be used for
2205
+ stress and performance analysis. So, any new change for vmalloc
2206
+ subsystem can be evaluated from performance and stability point
2207
+ of view.
18782208
18792209 If unsure, say N.
18802210
....@@ -1900,6 +2230,15 @@
19002230 development, but also to run regression tests against changes in
19012231 the interpreter code. It also enables test stubs for eBPF maps and
19022232 verifier used by user space verifier testsuite.
2233
+
2234
+ If unsure, say N.
2235
+
2236
+config TEST_BLACKHOLE_DEV
2237
+ tristate "Test blackhole netdev functionality"
2238
+ depends on m && NET
2239
+ help
2240
+ This builds the "test_blackhole_dev" module that validates the
2241
+ data path through this blackhole netdev.
19032242
19042243 If unsure, say N.
19052244
....@@ -1933,6 +2272,76 @@
19332272
19342273 If unsure, say N.
19352274
2275
+config BITFIELD_KUNIT
2276
+ tristate "KUnit test bitfield functions at runtime"
2277
+ depends on KUNIT
2278
+ help
2279
+ Enable this option to test the bitfield functions at boot.
2280
+
2281
+ KUnit tests run during boot and output the results to the debug log
2282
+ in TAP format (http://testanything.org/). Only useful for kernel devs
2283
+ running the KUnit test harness, and not intended for inclusion into a
2284
+ production build.
2285
+
2286
+ For more information on KUnit and unit tests in general please refer
2287
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
2288
+
2289
+ If unsure, say N.
2290
+
2291
+config SYSCTL_KUNIT_TEST
2292
+ tristate "KUnit test for sysctl" if !KUNIT_ALL_TESTS
2293
+ depends on KUNIT
2294
+ default KUNIT_ALL_TESTS
2295
+ help
2296
+ This builds the proc sysctl unit test, which runs on boot.
2297
+ Tests the API contract and implementation correctness of sysctl.
2298
+ For more information on KUnit and unit tests in general please refer
2299
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
2300
+
2301
+ If unsure, say N.
2302
+
2303
+config LIST_KUNIT_TEST
2304
+ tristate "KUnit Test for Kernel Linked-list structures" if !KUNIT_ALL_TESTS
2305
+ depends on KUNIT
2306
+ default KUNIT_ALL_TESTS
2307
+ help
2308
+ This builds the linked list KUnit test suite.
2309
+ It tests that the API and basic functionality of the list_head type
2310
+ and associated macros.
2311
+
2312
+ KUnit tests run during boot and output the results to the debug log
2313
+ in TAP format (https://testanything.org/). Only useful for kernel devs
2314
+ running the KUnit test harness, and not intended for inclusion into a
2315
+ production build.
2316
+
2317
+ For more information on KUnit and unit tests in general please refer
2318
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
2319
+
2320
+ If unsure, say N.
2321
+
2322
+config LINEAR_RANGES_TEST
2323
+ tristate "KUnit test for linear_ranges"
2324
+ depends on KUNIT
2325
+ select LINEAR_RANGES
2326
+ help
2327
+ This builds the linear_ranges unit test, which runs on boot.
2328
+ Tests the linear_ranges logic correctness.
2329
+ For more information on KUnit and unit tests in general please refer
2330
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
2331
+
2332
+ If unsure, say N.
2333
+
2334
+config BITS_TEST
2335
+ tristate "KUnit test for bits.h"
2336
+ depends on KUNIT
2337
+ help
2338
+ This builds the bits unit test.
2339
+ Tests the logic of macros defined in bits.h.
2340
+ For more information on KUnit and unit tests in general please refer
2341
+ to the KUnit documentation in Documentation/dev-tools/kunit/.
2342
+
2343
+ If unsure, say N.
2344
+
19362345 config TEST_UDELAY
19372346 tristate "udelay test driver"
19382347 help
....@@ -1952,7 +2361,6 @@
19522361 config TEST_KMOD
19532362 tristate "kmod stress tester"
19542363 depends on m
1955
- depends on BLOCK && (64BIT || LBDAF) # for XFS, BTRFS
19562364 depends on NETDEVICES && NET_CORE && INET # for TUN
19572365 depends on BLOCK
19582366 select TEST_LKM
....@@ -1986,13 +2394,44 @@
19862394
19872395 If unsure, say N.
19882396
1989
-config TEST_MEMINIT
1990
- tristate "Test heap/page initialization"
2397
+config TEST_MEMCAT_P
2398
+ tristate "Test memcat_p() helper function"
19912399 help
1992
- Test if the kernel is zero-initializing heap and page allocations.
1993
- This can be useful to test init_on_alloc and init_on_free features.
2400
+ Test the memcat_p() helper for correctly merging two
2401
+ pointer arrays together.
19942402
19952403 If unsure, say N.
2404
+
2405
+config TEST_LIVEPATCH
2406
+ tristate "Test livepatching"
2407
+ default n
2408
+ depends on DYNAMIC_DEBUG
2409
+ depends on LIVEPATCH
2410
+ depends on m
2411
+ help
2412
+ Test kernel livepatching features for correctness. The tests will
2413
+ load test modules that will be livepatched in various scenarios.
2414
+
2415
+ To run all the livepatching tests:
2416
+
2417
+ make -C tools/testing/selftests TARGETS=livepatch run_tests
2418
+
2419
+ Alternatively, individual tests may be invoked:
2420
+
2421
+ tools/testing/selftests/livepatch/test-callbacks.sh
2422
+ tools/testing/selftests/livepatch/test-livepatch.sh
2423
+ tools/testing/selftests/livepatch/test-shadow-vars.sh
2424
+
2425
+ If unsure, say N.
2426
+
2427
+config TEST_OBJAGG
2428
+ tristate "Perform selftest on object aggreration manager"
2429
+ default n
2430
+ depends on OBJAGG
2431
+ help
2432
+ Enable this option to test object aggregation manager on boot
2433
+ (or module load).
2434
+
19962435
19972436 config TEST_STACKINIT
19982437 tristate "Test level of stack variable initialization"
....@@ -2004,12 +2443,52 @@
20042443
20052444 If unsure, say N.
20062445
2446
+config TEST_MEMINIT
2447
+ tristate "Test heap/page initialization"
2448
+ help
2449
+ Test if the kernel is zero-initializing heap and page allocations.
2450
+ This can be useful to test init_on_alloc and init_on_free features.
2451
+
2452
+ If unsure, say N.
2453
+
2454
+config TEST_HMM
2455
+ tristate "Test HMM (Heterogeneous Memory Management)"
2456
+ depends on TRANSPARENT_HUGEPAGE
2457
+ depends on DEVICE_PRIVATE
2458
+ select HMM_MIRROR
2459
+ select MMU_NOTIFIER
2460
+ help
2461
+ This is a pseudo device driver solely for testing HMM.
2462
+ Say M here if you want to build the HMM test module.
2463
+ Doing so will allow you to run tools/testing/selftest/vm/hmm-tests.
2464
+
2465
+ If unsure, say N.
2466
+
2467
+config TEST_FREE_PAGES
2468
+ tristate "Test freeing pages"
2469
+ help
2470
+ Test that a memory leak does not occur due to a race between
2471
+ freeing a block of pages and a speculative page reference.
2472
+ Loading this module is safe if your kernel has the bug fixed.
2473
+ If the bug is not fixed, it will leak gigabytes of memory and
2474
+ probably OOM your system.
2475
+
2476
+config TEST_FPU
2477
+ tristate "Test floating point operations in kernel space"
2478
+ depends on X86 && !KCOV_INSTRUMENT_ALL
2479
+ help
2480
+ Enable this option to add /sys/kernel/debug/selftest_helpers/test_fpu
2481
+ which will trigger a sequence of floating point operations. This is used
2482
+ for self-testing floating point control register setting in
2483
+ kernel_fpu_begin().
2484
+
2485
+ If unsure, say N.
2486
+
20072487 endif # RUNTIME_TESTING_MENU
20082488
20092489 config MEMTEST
20102490 bool "Memtest"
2011
- depends on HAVE_MEMBLOCK
2012
- ---help---
2491
+ help
20132492 This option adds a kernel parameter 'memtest', which allows memtest
20142493 to be set.
20152494 memtest=0, mean disabled; -- default
....@@ -2018,61 +2497,17 @@
20182497 memtest=17, mean do 17 test patterns.
20192498 If you are unsure how to answer this question, answer N.
20202499
2021
-config BUG_ON_DATA_CORRUPTION
2022
- bool "Trigger a BUG when data corruption is detected"
2023
- select DEBUG_LIST
2500
+
2501
+
2502
+config HYPERV_TESTING
2503
+ bool "Microsoft Hyper-V driver testing"
2504
+ default n
2505
+ depends on HYPERV && DEBUG_FS
20242506 help
2025
- Select this option if the kernel should BUG when it encounters
2026
- data corruption in kernel memory structures when they get checked
2027
- for validity.
2507
+ Select this option to enable Hyper-V vmbus testing.
20282508
2029
- If unsure, say N.
2509
+endmenu # "Kernel Testing and Coverage"
20302510
2031
-source "samples/Kconfig"
2032
-
2033
-source "lib/Kconfig.kgdb"
2034
-
2035
-source "lib/Kconfig.ubsan"
2036
-
2037
-config ARCH_HAS_DEVMEM_IS_ALLOWED
2038
- bool
2039
-
2040
-config STRICT_DEVMEM
2041
- bool "Filter access to /dev/mem"
2042
- depends on MMU && DEVMEM
2043
- depends on ARCH_HAS_DEVMEM_IS_ALLOWED
2044
- default y if PPC || X86 || ARM64
2045
- ---help---
2046
- If this option is disabled, you allow userspace (root) access to all
2047
- of memory, including kernel and userspace memory. Accidental
2048
- access to this is obviously disastrous, but specific access can
2049
- be used by people debugging the kernel. Note that with PAT support
2050
- enabled, even in this case there are restrictions on /dev/mem
2051
- use due to the cache aliasing requirements.
2052
-
2053
- If this option is switched on, and IO_STRICT_DEVMEM=n, the /dev/mem
2054
- file only allows userspace access to PCI space and the BIOS code and
2055
- data regions. This is sufficient for dosemu and X and all common
2056
- users of /dev/mem.
2057
-
2058
- If in doubt, say Y.
2059
-
2060
-config IO_STRICT_DEVMEM
2061
- bool "Filter I/O access to /dev/mem"
2062
- depends on STRICT_DEVMEM
2063
- ---help---
2064
- If this option is disabled, you allow userspace (root) access to all
2065
- io-memory regardless of whether a driver is actively using that
2066
- range. Accidental access to this is obviously disastrous, but
2067
- specific access can be used by people debugging kernel drivers.
2068
-
2069
- If this option is switched on, the /dev/mem file only allows
2070
- userspace access to *idle* io-memory ranges (see /proc/iomem) This
2071
- may break traditional users of /dev/mem (dosemu, legacy X, etc...)
2072
- if the driver using a given range cannot be disabled.
2073
-
2074
- If in doubt, say Y.
2075
-
2076
-source "arch/$(SRCARCH)/Kconfig.debug"
2511
+source "Documentation/Kconfig"
20772512
20782513 endmenu # Kernel hacking