^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) # SPDX-License-Identifier: GPL-2.0-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) config HAVE_ARCH_KGDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) # set if architecture has the its kgdb_arch_handle_qxfer_pkt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) # function to enable gdb stub to address XML packet sent from GDB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) config HAVE_ARCH_KGDB_QXFER_PKT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) menuconfig KGDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) bool "KGDB: kernel debugger"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) depends on HAVE_ARCH_KGDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) depends on DEBUG_KERNEL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) If you say Y here, it will be possible to remotely debug the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) kernel using gdb. It is recommended but not required, that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) you also turn on the kernel config option
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) CONFIG_FRAME_POINTER to aid in producing more reliable stack
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) backtraces in the external debugger. Documentation of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) kernel debugger is available at http://kgdb.sourceforge.net
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) as well as in Documentation/dev-tools/kgdb.rst. If
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) unsure, say N.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) if KGDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) config KGDB_HONOUR_BLOCKLIST
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) bool "KGDB: use kprobe blocklist to prohibit unsafe breakpoints"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) depends on HAVE_KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) depends on MODULES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) select KPROBES
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) default y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) If set to Y the debug core will use the kprobe blocklist to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) identify symbols where it is unsafe to set breakpoints.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) In particular this disallows instrumentation of functions
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) called during debug trap handling and thus makes it very
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) difficult to inadvertently provoke recursive trap handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) If unsure, say Y.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) config KGDB_SERIAL_CONSOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) tristate "KGDB: use kgdb over the serial console"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) select CONSOLE_POLL
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) select MAGIC_SYSRQ
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) depends on TTY && HW_CONSOLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) default y
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) Share a serial console with kgdb. Sysrq-g must be used
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) to break in initially.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) config KGDB_TESTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) bool "KGDB: internal test suite"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) This is a kgdb I/O module specifically designed to test
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) kgdb's internal functions. This kgdb I/O module is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) intended to for the development of new kgdb stubs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) as well as regression testing the kgdb internals.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) See the drivers/misc/kgdbts.c for the details about
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) the tests. The most basic of this I/O module is to boot
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) a kernel boot arguments "kgdbwait kgdbts=V1F100"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) config KGDB_TESTS_ON_BOOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) bool "KGDB: Run tests on boot"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) depends on KGDB_TESTS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) Run the kgdb tests on boot up automatically without the need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) to pass in a kernel parameter
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) config KGDB_TESTS_BOOT_STRING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) string "KGDB: which internal kgdb tests to run"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) depends on KGDB_TESTS_ON_BOOT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) default "V1F100"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) This is the command string to send the kgdb test suite on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) boot. See the drivers/misc/kgdbts.c for detailed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) information about other strings you could use beyond the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) default of V1F100.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) config KGDB_LOW_LEVEL_TRAP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) bool "KGDB: Allow debugging with traps in notifiers"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) depends on X86 || MIPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) This will add an extra call back to kgdb for the breakpoint
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) exception handler which will allow kgdb to step through a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) notify handler.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) config KGDB_KDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) bool "KGDB_KDB: include kdb frontend for kgdb"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) KDB frontend for kernel
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) config KDB_DEFAULT_ENABLE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) hex "KDB: Select kdb command functions to be enabled by default"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) depends on KGDB_KDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) default 0x1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) Specifiers which kdb commands are enabled by default. This may
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) be set to 1 or 0 to enable all commands or disable almost all
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) commands.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) Alternatively the following bitmask applies:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 0x0002 - allow arbitrary reads from memory and symbol lookup
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 0x0004 - allow arbitrary writes to memory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 0x0008 - allow current register state to be inspected
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 0x0010 - allow current register state to be modified
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 0x0020 - allow passive inspection (backtrace, process list, lsmod)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 0x0040 - allow flow control management (breakpoint, single step)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 0x0080 - enable signalling of processes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 0x0100 - allow machine to be rebooted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) The config option merely sets the default at boot time. Both
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) issuing 'echo X > /sys/module/kdb/parameters/cmd_enable' or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) setting with kdb.cmd_enable=X kernel command line option will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) override the default settings.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) config KDB_KEYBOARD
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) bool "KGDB_KDB: keyboard as input device"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) depends on VT && KGDB_KDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) KDB can use a PS/2 type keyboard for an input device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) config KDB_CONTINUE_CATASTROPHIC
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) int "KDB: continue after catastrophic errors"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) depends on KGDB_KDB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) default "0"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) This integer controls the behaviour of kdb when the kernel gets a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) catastrophic error, i.e. for a panic or oops.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) When KDB is active and a catastrophic error occurs, nothing extra
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) will happen until you type 'go'.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) CONFIG_KDB_CONTINUE_CATASTROPHIC == 0 (default). The first time
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) you type 'go', you will be warned by kdb. The secend time you type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 'go', KDB tries to continue. No guarantees that the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) kernel is still usable in this situation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) CONFIG_KDB_CONTINUE_CATASTROPHIC == 1. KDB tries to continue.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) No guarantees that the kernel is still usable in this situation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) CONFIG_KDB_CONTINUE_CATASTROPHIC == 2. KDB forces a reboot.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) If you are not sure, say 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) config ARCH_HAS_EARLY_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) default n
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) help
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) If an architecture can definitely handle entering the debugger
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) when early_param's are parsed then it select this config.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) Otherwise, if "kgdbwait" is passed on the kernel command line it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) won't actually be processed until dbg_late_init() just after the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) call to kgdb_arch_late() is made.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) NOTE: Even if this isn't selected by an architecture we will
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) still try to register kgdb to handle breakpoints and crashes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) when early_param's are parsed, we just won't act on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) "kgdbwait" parameter until dbg_late_init(). If you get a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) crash and try to drop into kgdb somewhere between these two
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) places you might or might not end up being able to use kgdb
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) depending on exactly how far along the architecture has initted.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) endif # KGDB