xen: make debugger support configurable
PATCH 1/1 xen: make debugger support configurable
Debugger support in the hypervisor is rarely used and it is opening a way for dom0 to modify the running hypervisor by very easy means.
Add a Kconfig option to control support of gdbsx. Default is off.
--- xen/Kconfig.debug | 4 ++++ xen/arch/x86/Kconfig | 1 - xen/arch/x86/domctl.c | 4 ++++ xen/common/Kconfig | 3 --- xen/common/domain.c | 2 +- xen/include/asm-x86/debugger.h | 30 ++++++++++++++++++------------ xen/include/xen/sched.h | 4 ++++ 7 files changed, 31 insertions(+), 17 deletions(-)
xen/Kconfig.debug +4 -0
@@ -13,9 +13,13 @@ config DEBUG if DEBUG || EXPERT = "y" +config GDBSX + bool + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86 + select GDBSX ---help--- If you want to attach gdb to Xen to debug Xen if it crashes then say Y.
xen/arch/x86/Kconfig +0 -1
@@ -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
xen/arch/x86/domctl.c +4 -0
@@ -36,6 +36,7 @@#include <asm/psr.h> #include <asm/cpuid.h> +#ifdef CONFIG_GDBSX static int gdbsx_guest_mem_io (domid_t domid,struct xen_domctl_gdbsx_memio *iop) {void *__user gva = (void *)iop->gva, *__user uva = (void *)iop->uva;
@@ -45,6 +46,7 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) return iop->remain ? -EFAULT : 0; } +#endif static void domain_cpu_policy_changed (struct domain *d) {
@@ -912,6 +914,7 @@ long arch_do_domctl( }#endif +#ifdef CONFIG_GDBSX case XEN_DOMCTL_gdbsx_guestmemio: domctl->u.gdbsx_guest_memio.remain = domctl->u.gdbsx_guest_memio.len; ret =gdbsx_guest_mem_io (domctl->domain, &domctl->u.gdbsx_guest_memio);
@@ -976,6 +979,7 @@ long arch_do_domctl( copyback = true; break; } +#endif case XEN_DOMCTL_setvcpuextstate:case XEN_DOMCTL_getvcpuextstate:
xen/common/Kconfig +0 -3
@@ -57,9 +57,6 @@ config HAS_UBSAN config HAS_KEXEC bool -config HAS_GDBSX - bool - config HAS_IOPORTS bool
xen/common/domain.c +1 -1
@@ -915,7 +915,7 @@ void vcpu_end_shutdown_deferral(struct vcpu *v)vcpu_check_shutdown (v); } -#ifdef CONFIG_HAS_GDBSX +#ifdef CONFIG_GDBSX void domain_pause_for_debugger (void ) {struct vcpu *curr = current;
xen/include/asm-x86/debugger.h +18 -12
@@ -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) {
@@ -88,4 +76,22 @@ unsigned int dbg_rw_mem(void * __user addr, void * __user buf, unsigned int len, domid_t domid, bool toaddr, uint64_t pgd3); +#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 +#endif /* __X86_DEBUGGER_H__ */
xen/include/xen/sched.h +4 -0
@@ -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_GDBSX void domain_pause_for_debugger (void ); +#else +static inline void domain_pause_for_debugger (void ) { } +#endif int domain_soft_reset (struct domain *d);
Signature · 7 lines
2.16.4 _______________________________________________ Xen-devel mailing list [email protected] https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 6 lines · Juergen Gross
Debugger support in the hypervisor is rarely used and it is opening a way for dom0 to modify the running hypervisor by very easy means.
Add a
Kconfigoption to control support of gdbsx. Default is off.Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 24 lines · Juergen Gross
Debugger support in the hypervisor is rarely used and it is opening a way for dom0 to modify the running hypervisor by very easy means.
Add a
Kconfigoption to control support of gdbsx. Default is off.Signed-off-by Juergen Gross <[email protected]>--- xen/Kconfig.debug | 4 ++++ xen/arch/x86/Kconfig | 1 - xen/arch/x86/domctl.c | 4 ++++ xen/common/Kconfig | 3 --- xen/common/domain.c | 2 +- xen/include/asm-x86/debugger.h | 30 ++++++++++++++++++------------ xen/include/xen/sched.h | 4 ++++ 7 files changed, 31 insertions(+), 17 deletions(-)xen/Kconfig.debug +0
-0@@ -13,9 +13,13 @@ config DEBUG if DEBUG || EXPERT = "y"
xen/Kconfig.debug config DEBUG · line 25
Quoted 10 lines
xen/Kconfig.debug +4
-0+config GDBSX + bool + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86 + select GDBSX ---help--- If you want to attach gdb to Xen to debug Xen if it crashes then say Y.
CRASH_DEBUG and GDBSX are unrelated.
The former is gdbstub over serial for Xen itself (which I've never seen used, and therefore doubt functions), while the latter is a set of dom0 hypercalls used by the gdbsx utility.
I'm happy to make CONFIG_GDBSX more useful than it currently is, but I don't think the two options want conflating.
~Andrew
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel
Quoted 38 lines · Andrew Cooper
Quoted 24 lines · Juergen Gross
Debugger support in the hypervisor is rarely used and it is opening a way for dom0 to modify the running hypervisor by very easy means.
Add a
Kconfigoption to control support of gdbsx. Default is off.Signed-off-by Juergen Gross <[email protected]>--- xen/Kconfig.debug | 4 ++++ xen/arch/x86/Kconfig | 1 - xen/arch/x86/domctl.c | 4 ++++ xen/common/Kconfig | 3 --- xen/common/domain.c | 2 +- xen/include/asm-x86/debugger.h | 30 ++++++++++++++++++------------ xen/include/xen/sched.h | 4 ++++ 7 files changed, 31 insertions(+), 17 deletions(-)xen/Kconfig.debug +0
-0@@ -13,9 +13,13 @@ config DEBUG if DEBUG || EXPERT = "y"xen/Kconfig.debug config DEBUG · line 25
Quoted 10 lines
xen/Kconfig.debug +4
-0+config GDBSX + bool + config CRASH_DEBUG bool "Crash Debugging Support" depends on X86 + select GDBSX ---help--- If you want to attach gdb to Xen to debug Xen if it crashes then say Y.
CRASH_DEBUGand GDBSX are unrelated.
Quoted 6 lines
The former is gdbstub over serial for Xen itself (which I've never seen used, and therefore doubt functions), while the latter is a set of dom0 hypercalls used by the gdbsx utility.
I'm happy to make
CONFIG_GDBSXmore useful than it currently is, but I don't think the two options want conflating.
Ah, okay.
Will send V2 with 2 patches: one for putting more code under CONFIG_CRASH_DEBUG and one for introducing CONFIG_GDBSX.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel