From nobody Mon May 6 12:48:32 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org ARC-Seal: i=1; a=rsa-sha256; t=1573662221; cv=none; d=zoho.com; s=zohoarc; b=RRu9iUOG2YHPNJfEwrKQCae5EQvFUDSgAVTRKlVGqv7S/snGRhKbp6bJCmRBaQfCXEw59tAsDZTUSK0iEigqsPjINNhIgNm2hSEmc4lf6TAYvEeTmNWmdNwyyDS784qgywSlCozjKHKw5IX6i1xQ5OOKLvcfC5lEXbig2SLt7vw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1573662221; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=aEKJjuxXsFKHbxOCFCvbNrIBWB3rYLcCYx7DaqybTBY=; b=loOia41mz/CV3H3dicxx6Trb5qzwArrktPUyRrkIde0Jh08OgHPkpUuq7TWidFNYAOG6aiobMstS9TBpbw84XUO3Ww0j7OVZq4bJv7STKb5jhUrzjSbRQfks9P0CLS3oAzo/Xi6jgkcOIuuZ3K9gKwdH3fGpMD3DVn2b2RB8VGw= ARC-Authentication-Results: i=1; mx.zoho.com; spf=none (zoho.com: 192.237.175.120 is neither permitted nor denied by domain of lists.xenproject.org) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1573662221565971.293402356252; Wed, 13 Nov 2019 08:23:41 -0800 (PST) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iUvPj-00032J-Vh; Wed, 13 Nov 2019 16:22:39 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1iUvPi-00032D-Qj for xen-devel@lists.xenproject.org; Wed, 13 Nov 2019 16:22:38 +0000 Received: from mx1.suse.de (unknown [195.135.220.15]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id cbb8c524-0631-11ea-a237-12813bfff9fa; Wed, 13 Nov 2019 16:22:33 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 3D6B5B205; Wed, 13 Nov 2019 16:22:32 +0000 (UTC) X-Inumbo-ID: cbb8c524-0631-11ea-a237-12813bfff9fa X-Virus-Scanned: by amavisd-new at test-mx.suse.de From: Juergen Gross To: xen-devel@lists.xenproject.org Date: Wed, 13 Nov 2019 17:22:29 +0100 Message-Id: <20191113162229.1140-1-jgross@suse.com> X-Mailer: git-send-email 2.16.4 Subject: [Xen-devel] [PATCH] xen: make debugger support configurable X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Juergen Gross , Stefano Stabellini , Julien Grall , Wei Liu , Konrad Rzeszutek Wilk , George Dunlap , Andrew Cooper , Ian Jackson , Jan Beulich , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" 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. Signed-off-by: Juergen Gross Acked-by: Jan Beulich --- 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(-) diff --git a/xen/Kconfig.debug b/xen/Kconfig.debug index 22573e74db..84a6e1b8eb 100644 --- a/xen/Kconfig.debug +++ b/xen/Kconfig.debug @@ -13,9 +13,13 @@ config DEBUG =20 if DEBUG || EXPERT =3D "y" =20 +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. 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/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 43e368d63b..90e36b9ad8 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -36,6 +36,7 @@ #include #include =20 +#ifdef CONFIG_GDBSX static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio= *iop) { void * __user gva =3D (void *)iop->gva, * __user uva =3D (void *)iop->= uva; @@ -45,6 +46,7 @@ static int gdbsx_guest_mem_io(domid_t domid, struct xen_d= omctl_gdbsx_memio *iop) =20 return iop->remain ? -EFAULT : 0; } +#endif =20 static void domain_cpu_policy_changed(struct domain *d) { @@ -912,6 +914,7 @@ long arch_do_domctl( } #endif =20 +#ifdef CONFIG_GDBSX case XEN_DOMCTL_gdbsx_guestmemio: domctl->u.gdbsx_guest_memio.remain =3D domctl->u.gdbsx_guest_memio= .len; ret =3D gdbsx_guest_mem_io(domctl->domain, &domctl->u.gdbsx_guest_= memio); @@ -976,6 +979,7 @@ long arch_do_domctl( copyback =3D true; break; } +#endif =20 case XEN_DOMCTL_setvcpuextstate: case XEN_DOMCTL_getvcpuextstate: 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 =20 -config HAS_GDBSX - bool - config HAS_IOPORTS bool =20 diff --git a/xen/common/domain.c b/xen/common/domain.c index 611116c7fc..b4e041ffd0 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); } =20 -#ifdef CONFIG_HAS_GDBSX +#ifdef CONFIG_GDBSX void domain_pause_for_debugger(void) { struct vcpu *curr =3D current; diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h index b1b627f1fa..4a8f226b86 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" ); =20 -#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 * __use= r buf, unsigned int len, domid_t domid, bool toaddr, uint64_t pgd3); =20 +#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__ */ diff --git a/xen/include/xen/sched.h b/xen/include/xen/sched.h index 9f7bc69293..094003f562 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_GDBSX void domain_pause_for_debugger(void); +#else +static inline void domain_pause_for_debugger(void) { } +#endif =20 int domain_soft_reset(struct domain *d); =20 --=20 2.16.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xenproject.org https://lists.xenproject.org/mailman/listinfo/xen-devel