From 4de0f05fcf7d57c25aaef2f4aa064812b8628a72 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Wed, 20 Apr 2022 01:38:32 +0100 Subject: [PATCH] x86/gdbsx: Move domain_pause_for_debugger() into gdbsx domain_pause_for_debugger() is guest debugging (CONFIG_GDBSX) not host debugging (CONFIG_CRASH_DEBUG). Move it into the new gdbsx.c to drop the (incorrect) ifdefary, and provide a static inline in the !CONFIG_GDBSX case so callers can optimise away everything rather than having to emit a call to an empty function. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich --- xen/arch/x86/domain.c | 14 -------------- xen/arch/x86/gdbsx.c | 14 ++++++++++++++ xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/realmode.c | 3 ++- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/include/asm/debugger.h | 2 -- xen/arch/x86/include/asm/gdbsx.h | 6 ++++++ xen/arch/x86/nmi.c | 1 - xen/arch/x86/traps.c | 1 + 9 files changed, 25 insertions(+), 20 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index a5048ed654..a72cc9552a 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2540,20 +2540,6 @@ static int __init cf_check init_vcpu_kick_softirq(void) } __initcall(init_vcpu_kick_softirq); -void domain_pause_for_debugger(void) -{ -#ifdef CONFIG_CRASH_DEBUG - struct vcpu *curr = current; - struct domain *d = curr->domain; - - domain_pause_by_systemcontroller_nosync(d); - - /* if gdbsx active, we just need to pause the domain */ - if ( curr->arch.gdbsx_vcpu_event == 0 ) - send_global_virq(VIRQ_DEBUGGER); -#endif -} - /* * Local variables: * mode: C diff --git a/xen/arch/x86/gdbsx.c b/xen/arch/x86/gdbsx.c index 59eb31fc9a..6ef46e8ea7 100644 --- a/xen/arch/x86/gdbsx.c +++ b/xen/arch/x86/gdbsx.c @@ -18,6 +18,8 @@ #include #include #include +#include + #include #include @@ -164,6 +166,18 @@ int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *iop) return iop->remain ? -EFAULT : 0; } +void domain_pause_for_debugger(void) +{ + struct vcpu *curr = current; + struct domain *d = curr->domain; + + domain_pause_by_systemcontroller_nosync(d); + + /* if gdbsx active, we just need to pause the domain */ + if ( curr->arch.gdbsx_vcpu_event == 0 ) + send_global_virq(VIRQ_DEBUGGER); +} + /* * Local variables: * mode: C diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 2455835eda..0849a9dc5f 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -58,7 +58,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmode.c index cc23afa788..4ac93e0810 100644 --- a/xen/arch/x86/hvm/vmx/realmode.c +++ b/xen/arch/x86/hvm/vmx/realmode.c @@ -14,7 +14,8 @@ #include #include #include -#include + +#include #include #include #include diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c index af9ee7cebb..cc8c4e9f04 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/xen/arch/x86/include/asm/debugger.h b/xen/arch/x86/include/asm/debugger.h index c5585752ca..9a3132356f 100644 --- a/xen/arch/x86/include/asm/debugger.h +++ b/xen/arch/x86/include/asm/debugger.h @@ -26,8 +26,6 @@ #include #include -void domain_pause_for_debugger(void); - #ifdef CONFIG_CRASH_DEBUG #include diff --git a/xen/arch/x86/include/asm/gdbsx.h b/xen/arch/x86/include/asm/gdbsx.h index eee746fc01..938eb74e2e 100644 --- a/xen/arch/x86/include/asm/gdbsx.h +++ b/xen/arch/x86/include/asm/gdbsx.h @@ -9,5 +9,11 @@ struct xen_domctl_gdbsx_memio; int gdbsx_guest_mem_io(struct domain *d, struct xen_domctl_gdbsx_memio *iop); +void domain_pause_for_debugger(void); + +#else + +static inline void domain_pause_for_debugger(void) {} + #endif /* CONFIG_GDBSX */ #endif /* __X86_GDBX_H__ */ diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index 302eaf2ff3..7656023748 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 84cd038dc3..d915324611 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -58,6 +58,7 @@ #include #include #include +#include #include #include #include -- 2.30.2