[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen: Remove debugger.h



commit 3f819af8a796c0e2f798dd301ec8c3f8cccbc9fc
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Fri Jan 26 19:55:18 2024 +0000
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Thu Feb 1 19:52:44 2024 +0000

    xen: Remove debugger.h
    
    With x86 having dropped gdbstub, Xen's only debugger has gone.
    
    Drop xen/debugger.h and remove the hooks spread around the codebase.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/include/asm/bug.h      |  2 --
 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(+), 159 deletions(-)

diff --git a/xen/arch/x86/include/asm/bug.h b/xen/arch/x86/include/asm/bug.h
index 7fe879a8cc..e748b6c2f2 100644
--- a/xen/arch/x86/include/asm/bug.h
+++ b/xen/arch/x86/include/asm/bug.h
@@ -21,8 +21,6 @@
 
 #ifndef __ASSEMBLY__
 
-#define BUG_DEBUGGER_TRAP_FATAL(regs) debugger_trap_fatal(X86_EXC_GP,regs)
-
 #define BUG_INSTR       "ud2"
 #define BUG_ASM_CONST   "c"
 
diff --git a/xen/arch/x86/include/asm/debugger.h 
b/xen/arch/x86/include/asm/debugger.h
deleted file mode 100644
index a5c299c6c3..0000000000
--- a/xen/arch/x86/include/asm/debugger.h
+++ /dev/null
@@ -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__ */
diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c
index 7724306116..5f4bcc0537 100644
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -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;
         }
 
         /*
diff --git a/xen/common/bug.c b/xen/common/bug.c
index ca166e102b..5fbe703a81 100644
--- a/xen/common/bug.c
+++ b/xen/common/bug.c
@@ -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);
diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c
index 99a2d72a02..f131034d33 100644
--- a/xen/common/keyhandler.c
+++ b/xen/common/keyhandler.c
@@ -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)
 {
diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c
index dfd5e41097..5f8141edc6 100644
--- a/xen/common/shutdown.c
+++ b/xen/common/shutdown.c
@@ -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();
diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c
index 0666564ec9..dce0226e87 100644
--- a/xen/drivers/char/console.c
+++ b/xen/drivers/char/console.c
@@ -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 )
diff --git a/xen/include/xen/bug.h b/xen/include/xen/bug.h
index 8cca4486a4..4bd0be5088 100644
--- a/xen/include/xen/bug.h
+++ b/xen/include/xen/bug.h
@@ -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>
 
diff --git a/xen/include/xen/debugger.h b/xen/include/xen/debugger.h
deleted file mode 100644
index 72684268af..0000000000
--- a/xen/include/xen/debugger.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0 */
-/******************************************************************************
- * Arch specific debuggers should implement:
- *
- * debugger_trap_fatal():
- *  Called when Xen is about to give up and crash. Typically you will use this
- *  hook to drop into a debug session. It can also be used to hook off
- *  deliberately caused traps (which you then handle and return non-zero).
- *
- * debugger_trap_immediate():
- *  Called if we want to drop into a debugger now.  This is essentially the
- *  same as debugger_trap_fatal, except that we use the current register state
- *  rather than the state which was in effect when we took the trap.
- *  For example: if we're dying because of an unhandled exception, we call
- *  debugger_trap_fatal; if we're dying because of a panic() we call
- *  debugger_trap_immediate().
- */
-
-#ifndef __XEN_DEBUGGER_H__
-#define __XEN_DEBUGGER_H__
-
-#ifdef CONFIG_CRASH_DEBUG
-
-#include <asm/debugger.h>
-
-#else
-
-#include <xen/stdbool.h>
-
-struct cpu_user_regs;
-
-static inline bool debugger_trap_fatal(
-    unsigned int vector, const struct cpu_user_regs *regs)
-{
-    return false;
-}
-
-static inline void debugger_trap_immediate(void)
-{
-}
-
-#endif /* CONFIG_CRASH_DEBUG */
-
-#endif /* __XEN_DEBUGGER_H__ */
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.