[v2,1/2] xen: put more code under CONFIG_CRASH_DEBUG
diff mbox series

Message ID 20191114082739.7928-2-jgross@suse.com
State New
Headers show
Series
  • xen: make more debugger support code conditional
Related show

Commit Message

Jürgen Groß Nov. 14, 2019, 8:27 a.m. UTC
Some code is not needed with CONFIG_CRASH_DEBUG, so only include it if
CONFIG_CRASH_DEBUG is defined.

While at it remove CONFIG_HAS_GDBSX as it can easily be replaced by
CONFIG_CRASH_DEBUG.

Signed-off-by: Juergen Gross <jgross@suse.com>
---
 xen/arch/x86/Kconfig           |  1 -
 xen/common/Kconfig             |  3 ---
 xen/common/domain.c            |  2 +-
 xen/include/asm-x86/debugger.h | 30 ++++++++++++++++++------------
 xen/include/xen/sched.h        |  4 ++++
 5 files changed, 23 insertions(+), 17 deletions(-)

Comments

Andrew Cooper Nov. 29, 2019, 7:43 p.m. UTC | #1
On 14/11/2019 08:27, Juergen Gross wrote:
> diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
> index 9f7bc69293..d2d30ece7d 100644
> --- a/xen/include/xen/sched.h
> +++ b/xen/include/xen/sched.h
> @@ -652,7 +652,11 @@ void domain_destroy(struct domain *d);
>  int domain_kill(struct domain *d);
>  int domain_shutdown(struct domain *d, u8 reason);
>  void domain_resume(struct domain *d);
> +#ifdef CONFIG_CRASH_DEBUG
>  void domain_pause_for_debugger(void);
> +#else
> +static inline void domain_pause_for_debugger(void) { }
> +#endif

This looked a tad weird.  It turns out we've got a trivial
domain_pause_for_debugger() in common code, guarded by
CONFIG_CRASH_DEBUG, which is actually an x86 check, seeing as
gdbsx_vcpu_event doesn't exist on ARM.

I'd suggest moving domain_pause_for_debugger() into arch/x86/domain.c
and moving this prototype into debugger.h

With an #include <asm/debugger.h> in vmx/realmode.c, it appears to build
fine.

~Andrew

Patch
diff mbox series

diff --git a/xen/arch/x86/Kconfig b/xen/arch/x86/Kconfig
index 28b3b4692a..c72da8964a 100644
--- a/xen/arch/x86/Kconfig
+++ b/xen/arch/x86/Kconfig
@@ -13,7 +13,6 @@  config X86
 	select HAS_EHCI
 	select HAS_EX_TABLE
 	select HAS_FAST_MULTIPLY
-	select HAS_GDBSX
 	select HAS_IOPORTS
 	select HAS_KEXEC
 	select MEM_ACCESS_ALWAYS_ON
diff --git a/xen/common/Kconfig b/xen/common/Kconfig
index f754741972..7bde6aff02 100644
--- a/xen/common/Kconfig
+++ b/xen/common/Kconfig
@@ -57,9 +57,6 @@  config HAS_UBSAN
 config HAS_KEXEC
 	bool
 
-config HAS_GDBSX
-	bool
-
 config HAS_IOPORTS
 	bool
 
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 611116c7fc..c06efedc8e 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -915,7 +915,7 @@  void vcpu_end_shutdown_deferral(struct vcpu *v)
         vcpu_check_shutdown(v);
 }
 
-#ifdef CONFIG_HAS_GDBSX
+#ifdef CONFIG_CRASH_DEBUG
 void domain_pause_for_debugger(void)
 {
     struct vcpu *curr = current;
diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h
index b1b627f1fa..e23f2fa4a3 100644
--- a/xen/include/asm-x86/debugger.h
+++ b/xen/include/asm-x86/debugger.h
@@ -47,18 +47,6 @@  static inline bool debugger_trap_fatal(
 /* Int3 is a trivial way to gather cpu_user_regs context. */
 #define debugger_trap_immediate() __asm__ __volatile__ ( "int3" );
 
-#else
-
-static inline bool debugger_trap_fatal(
-    unsigned int vector, struct cpu_user_regs *regs)
-{
-    return false;
-}
-
-#define debugger_trap_immediate() ((void)0)
-
-#endif
-
 static inline bool debugger_trap_entry(
     unsigned int vector, struct cpu_user_regs *regs)
 {
@@ -84,6 +72,24 @@  static inline bool debugger_trap_entry(
     return false;
 }
 
+#else
+
+static inline bool debugger_trap_fatal(
+    unsigned int vector, struct cpu_user_regs *regs)
+{
+    return false;
+}
+
+#define debugger_trap_immediate() ((void)0)
+
+static inline bool debugger_trap_entry(
+    unsigned int vector, struct cpu_user_regs *regs)
+{
+    return false;
+}
+
+#endif
+
 unsigned int dbg_rw_mem(void * __user addr, void * __user buf,
                         unsigned int len, domid_t domid, bool toaddr,
                         uint64_t pgd3);
diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h
index 9f7bc69293..d2d30ece7d 100644
--- a/xen/include/xen/sched.h
+++ b/xen/include/xen/sched.h
@@ -652,7 +652,11 @@  void domain_destroy(struct domain *d);
 int domain_kill(struct domain *d);
 int domain_shutdown(struct domain *d, u8 reason);
 void domain_resume(struct domain *d);
+#ifdef CONFIG_CRASH_DEBUG
 void domain_pause_for_debugger(void);
+#else
+static inline void domain_pause_for_debugger(void) { }
+#endif
 
 int domain_soft_reset(struct domain *d);