Remove gdbstub and debugger infrastructure
cover Remove gdbstub and debugger infrastructure
See patches for details. This is to help the efforts to clean up the IRQ infrastructure.
Andrew Cooper (2):
x86: Remove gdbstub
xen: Remove debugger.h
CHANGELOG.md | 1 + docs/misc/xen-command-line.pandoc | 7 - xen/Kconfig.debug | 7 - xen/arch/x86/Makefile | 1 - xen/arch/x86/gdbstub.c | 91 ---- xen/arch/x86/include/asm/bug.h | 20 - xen/arch/x86/include/asm/debugger.h | 30 -- xen/arch/x86/traps.c | 30 +- xen/arch/x86/x86_64/Makefile | 2 - xen/arch/x86/x86_64/gdbstub.c | 150 ------ xen/common/Makefile | 1 - xen/common/bug.c | 27 - xen/common/gdbstub.c | 748 ---------------------------- xen/common/keyhandler.c | 22 +- xen/common/shutdown.c | 2 - xen/drivers/char/console.c | 3 - xen/include/xen/bug.h | 4 - xen/include/xen/debugger.h | 44 -- xen/include/xen/gdbstub.h | 103 ---- 19 files changed, 6 insertions(+), 1287 deletions(-) delete mode 100644 xen/arch/x86/gdbstub.c delete mode 100644 xen/arch/x86/include/asm/debugger.h delete mode 100644 xen/arch/x86/x86_64/gdbstub.c delete mode 100644 xen/common/gdbstub.c delete mode 100644 xen/include/xen/debugger.h delete mode 100644 xen/include/xen/gdbstub.h
base-commit: c378ff8983cd69786c35117e49640f027e581bca
Signature · 1 line
2.30.2
PATCH 1/2 x86: Remove gdbstub
In 13y of working on Xen, I've never seen seen it used. The implementation was introduced (commit b69f92f3012e, Jul 28 2004) with known issues such as:
/* Resuming after we've stopped used to work, but more through luck
than any actual intention. It doesn't at the moment. */
which appear to have gone unfixed for the 20 years since.
Nowadays there are more robust ways of inspecting crashed state, such as a kexec crash kernel, or running Xen in a VM.
This will allow us to clean up some hooks around the codebase which are proving awkward for other tasks.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Oleksii Kurochko <[email protected]>
Bloat-o-meter really likes this change.
add/remove: 1/31 grow/shrink: 2/15 up/down: 113/-17033 (-16920)
Function old new delta hwdom_shutdown 101 176 +75 do_int3.cold - 27 +27 do_bug_frame 566 577 +11 panic.cold 98 97 -1 gdb_arch_print_state 1 - -1 gdb_arch_exit 1 - -1 gdb_arch_enter 1 - -1 do_page_fault.cold 55 53 -2 gdb_smp_paused_count 4 - -4 __setup_str_opt_gdb 4 - -4 gdb_arch_copy_to_user 5 - -5 gdb_arch_copy_from_user 5 - -5 gdb_arch_signal_num 6 - -6 xen_config_data 1280 1273 -7 __initcall_initialise_gdb 8 - -8 do_debugger_trap_fatal 15 5 -10 do_debug_key 48 35 -13 gdb_arch_write_reg_array 15 - -15 gdb_send_packet.cold 16 - -16 do_debug 457 441 -16 do_trap 213 194 -19 do_int3 251 230 -21 do_invalid_op 331 307 -24 __setup_opt_gdb 24 - -24 opt_gdb 30 - -30 do_unhandled_trap 38 7 -31 cpumask_first.constprop 138 104 -34 cpumask_next.constprop 174 129 -45 gdb_arch_resume 52 - -52 char2hex 58 - -58 do_page_fault 1820 1752 -68 gdb_write_to_packet 69 - -69 do_general_protection 542 471 -71 initialise_gdb 81 - -81 gdb_write_to_packet_str 86 - -86 do_bug_frame.cold 131 39 -92 gdb_send_reply 110 - -110 hwdom_shutdown.cold 140 - -140 gdb_pause_this_cpu 159 - -159 gdb_write_to_packet_hex 200 - -200 gdb_send_packet 216 - -216 gdbstub_console_puts 220 - -220 __trap_to_gdb.cold 313 - -313 gdb_arch_read_reg_array 451 - -451 gdb_arch_write_reg 585 - -585 gdb_arch_read_reg 883 - -883 gdb_cpu 2048 - -2048 __trap_to_gdb 2540 - -2540 __gdb_ctx 8248 - -8248 Total: Before=4081568, After=4064648, chg -0.41% --- CHANGELOG.md | 1 + docs/misc/xen-command-line.pandoc | 7 - xen/Kconfig.debug | 7 - xen/arch/x86/Makefile | 1 - xen/arch/x86/gdbstub.c | 91 ---- xen/arch/x86/x86_64/Makefile | 2 - xen/arch/x86/x86_64/gdbstub.c | 150 ------ xen/common/Makefile | 1 - xen/common/gdbstub.c | 748 ------------------------------ xen/include/xen/gdbstub.h | 103 ---- 10 files changed, 1 insertion(+), 1110 deletions(-) delete mode 100644 xen/arch/x86/gdbstub.c delete mode 100644 xen/arch/x86/x86_64/gdbstub.c delete mode 100644 xen/common/gdbstub.c delete mode 100644 xen/include/xen/gdbstub.h
CHANGELOG.md +1 -0
@@ -23,6 +23,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - /usr/bin/pygrub symlink. This was deprecated in Xen 4.2 (2012) but left for compatibility reasons. VMs configured with bootloader="/usr/bin/pygrub" should be updated to just bootloader="pygrub". +- The Xen gdbstub on x86. ## [4.18.0](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.18.0) - 2023-11-16
docs/misc/xen-command-line.pandoc +0 -7
@@ -1242,13 +1242,6 @@ requirement can be relaxed. This option is particularly useful for nested virtualization, to allow the L1 hypervisor to use EPT even if the L0 hypervisor does not provide `VM_ENTRY_LOAD_GUEST_PAT`. -### gdb -> `= com1[H,L] | com2[H,L] | dbgp` - -> Default: `` - -Specify which console gdbstub should use. See **console**. - ### gnttab > `= List of [ max-ver:<integer>, transitive=<bool>, transfer=<bool> ]`
xen/Kconfig.debug +0 -7
@@ -13,13 +13,6 @@ config DEBUG if DEBUG || EXPERT -config CRASH_DEBUG - bool "Crash Debugging Support" - depends on X86 - ---help--- - If you want to attach gdb to Xen to debug Xen if it crashes - then say Y. - config GDBSX bool "Guest debugging with gdbsx" depends on X86
xen/arch/x86/Makefile +0 -1
@@ -35,7 +35,6 @@ obj-y += e820.o obj-y += emul-i8254.o obj-y += extable.o obj-y += flushtlb.o -obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o obj-$(CONFIG_GDBSX) += gdbsx.o obj-y += hypercall.o obj-y += i387.o
xen/arch/x86/gdbstub.c deleted +0 -91
91 lines not on this page · raw message
xen/arch/x86/x86_64/Makefile +0 -2
@@ -12,5 +12,3 @@ obj-$(CONFIG_COMPAT) += domain.o obj-$(CONFIG_COMPAT) += cpu_idle.o obj-$(CONFIG_COMPAT) += cpufreq.o obj-bin-$(CONFIG_KEXEC) += kexec_reloc.o - -obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o
xen/arch/x86/x86_64/gdbstub.c deleted +0 -150
150 lines not on this page · raw message
xen/common/Makefile +0 -1
@@ -12,7 +12,6 @@ obj-$(CONFIG_OVERLAY_DTB) += dt-overlay.o obj-y += event_2l.o obj-y += event_channel.o obj-y += event_fifo.o -obj-$(CONFIG_CRASH_DEBUG) += gdbstub.o obj-$(CONFIG_GRANT_TABLE) += grant_table.o obj-y += guestcopy.o obj-bin-y += gunzip.init.o
xen/common/gdbstub.c deleted +0 -748
748 lines not on this page · raw message
xen/include/xen/gdbstub.h deleted +0 -103
103 lines not on this page · raw message
base-commit: c378ff8983cd69786c35117e49640f027e581bca
Signature · 1 line
2.30.2
Re: [PATCH 1/2] x86: Remove gdbstub
Quoted 5 lines · Andrew Cooper
In 13y of working on Xen, I've never seen seen it used. The implementation was introduced (commit
b69f92f3012e, Jul 28 2004) with known issues such as:/* Resuming after we've stopped used to work, but more through luck
than any actual intention. It doesn't at the moment. */
As mentioned elsewhere, this alone might constitute a valid use of gdb. Hence I'm a little hesitant here, but given no indication of even this narrow use case having been employed by anyone at any time ...
Quoted 9 lines
which appear to have gone unfixed for the 20 years since.
Nowadays there are more robust ways of inspecting crashed state, such as a kexec crash kernel, or running Xen in a VM.
This will allow us to clean up some hooks around the codebase which are proving awkward for other tasks.
Signed-off-by Andrew Cooper <[email protected]>
Jan
PATCH 2/2 xen: Remove debugger.h
In reply to Andrew CooperWith x86 having dropped gdbstub, Xen's only debugger has gone.
Drop xen/debugger.h and remove the hooks spread around the codebase.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Oleksii Kurochko <[email protected]>
I debated splitting this up, but decided it wasn't worth the effort. There's a lot of further cleanup that can be done, including an include tangle it seems?
--- xen/arch/x86/include/asm/bug.h | 20 ------------- xen/arch/x86/include/asm/debugger.h | 30 -------------------- xen/arch/x86/traps.c | 30 +++----------------- xen/common/bug.c | 27 ------------------ xen/common/keyhandler.c | 22 +-------------- xen/common/shutdown.c | 2 -- xen/drivers/char/console.c | 3 -- xen/include/xen/bug.h | 4 --- xen/include/xen/debugger.h | 44 ----------------------------- 9 files changed, 5 insertions(+), 177 deletions(-) delete mode 100644 xen/arch/x86/include/asm/debugger.h delete mode 100644 xen/include/xen/debugger.h
xen/arch/x86/include/asm/bug.h +0 -20
@@ -1,28 +1,8 @@#ifndef __X86_BUG_H__#define __X86_BUG_H__ -/* -* Please do not include in the header any header that might -* use BUG/ASSERT/etc maros asthey will be defined later after -* the return to <xen/bug.h> from the current header: -* -* <xen/bug.h>: -* ... -* <asm/bug.h>: -* ... -* <any_header_which_uses_BUG/ASSERT/etc macros.h> -* ... -* ... -* #define BUG() ... -* ... -* #define ASSERT() ... -* ... -*/ -#ifndef __ASSEMBLY__ -#define BUG_DEBUGGER_TRAP_FATAL (regs) debugger_trap_fatal(X86_EXC_GP,regs) -#define BUG_INSTR "ud2"#define BUG_ASM_CONST "c"
xen/arch/x86/include/asm/debugger.h deleted +0 -30
@@ -1,30 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0 */ -/****************************************************************************** -* xen/arch/x86/include/asm/debugger.h -* -* x86-specific debugger hooks. -*/ -#ifndef __X86_DEBUGGER_H__ -#define __X86_DEBUGGER_H__ - -#include <xen/gdbstub.h> -#include <xen/stdbool.h> - -#include <asm/x86-defns.h> - -/* Returns true if GDB handled the trap, or it is surviveable. */ -static inline bool debugger_trap_fatal ( -unsigned int vector,struct cpu_user_regs *regs) -{ -int rc =__trap_to_gdb (regs, vector); - -if ( rc ==0 ) -return true; - -return vector ==X86_EXC_BP ; -} - -/* Int3 is a trivial way to gather cpu_user_regs context. */ -#define debugger_trap_immediate () __asm__ __volatile__ ( "int3" ) - -#endif /* __X86_DEBUGGER_H__ */
xen/arch/x86/traps.c +4 -26
@@ -25,7 +25,6 @@#include <xen/shutdown.h> #include <xen/guest_access.h> #include <asm/regs.h> -#include <xen/debugger.h> #include <xen/delay.h> #include <xen/event.h> #include <xen/spinlock.h>
@@ -835,11 +834,6 @@ void fatal_trap(const struct cpu_user_regs *regs, bool show_remote) void asmlinkage do_unhandled_trap(struct cpu_user_regs *regs) { -unsigned int trapnr = regs->entry_vector; - -if (debugger_trap_fatal (trapnr, regs) ) -return ; -fatal_trap (regs, false); }
@@ -941,9 +935,6 @@ void asmlinkage do_trap(struct cpu_user_regs *regs)return ; hardware_trap: -if (debugger_trap_fatal (trapnr, regs) ) -return ; -fatal_trap (regs, false); }
@@ -1190,9 +1181,6 @@ void asmlinkage do_invalid_op(struct cpu_user_regs *regs)if (likely (extable_fixup (regs, true)) )return ; -if (debugger_trap_fatal (X86_EXC_UD , regs) ) -return ; -show_execution_state (regs);panic ("FATAL TRAP: vector = %d (invalid opcode)\n" ,X86_EXC_UD ); }
@@ -1206,9 +1194,8 @@ void asmlinkage do_int3(struct cpu_user_regs *regs)if (likely (extable_fixup (regs, true)) )return ; -if ( !debugger_trap_fatal (X86_EXC_BP , regs) ) -printk (XENLOG_DEBUG "Hit embedded breakpoint at %p [%ps]\n" , -_p (regs->rip),_p (regs->rip)); +printk (XENLOG_DEBUG "Hit embedded breakpoint at %p [%ps]\n" , +_p (regs->rip),_p (regs->rip));return ; }
@@ -1294,9 +1281,6 @@ void do_general_protection(struct cpu_user_regs *regs)return ; hardware_gp: -if (debugger_trap_fatal (X86_EXC_GP , regs) ) -return ; -show_execution_state (regs);panic ("GENERAL PROTECTION FAULT\n[error_code=%04x]\n" , regs->error_code); }
@@ -1620,9 +1604,6 @@ void asmlinkage do_page_fault(struct cpu_user_regs *regs) } fatal: -if (debugger_trap_fatal (X86_EXC_PF , regs) ) -return ; -show_execution_state (regs);show_page_walk (addr); panic("FATAL PAGE FAULT\n"
@@ -1933,11 +1914,8 @@ void asmlinkage do_debug(struct cpu_user_regs *regs) return; }#endif -if ( !debugger_trap_fatal (X86_EXC_DB , regs) ) - { -WARN (); - regs->eflags &= ~X86_EFLAGS_TF ; - } +WARN (); + regs->eflags &= ~X86_EFLAGS_TF ; }/*
xen/common/bug.c +0 -27
@@ -1,23 +1,4 @@#include <xen/bug.h> -/* -* Ideally <xen/debugger.h> should be included in <asm/bug.h> -* but an issue with compilation can occur as <xen/debugger.h> uses -* BUG/ASSERT/etc macros inside but they will be defined later in -* <xen/bug.h> after return from inclusion of <asm/bug.h>: -* -* <xen/bug.h>: -* ... -* <asm/bug.h>: -* ... -* <xen/debugger.h> -> some of included header in it uses BUG/ASSERT/etc -* ... -* ... -* #define BUG() ... -* ... -* #define ASSERT() ... -* ... -*/ -#include <xen/debugger.h> #include <xen/errno.h> #include <xen/kernel.h> #include <xen/livepatch.h>
@@ -96,10 +77,6 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)case BUGFRAME_bug:printk ("Xen BUG at %s%s:%d\n" , prefix, filename, lineno); - -if (BUG_DEBUGGER_TRAP_FATAL (regs) ) -break ; -show_execution_state (regs);panic ("Xen BUG at %s%s:%d\n" , prefix, filename, lineno);
@@ -111,10 +88,6 @@ int do_bug_frame(struct cpu_user_regs *regs, unsigned long pc)printk ("Assertion '%s' failed at %s%s:%d\n" , predicate, prefix, filename, lineno); - -if (BUG_DEBUGGER_TRAP_FATAL (regs) ) -break ; -show_execution_state (regs);panic ("Assertion '%s' failed at %s%s:%d\n" , predicate, prefix, filename, lineno);
xen/common/keyhandler.c +1 -21
@@ -3,7 +3,6 @@*/ #include <asm/regs.h> -#include <xen/debugger.h> #include <xen/delay.h> #include <xen/keyhandler.h> #include <xen/param.h>
@@ -29,8 +28,7 @@ static bool alt_key_handling; static keyhandler_fn_t cf_check show_handlers, cf_check dump_hwdom_registers, cf_check dump_domains, cf_check read_clocks; static irq_keyhandler_fn_t cf_check do_toggle_alt_key, cf_check dump_registers, - cf_check reboot_machine, cf_check run_all_keyhandlers, - cf_check do_debug_key; + cf_check reboot_machine, cf_check run_all_keyhandlers; static struct keyhandler { union {
@@ -57,7 +55,6 @@ static struct keyhandler {IRQ_KEYHANDLER ('R' , reboot_machine,"reboot machine" ,0 ),KEYHANDLER ('t' , read_clocks,"display multi-cpu clock info" ,1 ),KEYHANDLER ('0' , dump_hwdom_registers,"dump Dom0 registers" ,1 ), -IRQ_KEYHANDLER ('%' , do_debug_key,"trap to xendbg" ,0 ),IRQ_KEYHANDLER ('*' , run_all_keyhandlers,"print all diagnostics" ,0 ), #ifdef CONFIG_PERF_COUNTERS
@@ -503,23 +500,6 @@ static void cf_check run_all_keyhandlers(tasklet_schedule (&run_all_keyhandlers_tasklet); } -static void cf_check do_debugger_trap_fatal(struct cpu_user_regs *regs) -{ - (void )debugger_trap_fatal (0xf001 , regs); - -/* Prevent tail call optimisation, which confuses xendbg. */ -barrier (); -} - -static void cf_check do_debug_key(unsigned char key, struct cpu_user_regs *regs) -{ -printk ("'%c' pressed -> trapping into debugger\n" , key); -if ( regs ) -do_debugger_trap_fatal (regs); -else -run_in_exception_handler (do_debugger_trap_fatal); -} - static void cf_check do_toggle_alt_key(unsigned char key,struct cpu_user_regs *regs) {
xen/common/shutdown.c +0 -2
@@ -2,7 +2,6 @@#include <xen/lib.h> #include <xen/param.h> #include <xen/sched.h> -#include <xen/debugger.h> #include <xen/domain.h> #include <xen/delay.h> #include <xen/watchdog.h>
@@ -40,7 +39,6 @@ void hwdom_shutdown(u8 reason)machine_halt ();case SHUTDOWN_crash: -debugger_trap_immediate ();printk ("Hardware Dom%u crashed: " , hardware_domain->domain_id);kexec_crash (CRASHREASON_HWDOM );reboot_or_halt ();
xen/drivers/char/console.c +0 -3
@@ -15,7 +15,6 @@#include <xen/init.h> #include <xen/event.h> #include <xen/console.h> -#include <xen/debugger.h> #include <xen/param.h> #include <xen/serial.h> #include <xen/softirq.h>
@@ -1297,8 +1296,6 @@ void panic(const char *fmt, ...)spin_unlock_irqrestore (&lock, flags); -debugger_trap_immediate (); -kexec_crash (CRASHREASON_PANIC );if ( opt_noreboot )
xen/include/xen/bug.h +0 -4
@@ -16,10 +16,6 @@#ifndef __ASSEMBLY__ -#ifndef BUG_DEBUGGER_TRAP_FATAL -#define BUG_DEBUGGER_TRAP_FATAL (regs) 0 -#endif -#include <xen/macros.h> #include <xen/types.h>
xen/include/xen/debugger.h deleted +0 -44
44 lines not on this page · raw message
Signature · 1 line
2.30.2
Re: [PATCH 2/2] xen: Remove debugger.h
Quoted 14 lines · Andrew Cooper
xen/arch/x86/include/asm/bug.h +0
-8@@ -1,28 +1,8 @@#ifndef __X86_BUG_H__#define __X86_BUG_H__ -/* -* Please do not include in the header any header that might -* use BUG/ASSERT/etc maros asthey will be defined later after -* the return to <xen/bug.h> from the current header: -* -* <xen/bug.h>: -* ... -* <asm/bug.h>:
xen/arch/x86/include/asm/bug.h line 21
Quoted 10 lines
xen/arch/x86/include/asm/bug.h +0
-10-* ... -* <any_header_which_uses_BUG/ASSERT/etc macros.h> -* ... -* ... -* #define BUG() ... -* ... -* #define ASSERT() ... -* ... -*/ -
Leaving aside the clumsiness of the initial text, other than in common/bug.c I don't see why this comment is to go away (and, if at all, in this very patch). With it retained or the removal suitably explained
Jan
Quoted 7 lines
xen/arch/x86/include/asm/bug.h +0
-2#ifndef __ASSEMBLY__ -#define BUG_DEBUGGER_TRAP_FATAL (regs) debugger_trap_fatal(X86_EXC_GP,regs) -#define BUG_INSTR "ud2"#define BUG_ASM_CONST "c"