From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318633; cv=none; d=zohomail.com; s=zohoarc; b=hSA1rH5oyWnTPm2AEN628h1UV3vf6ZS+FqHtpbOJ0HhBpDXFS4VNdeRPuOFqy7/LZ771zF7i8rzZhkybp0XtHQam/092wPRubkHs7cBIOniWn994sFPhwdQzHEFqvxQfFG/v/Wit3q24Q5G6eXmZaFO97F+E501uTwT87jkkfSM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318633; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ymbhtWJDlmnuoU0qSCptZumb6o8HnxQbmRZItmihOOU=; b=ZcyfwsLjhmV3lw7yPjds/BAqBQXpr9hOs0Z2KQdbOErJmKpwgMpoMUkUaGk9lkpeXY9GfGKc+EoGdUQB3hXh3cIU/imqUvkMee949FF8xBR+Q9qk43k4wATXNeWCrJdydsJqktFM4c2zK7yHQFqlqiN5KHO6fEHv9KgZPPoVzLU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629318633044858.2299946957536; Wed, 18 Aug 2021 13:30:33 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168317.307328 (Exim 4.92) (envelope-from ) id 1mGSCH-0007Hw-OS; Wed, 18 Aug 2021 20:30:01 +0000 Received: by outflank-mailman (output) from mailman id 168317.307328; Wed, 18 Aug 2021 20:30:01 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCH-0007Hn-LC; Wed, 18 Aug 2021 20:30:01 +0000 Received: by outflank-mailman (input) for mailman id 168317; Wed, 18 Aug 2021 20:29:59 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCF-000714-NG for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:29:59 +0000 Received: from mail-pl1-x633.google.com (unknown [2607:f8b0:4864:20::633]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5cd00804-05e6-4fea-bf0e-1e3d6a630f84; Wed, 18 Aug 2021 20:29:53 +0000 (UTC) Received: by mail-pl1-x633.google.com with SMTP id c17so2587564plz.2 for ; Wed, 18 Aug 2021 13:29:49 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:47 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 5cd00804-05e6-4fea-bf0e-1e3d6a630f84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ymbhtWJDlmnuoU0qSCptZumb6o8HnxQbmRZItmihOOU=; b=YKl9qr55piVM4v/UfO59fMR1wKRC2574LTWQNfSd0FVrL5nHh2bww1/I4V9aaHQ9cz KAd5HFzP5L4Dxy2z+xuudCCzeuW0RlCd/cqm7ze7zVCdRWUAp85G+CG1WWgLFxwwtxQS rbVym4zvigZQf+66xocGuApPV0F8WHaCnOhPkO8J1OvtmgahtqSMpjs9km4JEX6c/TvQ MebjS242u3bnJSG7uNbYzhEIkeT8OnIRPR5ha0ERS0ygDzyB4DFKsvWo0Z+O6VQjKbHd 471tzl/JVoe5wnVyrSHit6NKR9EB0PgF0eukJwkgPf9PTYYK2uZ6xwnBzCIIWZKqbohJ vurA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=ymbhtWJDlmnuoU0qSCptZumb6o8HnxQbmRZItmihOOU=; b=RXl7A+w3zv4HYSYu8IXM4o5aLDhyUJNn8c5MhY5f8KKf/yok42zVlY9okh8/g8kE8r hYloOWLvWBxkkRdUZWiXx0WBxYu76s0vmGnAapRh8jTwSIYN4XNZ25xHpSlN4/XzdnzU XRCtsNcapQPcRmKHP0W1sgsfvLP875+/lqKukBolTAusiUW0gm+CIxP7KcZg5WKs5eEY pqayeEbKC5NoxWNux9NUImF9yyZOArIeMVykdZm1I73Y2PXb2OF+FjnaTCLikAFHzHwY x+0Fprq9/F6j4fKDMU8dkUYe7dWe2Q8FVhp92E0eXIFMSwznTDLxtqtcUZAjcgP82Icg zSig== X-Gm-Message-State: AOAM5328Fvm+WvdxLzd4lVg3xnnujavDz5gnIBwjqdnqLYs3/Q1IhMV1 WqLXOnK7+i6hNy8O56+sOWQASCmDAfLHrhRs X-Google-Smtp-Source: ABdhPJwg4IupZNg4wmzTylST1vPnBXDYpAFAsWlOW3tjWfPe3sReJbOfM6NM7rjPmc4Xs5AxlpgpQw== X-Received: by 2002:a17:902:7441:b029:12d:6476:d8f with SMTP id e1-20020a1709027441b029012d64760d8fmr8903237plt.28.1629318588212; Wed, 18 Aug 2021 13:29:48 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 1/6] arm/traps: remove debugger_trap_fatal() calls Date: Wed, 18 Aug 2021 13:29:02 -0700 Message-Id: <4c4f45280547564b2c16fd9ca09443314b8f3b6e.1629315873.git.bobby.eshleman@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318635642100001 Content-Type: text/plain; charset="utf-8" ARM doesn't actually use debugger_trap_* anything, and is stubbed out. This commit simply removes the unneeded calls. Signed-off-by: Bobby Eshleman Acked-by: Julien Grall --- xen/arch/arm/traps.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 4ccb6e7d18..889650ba63 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include #include @@ -1266,10 +1265,6 @@ int do_bug_frame(const struct cpu_user_regs *regs, v= addr_t pc) =20 case BUGFRAME_bug: printk("Xen BUG at %s%s:%d\n", prefix, filename, lineno); - - if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) - return 0; - show_execution_state(regs); panic("Xen BUG at %s%s:%d\n", prefix, filename, lineno); =20 @@ -1281,8 +1276,6 @@ int do_bug_frame(const struct cpu_user_regs *regs, va= ddr_t pc) =20 printk("Assertion '%s' failed at %s%s:%d\n", predicate, prefix, filename, lineno); - if ( debugger_trap_fatal(TRAP_invalid_op, regs) ) - return 0; show_execution_state(regs); panic("Assertion '%s' failed at %s%s:%d\n", predicate, prefix, filename, lineno); --=20 2.32.0 From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318642; cv=none; d=zohomail.com; s=zohoarc; b=OGWDDprsiec3xBIOK0ATxRkMiEOmJsRjwjFv+vo67QZN8D3HqfQcM/AOMShoC3cP0yyMqFfTO16qGnr2xSxzMNfsj7jejgF16S0QElFDKOnjHC17eEl9r61PajybabawgZ3iStMrP54oETlnp1suEcfWYU+ZtxaCF9vDmRScdhM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318642; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=4ydItZe/YrS4x0wkLgFOI7vFRBemhJhfaF8p2sL58+8=; b=Z/qjnnniclKxs2QeGDhv9tTlLnCBdUVGmB7Zs8knbjgr7yPajVdTCf66mK3tIS8jXKY4dGvqxi6hKzlmvw7OgPTTOu6qVmLsx87GG2G3Wu5Z1pm80KAZSjkyFjf+hFXh1OmS07dxEOJCyqGloNOu5NIdru9vU81o4IoKvaVOjs0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629318642626718.0799982893582; Wed, 18 Aug 2021 13:30:42 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168320.307361 (Exim 4.92) (envelope-from ) id 1mGSCW-0000fQ-OO; Wed, 18 Aug 2021 20:30:16 +0000 Received: by outflank-mailman (output) from mailman id 168320.307361; Wed, 18 Aug 2021 20:30:16 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCW-0000fH-Kc; Wed, 18 Aug 2021 20:30:16 +0000 Received: by outflank-mailman (input) for mailman id 168320; Wed, 18 Aug 2021 20:30:14 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCU-000714-Ne for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:30:14 +0000 Received: from mail-pj1-x102a.google.com (unknown [2607:f8b0:4864:20::102a]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id d8baf436-6195-4e7d-9640-fac0d15dc35e; Wed, 18 Aug 2021 20:29:53 +0000 (UTC) Received: by mail-pj1-x102a.google.com with SMTP id hv22-20020a17090ae416b0290178c579e424so3183136pjb.3 for ; Wed, 18 Aug 2021 13:29:50 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:49 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: d8baf436-6195-4e7d-9640-fac0d15dc35e DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=4ydItZe/YrS4x0wkLgFOI7vFRBemhJhfaF8p2sL58+8=; b=j69g3PiS+OxRuyXwjF6Adopqs6d6B5vsr8+HrrpIV+qi3sDt04QKnw8l3WamaXbl8P lFe9uwvk+CFaTSbfKh9I5t/ZACiU87LZJYsQReYVHbHhpPCa5Dmf+cqjrqzZbjIjPx84 y0cQ2HeRnAgmkSO/ld4sdqsp2QkNsU/5730BRWLuIlRo7WyiPErZjRRmIeemEtqpToqd /WGKvPoq9c8tz61cIK8W4H93byIz9PsXEvwGA2cBB8A6cTqydsB3pJQEJtTG4GI1f9JV 07jDQEFjyYJx4xeIRNNfRysHilXtnKXOI+Fem2W7C8str9dKkjdT6dWKM45aCcIW4CNb +zkg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=4ydItZe/YrS4x0wkLgFOI7vFRBemhJhfaF8p2sL58+8=; b=hyXY/shnDNo4KsczubLg1NzZO5yjflxE3liTgHDWDeAf6mvcNNLGcglwwCf+uy3eeD xML8QA2R0OON8NBpkbtBX6EJt4UQxIBLdIluMvMnhv2+X1F2BrsVo+44Nj5vAARATgGs zpR3kWpSLqfF1D6XKUWK1vCFvuK9Dz/ujIDUOT4/ZCNzijcKDlw5pd9n9qpKQrDMCc7a KIWEa3TDsk5xKzv/3uIt6dYNJpvxB3Udpu3A2zKmdLvMc8WhANHI3BnED/wLjm2AaE9A kPdk6qLOW7jFCIsfTfaTDa3GZd/rJtZfTOeN0XPfB25m/zafZcRDKkdopOpD8tpzPZx/ Tldw== X-Gm-Message-State: AOAM530YuttnDbN3JX9wf9AV16Rm8jVwEMtIWyUgKul5fmETXAiB3PKI S2DQERGljO4EiPDbFtKbehk6T1G15XM4pm2R X-Google-Smtp-Source: ABdhPJxM0yxuBeRAbA8LrpLo+klvMhi1bXn5XmaAsWbgMUvlPUn70NylvnbO/RZnS+q/ra6wqr4sSQ== X-Received: by 2002:a17:90a:9411:: with SMTP id r17mr11107155pjo.49.1629318589386; Wed, 18 Aug 2021 13:29:49 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 2/6] x86/debugger: separate Xen and guest debugging debugger_trap_* functions Date: Wed, 18 Aug 2021 13:29:03 -0700 Message-Id: <7925a89cf830e0e3705a8700fce09a408fcfc27c.1629315873.git.bobby.eshleman@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318644355100001 Content-Type: text/plain; charset="utf-8" Unlike debugger_trap_fatal() and debugger_trap_immediate(), debugger_trap_entry() is specific to guest debugging and *NOT* the debugging of Xen itself. That is, it is part of gdbsx functionality and not the Xen gdstub. This is evidenced by debugger_trap_fatal()'s usage of domain_pause_for_debugger(). Because of this, debugger_trap_entry() does not belong alongside the generic Xen debugger functionality. This commit fixes this by expanding inline debugger_trap_entry() into its usage in x86/traps.c and stubbing out domain_pause_for_debugger() when !CONFIG_GDBSX. Properly placing what was debugger_trap_entry() under the scope of gdbsx instead of gdbstub. The function calls that caused an effective no-op and early exit out of debugger_trap_entry() are removed completely (when the trapnr is not int3/debug). This commit is one of a series geared towards removing the unnecessary requirement that all architectures to implement . Signed-off-by: Bobby Eshleman --- xen/arch/x86/domain.c | 2 +- xen/arch/x86/traps.c | 48 ++++++++++++++++++++-------------- xen/include/asm-x86/debugger.h | 42 ++--------------------------- 3 files changed, 31 insertions(+), 61 deletions(-) diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index ef1812dc14..70894ff826 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -2541,7 +2541,7 @@ __initcall(init_vcpu_kick_softirq); =20 void domain_pause_for_debugger(void) { -#ifdef CONFIG_CRASH_DEBUG +#ifdef CONFIG_GDBSX struct vcpu *curr =3D current; struct domain *d =3D curr->domain; =20 diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index e60af16ddd..d0a4c0ea74 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -858,13 +858,20 @@ static void do_trap(struct cpu_user_regs *regs) if ( regs->error_code & X86_XEC_EXT ) goto hardware_trap; =20 - if ( debugger_trap_entry(trapnr, regs) ) - return; - ASSERT(trapnr < 32); =20 if ( guest_mode(regs) ) { + struct vcpu *curr =3D current; + if ( (trapnr =3D=3D TRAP_debug || trapnr =3D=3D TRAP_int3) && + guest_kernel_mode(curr, regs) && + curr->domain->debugger_attached ) + { + if ( trapnr !=3D TRAP_debug ) + curr->arch.gdbsx_vcpu_event =3D trapnr; + domain_pause_for_debugger(); + return; + } pv_inject_hw_exception(trapnr, (TRAP_HAVE_EC & (1u << trapnr)) ? regs->error_code : X86_EVENT_NO_EC); @@ -1094,9 +1101,6 @@ void do_invalid_op(struct cpu_user_regs *regs) int id =3D -1, lineno; const struct virtual_region *region; =20 - if ( debugger_trap_entry(TRAP_invalid_op, regs) ) - return; - if ( likely(guest_mode(regs)) ) { if ( pv_emulate_invalid_op(regs) ) @@ -1201,8 +1205,7 @@ void do_invalid_op(struct cpu_user_regs *regs) =20 void do_int3(struct cpu_user_regs *regs) { - if ( debugger_trap_entry(TRAP_int3, regs) ) - return; + struct vcpu *curr =3D current; =20 if ( !guest_mode(regs) ) { @@ -1215,6 +1218,12 @@ void do_int3(struct cpu_user_regs *regs) =20 return; } + else if ( guest_kernel_mode(curr, regs) && curr->domain->debugger_atta= ched ) + { + curr->arch.gdbsx_vcpu_event =3D TRAP_int3; + domain_pause_for_debugger(); + return; + } =20 pv_inject_hw_exception(TRAP_int3, X86_EVENT_NO_EC); } @@ -1492,9 +1501,6 @@ void do_page_fault(struct cpu_user_regs *regs) /* fixup_page_fault() might change regs->error_code, so cache it here.= */ error_code =3D regs->error_code; =20 - if ( debugger_trap_entry(TRAP_page_fault, regs) ) - return; - perfc_incr(page_faults); =20 /* Any shadow stack access fault is a bug in Xen. */ @@ -1593,9 +1599,6 @@ void do_general_protection(struct cpu_user_regs *regs) struct vcpu *v =3D current; #endif =20 - if ( debugger_trap_entry(TRAP_gp_fault, regs) ) - return; - if ( regs->error_code & X86_XEC_EXT ) goto hardware_gp; =20 @@ -1888,9 +1891,6 @@ void do_debug(struct cpu_user_regs *regs) /* Stash dr6 as early as possible. */ dr6 =3D read_debugreg(6); =20 - if ( debugger_trap_entry(TRAP_debug, regs) ) - return; - /* * At the time of writing (March 2018), on the subject of %dr6: * @@ -1994,6 +1994,11 @@ void do_debug(struct cpu_user_regs *regs) =20 return; } + else if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached ) + { + domain_pause_for_debugger(); + return; + } =20 /* Save debug status register where guest OS can peek at it */ v->arch.dr6 |=3D (dr6 & ~X86_DR6_DEFAULT); @@ -2014,9 +2019,6 @@ void do_entry_CP(struct cpu_user_regs *regs) const char *err =3D "??"; unsigned int ec =3D regs->error_code; =20 - if ( debugger_trap_entry(TRAP_debug, regs) ) - return; - /* Decode ec if possible */ if ( ec < ARRAY_SIZE(errors) && errors[ec][0] ) err =3D errors[ec]; @@ -2028,6 +2030,12 @@ void do_entry_CP(struct cpu_user_regs *regs) */ if ( guest_mode(regs) ) { + struct vcpu *curr =3D current; + if ( guest_kernel_mode(curr, regs) && curr->domain->debugger_attac= hed ) + { + domain_pause_for_debugger(); + return; + } gprintk(XENLOG_ERR, "Hit #CP[%04x] in guest context %04x:%p\n", ec, regs->cs, _p(regs->rip)); ASSERT_UNREACHABLE(); diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h index 99803bfd0c..cd6b9477f7 100644 --- a/xen/include/asm-x86/debugger.h +++ b/xen/include/asm-x86/debugger.h @@ -5,19 +5,12 @@ *=20 * Each debugger should define two functions here: *=20 - * 1. debugger_trap_entry():=20 - * Called at start of any synchronous fault or trap, before any other work - * is done. The idea is that if your debugger deliberately caused the trap - * (e.g. to implement breakpoints or data watchpoints) then you can take - * appropriate action and return a non-zero value to cause early exit from - * the trap function. - *=20 - * 2. debugger_trap_fatal(): + * 1. 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). * - * 3. debugger_trap_immediate(): + * 2. 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 s= tate * rather than the state which was in effect when we took the trap. @@ -49,31 +42,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 -static inline bool debugger_trap_entry( - unsigned int vector, struct cpu_user_regs *regs) -{ - /* - * This function is called before any checks are made. Amongst other - * things, be aware that during early boot, current is not a safe poin= ter - * to follow. - */ - struct vcpu *v =3D current; - - if ( vector !=3D TRAP_int3 && vector !=3D TRAP_debug ) - return false; - - if ( guest_mode(regs) && guest_kernel_mode(v, regs) && - v->domain->debugger_attached ) - { - if ( vector !=3D TRAP_debug ) /* domain pause is good enough */ - current->arch.gdbsx_vcpu_event =3D vector; - domain_pause_for_debugger(); - return true; - } - - return false; -} - #else =20 static inline bool debugger_trap_fatal( @@ -84,12 +52,6 @@ static inline bool debugger_trap_fatal( =20 #define debugger_trap_immediate() ((void)0) =20 -static inline bool debugger_trap_entry( - unsigned int vector, struct cpu_user_regs *regs) -{ - return false; -} - #endif =20 #ifdef CONFIG_GDBSX --=20 2.32.0 From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318634; cv=none; d=zohomail.com; s=zohoarc; b=LyHqZu0Pfmd+PQJx8Xfmid2I2LonGrZZGgik2zWNVkvAznPEVVQ+NyOf0GvTtowSiMw7SpbfWxCmoIV35R7fpJqiELxC4WZTSyAfqtavTigOb7LwcmE4/UBEuVN7WmTS2+2bH9NFGYVgqfpnwJmy+DNKmUD8ynZBglaiffDEyqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318634; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=8OBC9884kmwmCHY2iZR5n9BK6YWwg3ipAzzHcSbYvfU=; b=R4SxbONKQZqkAHZF73IB374rKpcBFI68ydAQQS9L7D3Z82HLQMqlXdHSVrlGWsX8NiiN69h7NTKFXCN4mEwy3XhWAN/ECd0IanxUdsCFyhS0nPutdwIcK9Lr8qT3cx6cgiqOzTEGWQDIALOcYB6Rso4eoor5VnurvA4K++0hnKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629318634680321.9029970374594; Wed, 18 Aug 2021 13:30:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168319.307350 (Exim 4.92) (envelope-from ) id 1mGSCR-0000Dz-8x; Wed, 18 Aug 2021 20:30:11 +0000 Received: by outflank-mailman (output) from mailman id 168319.307350; Wed, 18 Aug 2021 20:30:11 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCR-0000Dq-58; Wed, 18 Aug 2021 20:30:11 +0000 Received: by outflank-mailman (input) for mailman id 168319; Wed, 18 Aug 2021 20:30:09 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCP-000714-Nd for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:30:09 +0000 Received: from mail-pf1-x435.google.com (unknown [2607:f8b0:4864:20::435]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id bd9e6df9-4592-4715-ae5d-e603d1893426; Wed, 18 Aug 2021 20:29:53 +0000 (UTC) Received: by mail-pf1-x435.google.com with SMTP id 7so3368365pfl.10 for ; Wed, 18 Aug 2021 13:29:51 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:50 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: bd9e6df9-4592-4715-ae5d-e603d1893426 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8OBC9884kmwmCHY2iZR5n9BK6YWwg3ipAzzHcSbYvfU=; b=aYYTc19KeDyUYd0t94QMEaH6q9fhEci8qpdovRYZuUMY7fz+5XrpgsdGa9C7nQCexA WwQD17e3FIwPisFBSif8BvlJEa53NJD+W0uke4Z0OFQAO91yJwQ9hxN91eH3oxJiunYF EmVk0arSgSaNZn132JojeNDAPyPSnBHrbzkKvOYV66X2q1u4mTuPdXvHIquR3FlAKfZi fDNuIjfyVvypGwUSG109X7DP4Sr/XflCB8XafQiesYjaTJxE7bj/1HpjQkc8ZFo/2lgB WJwjELHXXXx52+w+LUrkPZBb/oHtDn+rEdFB5VL/w1MUNfcWw5mkeR9X3lqQCNCr4SES MfpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=8OBC9884kmwmCHY2iZR5n9BK6YWwg3ipAzzHcSbYvfU=; b=LSfprd0VcePxPBBkhNBw6ZheCDE1IjqivtQ9tDcImFIJbJrSNuUOnq2av9wmvBjIqq kzL4uARwN6yooJki9/sDt+mrJFYCYxPNyVcx9+udr6KmT6leSu/802+SlwP+BjZjPhfm SnxNvzawueXBP2zfMhzvdZmjyNzF76HYxKiIPW8DrNZsW0MfOZowOF1e+q5zKrWFc+eu cAXWNfaNJorM2slsuCW+1rwjeEDyIivaHNPUITs6XibDC9d9qnWuy/LWpc3GZecmF8Ys lz2mRZWi0zLJJ8WeHferywNnH4mvhT0GcQYIsi0ek33aST4g9RxwOOVinvSnmJVw2fxh GhjQ== X-Gm-Message-State: AOAM532Ju/jEbU+13swPyB/sCQyZrzctuO4RfsIcIc1GjDyO74aeYgbp g5ox3wxBEnNP1nk3whpUmBPNLbZ56fuMJYoC X-Google-Smtp-Source: ABdhPJwQBPt96fqTcpLeTFg1kVF+kEHwh8L6sFdo5h44QFmLMKaVmZZz0ny+bibgDTMn7Z4TIvOTAA== X-Received: by 2002:a62:b615:0:b029:3e0:20c3:181c with SMTP id j21-20020a62b6150000b02903e020c3181cmr11199194pff.62.1629318590543; Wed, 18 Aug 2021 13:29:50 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 3/6] arch/x86: rename debug.c to gdbsx.c Date: Wed, 18 Aug 2021 13:29:04 -0700 Message-Id: <9ab53497cdd52e3aeaeff8079d934dcee94d6479.1629315873.git.bobby.eshleman@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318635655100002 Content-Type: text/plain; charset="utf-8" This commit renames debug.c to gdbsx.c to clarify its purpose. The function gdbsx_guest_mem_io() is moved from domctl.c to gdbsx.c. Although gdbsx_guest_mem_io() is conditionally removed from its single call site in domctl.c upon !CONFIG_GDBSX and so no stub is technically necessary, this commit adds a stub that would preserve the functioning of that call site if the #ifdef CONFIG_GDBSX were to ever be removed or the function were to ever be called outside of such an ifdef block. Signed-off-by: Bobby Eshleman --- xen/arch/x86/Makefile | 2 +- xen/arch/x86/domctl.c | 12 +----------- xen/arch/x86/{debug.c =3D> gdbsx.c} | 12 ++++++++++-- xen/include/asm-x86/debugger.h | 6 ------ xen/include/asm-x86/gdbsx.h | 17 +++++++++++++++++ 5 files changed, 29 insertions(+), 20 deletions(-) rename xen/arch/x86/{debug.c =3D> gdbsx.c} (93%) create mode 100644 xen/include/asm-x86/gdbsx.h diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index fe38cfd544..ef8c2c4770 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -20,7 +20,7 @@ obj-y +=3D cpuid.o obj-$(CONFIG_PV) +=3D compat.o obj-$(CONFIG_PV32) +=3D x86_64/compat.o obj-$(CONFIG_KEXEC) +=3D crash.o -obj-$(CONFIG_GDBSX) +=3D debug.o +obj-$(CONFIG_GDBSX) +=3D gdbsx.o obj-y +=3D delay.o obj-y +=3D desc.o obj-bin-y +=3D dmi_scan.init.o diff --git a/xen/arch/x86/domctl.c b/xen/arch/x86/domctl.c index 26a76d2be9..a492fe140e 100644 --- a/xen/arch/x86/domctl.c +++ b/xen/arch/x86/domctl.c @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -33,20 +34,9 @@ #include #include #include -#include #include #include =20 -#ifdef CONFIG_GDBSX -static int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio= *iop) -{ - iop->remain =3D dbg_rw_mem(iop->gva, guest_handle_from_ptr(iop->uva, v= oid), - iop->len, domid, iop->gwr, iop->pgd3val); - - return iop->remain ? -EFAULT : 0; -} -#endif - static int update_domain_cpu_policy(struct domain *d, xen_domctl_cpu_policy_t *xdpc) { diff --git a/xen/arch/x86/debug.c b/xen/arch/x86/gdbsx.c similarity index 93% rename from xen/arch/x86/debug.c rename to xen/arch/x86/gdbsx.c index d90dc93056..adea0f017b 100644 --- a/xen/arch/x86/debug.c +++ b/xen/arch/x86/gdbsx.c @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include =20 typedef unsigned long dbgva_t; @@ -158,7 +158,7 @@ static unsigned int dbg_rw_guest_mem(struct domain *dp,= unsigned long addr, * pgd3: value of init_mm.pgd[3] in guest. see above. * Returns: number of bytes remaining to be copied. */ -unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) bu= f, +static unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(v= oid) buf, unsigned int len, domid_t domid, bool toaddr, uint64_t pgd3) { @@ -174,6 +174,14 @@ unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_H= ANDLE_PARAM(void) buf, return len; } =20 +int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) +{ + iop->remain =3D dbg_rw_mem(iop->gva, guest_handle_from_ptr(iop->uva, v= oid), + iop->len, domid, iop->gwr, iop->pgd3val); + + return iop->remain ? -EFAULT : 0; +} + /* * Local variables: * mode: C diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h index cd6b9477f7..ed4d5c829b 100644 --- a/xen/include/asm-x86/debugger.h +++ b/xen/include/asm-x86/debugger.h @@ -54,10 +54,4 @@ static inline bool debugger_trap_fatal( =20 #endif =20 -#ifdef CONFIG_GDBSX -unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(void) bu= f, - unsigned int len, domid_t domid, bool toaddr, - uint64_t pgd3); -#endif - #endif /* __X86_DEBUGGER_H__ */ diff --git a/xen/include/asm-x86/gdbsx.h b/xen/include/asm-x86/gdbsx.h new file mode 100644 index 0000000000..2b8812881d --- /dev/null +++ b/xen/include/asm-x86/gdbsx.h @@ -0,0 +1,17 @@ +#ifndef __X86_GDBX_H +#define __X86_GDBX_H__ + +#ifdef CONFIG_GDBSX + +int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop); + +#else + +static inline int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbs= x_memio *iop) +{ + return -EOPNOTSUPP; +} + +#endif + +#endif --=20 2.32.0 From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318637; cv=none; d=zohomail.com; s=zohoarc; b=CZedbn7y81LW/STm7/dx7h77D8SyUHre0DOK6qWSqKj26HpSW4AdNR7R0r4lVV5+hH9OhTkEXYFIv1jqd0xEZkIQLCcttdVFyba6/hecSs2miIUlJOfGJqBfZ6GCdmtAf3ZfYVCJr9TKim8ou7/rCNbUtdM2sedhzJranMjmUMA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318637; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=6A7J2MNGpc3g2fahO1l/wGJcP/R6g3oAioBf+kBOMlo=; b=JfDJvlU2ubkppswP/5QNq8aiwtKKDu8xtRn+XYr8Y62iXLKt4TFB+WdR90mvQHnIFw/IUkTPzWRSXdr95UwxQ0BPXGRi61MR4GiuF1+DY+9DQCv+7672zXFCqEpnTsmdwoOC1KLbSwwqXrpN0ePWDLx2Xn0p2tkXlbWqpzoqh9A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629318637527557.4908849647431; Wed, 18 Aug 2021 13:30:37 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168318.307339 (Exim 4.92) (envelope-from ) id 1mGSCM-0008At-0v; Wed, 18 Aug 2021 20:30:06 +0000 Received: by outflank-mailman (output) from mailman id 168318.307339; Wed, 18 Aug 2021 20:30:05 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCL-0008AF-T6; Wed, 18 Aug 2021 20:30:05 +0000 Received: by outflank-mailman (input) for mailman id 168318; Wed, 18 Aug 2021 20:30:04 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCK-000714-NK for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:30:04 +0000 Received: from mail-pj1-x102f.google.com (unknown [2607:f8b0:4864:20::102f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 5c334995-aa2b-41b0-b629-96c1f8662ac2; Wed, 18 Aug 2021 20:29:53 +0000 (UTC) Received: by mail-pj1-x102f.google.com with SMTP id nt11so3443944pjb.2 for ; Wed, 18 Aug 2021 13:29:52 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:51 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 5c334995-aa2b-41b0-b629-96c1f8662ac2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=6A7J2MNGpc3g2fahO1l/wGJcP/R6g3oAioBf+kBOMlo=; b=TIaHwSm0XnhYahj8GaB1Xwb09vEeyiF8cMGpgaPI5pCENrwZv15NKVYeS5yrbfe/g3 pao03g4UH6b01s6p3XCAduhPgjhXecwCQ3SkRjP+EeOFcYcRpNdQ/Pkfx74DNotveVYI szrEhUvnEHkFp6ws+5fO92c3b2JBsw3lRKtbjqEzvU3/jWHzpMKgJ/F+S4+H/Dm2nJoH P86R1ZvNKCv/qs2JmTx+DyXcPU0k2QEDueq3oKkCz061UHHKBSYirO669Qwng+zYAksI l2fRks4b5UWuYQXHOqHCnenQC1/tETW82eDTBbU3nS7D4iZnhQHsbwaZTO5kLL0uZhFT QONw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=6A7J2MNGpc3g2fahO1l/wGJcP/R6g3oAioBf+kBOMlo=; b=ekw2aHuqY5jFhrzzgjz8c2eu9leAT8p1+sX9HCh9j32zsPPi4Hr62XtQkO4Kue9OAO vYwiW2maNu0eBCDR1I1GlaFhx8ZXohM5/XZaIGa08RCBXPpA45X/HXDOTrulCbb2xRFt d6KBaCrBGfYcItMBV98QabMP7gFB1I7sloLxNHEzDLwqFjrEN3bnE4Lr3NrJyYKS6k95 v2+Phe0kWLOovA/kqKWDQMHbabG4E22pKnPefaLAoo231r3o+FsmNidsEuJWuRxtCqXI oj8js0h8itVn5QklQEq1KMwhDUnXD0hHW8u9ctpixAxo2NmmSa7mH6EyHMHVrVP/0g3v diuw== X-Gm-Message-State: AOAM530r16Vo9cftkSx2+ufRZ359Lp/rVGDiQICoBC7fH0t4Z/IaEC/a dyfzu7bJapFubvMVqPsbDpOdLoK4QQ/C/mqF X-Google-Smtp-Source: ABdhPJzwVN4slvHZh/0lxPIPp6llJx7b+APPSfqEQ/liaQQZ3i+8umorV432PQ3DU6l7BbvSO70Zmg== X-Received: by 2002:a17:902:da8f:b0:12d:a688:83b7 with SMTP id j15-20020a170902da8f00b0012da68883b7mr8688450plx.56.1629318591638; Wed, 18 Aug 2021 13:29:51 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 4/6] x86/gdbsx: expand dbg_rw_mem() inline Date: Wed, 18 Aug 2021 13:29:05 -0700 Message-Id: <7833b4a327212ff0fc816d17f91fa09291d6afc2.1629315873.git.bobby.eshleman@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318639733100001 Content-Type: text/plain; charset="utf-8" Because dbg_rw_mem() has only a single call site, this commit expands it inline. --- xen/arch/x86/gdbsx.c | 32 +++++++++++--------------------- 1 file changed, 11 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/gdbsx.c b/xen/arch/x86/gdbsx.c index adea0f017b..4cb8e042f9 100644 --- a/xen/arch/x86/gdbsx.c +++ b/xen/arch/x86/gdbsx.c @@ -151,33 +151,23 @@ static unsigned int dbg_rw_guest_mem(struct domain *d= p, unsigned long addr, return len; } =20 -/* - * addr is guest addr - * buf is debugger buffer. - * if toaddr, then addr =3D buf (write to addr), else buf =3D addr (rd fro= m guest) - * pgd3: value of init_mm.pgd[3] in guest. see above. - * Returns: number of bytes remaining to be copied. - */ -static unsigned int dbg_rw_mem(unsigned long gva, XEN_GUEST_HANDLE_PARAM(v= oid) buf, - unsigned int len, domid_t domid, bool toaddr, - uint64_t pgd3) +int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) { struct domain *d =3D rcu_lock_domain_by_id(domid); =20 - if ( d ) + if ( d && !d->is_dying ) { - if ( !d->is_dying ) - len =3D dbg_rw_guest_mem(d, gva, buf, len, toaddr, pgd3); - rcu_unlock_domain(d); + iop->remain =3D dbg_rw_guest_mem( + d, iop->gva, guest_handle_from_ptr(iop->uva, void), + iop->len, domid, iop->pgd3val); + } + else + { + iop->remain =3D iop->len; } =20 - return len; -} - -int gdbsx_guest_mem_io(domid_t domid, struct xen_domctl_gdbsx_memio *iop) -{ - iop->remain =3D dbg_rw_mem(iop->gva, guest_handle_from_ptr(iop->uva, v= oid), - iop->len, domid, iop->gwr, iop->pgd3val); + if ( d ) + rcu_unlock_domain(d); =20 return iop->remain ? -EFAULT : 0; } --=20 2.32.0 From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318644; cv=none; d=zohomail.com; s=zohoarc; b=j05fvjSijvdFK94dIuzUzciUHn5R9NWyF3XdPSEWlCwTVovZNZkc5nTx924qg/vdNzm42EdISVn6g6FmA53VsKAt0LOWg/zXmtpx7aT8TAl2HBrAchYnV5DNdmrEVQAgg4dLExsQ2s3ZpvYOzyUqSiEdE/ZFJZnyg4KZOI2LyrQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318644; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z/GxiSbRFRsqjM1uw03mp0aByMGfgJWL6sCEVLvY9yo=; b=kLWp16cxNUom0tnqnmcy9Gkwx0LzseP8U5stGqQVigmyid9qIKuOUPehBzfrYKCG8LGmudj1/QMmgpJzaOBI4M/v+ZH8HWK8t9FDW36cqtPoMMAiOQOo8jFc+rt7gy+2suZXgqAofY5sdueku8GfIydqVJfTkXY8LZPOWAiTULU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 16293186440351017.3425814463554; Wed, 18 Aug 2021 13:30:44 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168321.307371 (Exim 4.92) (envelope-from ) id 1mGSCc-0001Bv-1m; Wed, 18 Aug 2021 20:30:22 +0000 Received: by outflank-mailman (output) from mailman id 168321.307371; Wed, 18 Aug 2021 20:30:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCb-0001Bf-Tm; Wed, 18 Aug 2021 20:30:21 +0000 Received: by outflank-mailman (input) for mailman id 168321; Wed, 18 Aug 2021 20:30:19 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCZ-000714-Nh for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:30:19 +0000 Received: from mail-pj1-x102d.google.com (unknown [2607:f8b0:4864:20::102d]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 4b4ced5a-6ba6-4eb0-9b8c-d2c76a4780f5; Wed, 18 Aug 2021 20:29:53 +0000 (UTC) Received: by mail-pj1-x102d.google.com with SMTP id u21-20020a17090a8915b02901782c36f543so9696745pjn.4 for ; Wed, 18 Aug 2021 13:29:53 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:52 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 4b4ced5a-6ba6-4eb0-9b8c-d2c76a4780f5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z/GxiSbRFRsqjM1uw03mp0aByMGfgJWL6sCEVLvY9yo=; b=bNEzNoBCcyoAK1vJiNoO6HYZYgkeQut06KAvfvniipuPqmYAuSX3Cd6uywd43bzgW1 uxyUVgpQ9iRUvGqM1Njd3e3imSRX8UQGMv8dj0xa7LqAb5Dv+tu/GJlTQFZTgAfjbBVK W9OGFmaBcGHaoaI3vfUxLASnezZUoizdlL8gbazgu6Pvj/yMMCwytSGemwO7q76XbF0e RPtcRGlQXfBLkN1jJgNiTMoRv6SUYSBH1B4YvQVtCV2joSU6yQ+FJYn8BDqSYjO8SbaJ +08okqvWmh1uGCMfpS9cYQ3fPyrBkLwPXDcE00F0v9uOQQ645j9j+sD0NnxTb4u1PuY3 rFZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=z/GxiSbRFRsqjM1uw03mp0aByMGfgJWL6sCEVLvY9yo=; b=ZKKg+Y92kDslhwMeCJr3zEhHWV01SQfBb52LZRPw9yZaGKO1jUYJAprwkhdiYwGGiU PCsYDIOw/l/2JAtn4Hs/yHYjJfjd4cPCfXl1n3UbE6EsbRN2ggGkWFbFUJhh9tSNZYa+ hF9CeWdJNcwnAZb0cLAIv+gS1y1IjaDFX5rYNe/wu1qIZ6DtKw3CwUo5ZoYcE/cfH+T0 6ER8j4AzDhFOLS+jLmI/ZWriOUgBZL4eJL0SGNtg0dZ8Iaexx3vHtTQpSuQg/0qDHBAE zsLM2vsdMJ+hGIf5NElOwvECS8JeBW86N53FrwYvSP0NS3o0NkCh5l7Cwqx2AOE6SnEU XXGQ== X-Gm-Message-State: AOAM530+TBsDwY3sBqf5ZiVURU/vcsQXiaVQwxtjyIW0AVAIBSlWe0eb LSkRNzoCBiJ8HdBSX0F7cFJu+w3NT/Dqlixz X-Google-Smtp-Source: ABdhPJyh8DtEMy3Xiuo3daM/gznTddwqFpWtrZ++XTnWJWygJ9AvtiEbJaNHC8p/5fDfXZ//jrPBKA== X-Received: by 2002:a17:902:c406:b0:12d:d0ff:4a9 with SMTP id k6-20020a170902c40600b0012dd0ff04a9mr8611113plk.65.1629318592746; Wed, 18 Aug 2021 13:29:52 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 5/6] arch/x86: move domain_pause_for_debugger() to domain.h Date: Wed, 18 Aug 2021 13:29:06 -0700 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318644380100002 Content-Type: text/plain; charset="utf-8" domain_pause_for_debugger() was previously in debugger.h. This commit moves it to domain.h because its implementation is in domain.c. Signed-off-by: Bobby Eshleman --- Changes in v3: - domain_pause_for_debugger() is now moved into debugger.h, not a new file debugger.c xen/arch/x86/hvm/svm/svm.c | 2 +- xen/arch/x86/hvm/vmx/realmode.c | 2 +- xen/arch/x86/hvm/vmx/vmx.c | 2 +- xen/arch/x86/nmi.c | 1 - xen/arch/x86/traps.c | 1 + xen/include/asm-x86/debugger.h | 2 -- xen/include/asm-x86/domain.h | 2 ++ 7 files changed, 6 insertions(+), 6 deletions(-) diff --git a/xen/arch/x86/hvm/svm/svm.c b/xen/arch/x86/hvm/svm/svm.c index 642a64b747..84448e496f 100644 --- a/xen/arch/x86/hvm/svm/svm.c +++ b/xen/arch/x86/hvm/svm/svm.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -58,7 +59,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/x86/hvm/vmx/realmode.c b/xen/arch/x86/hvm/vmx/realmod= e.c index cc23afa788..5c4b1910a9 100644 --- a/xen/arch/x86/hvm/vmx/realmode.c +++ b/xen/arch/x86/hvm/vmx/realmode.c @@ -14,7 +14,7 @@ #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 e09b7e3af9..6fd59865c7 100644 --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -51,7 +52,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/arch/x86/nmi.c b/xen/arch/x86/nmi.c index ab94a96c4d..11d5f5a917 100644 --- a/xen/arch/x86/nmi.c +++ b/xen/arch/x86/nmi.c @@ -30,7 +30,6 @@ #include #include #include -#include #include #include =20 diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index d0a4c0ea74..5947ed25d6 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -63,6 +63,7 @@ #include #include #include +#include #include #include #include diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h index ed4d5c829b..8f6222956e 100644 --- a/xen/include/asm-x86/debugger.h +++ b/xen/include/asm-x86/debugger.h @@ -26,8 +26,6 @@ #include #include =20 -void domain_pause_for_debugger(void); - #ifdef CONFIG_CRASH_DEBUG =20 #include diff --git a/xen/include/asm-x86/domain.h b/xen/include/asm-x86/domain.h index 92d54de0b9..de854b5bfa 100644 --- a/xen/include/asm-x86/domain.h +++ b/xen/include/asm-x86/domain.h @@ -672,6 +672,8 @@ void update_guest_memory_policy(struct vcpu *v, =20 void domain_cpu_policy_changed(struct domain *d); =20 +void domain_pause_for_debugger(void); + bool update_runstate_area(struct vcpu *); bool update_secondary_system_time(struct vcpu *, struct vcpu_time_info *); --=20 2.32.0 From nobody Sun May 5 19:18:55 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1629318656; cv=none; d=zohomail.com; s=zohoarc; b=kZkpYe4I2YSBZzN051sV3c6pNMoWd9iAISePCuFwjYvDiESBolagroxbtl19465hb9BIoMYIH3tbHZGk4JDNjvzvSA4S59nPbGvQjd22KlZe9iv3ufVcBAgOLoyzXYQeaOEqbENvfMxOckO86TP47DVZZIe0e2No4esTKA/Sf1w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629318656; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mzhpzYQx8peh1hdfIxEJjNatsuoe8FeZa6ijWCK1xjE=; b=MVsvxKR7hjJRMTfPpG4WHex84u0ueg7nUK1C6GEyY6seUdDSvu604OnL6wy3UfxJNnxMFLopL7OqqOFcL60pracngHLn84C/XH8QgdNMrjDQXq/S61eIC7BkBCFZQAUaypr57Dr3AiugtY5P6Phka97ULepmPzwvVtwizFJFXcs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 1629318656422256.19816617019967; Wed, 18 Aug 2021 13:30:56 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.168323.307383 (Exim 4.92) (envelope-from ) id 1mGSCf-0001cD-Da; Wed, 18 Aug 2021 20:30:25 +0000 Received: by outflank-mailman (output) from mailman id 168323.307383; Wed, 18 Aug 2021 20:30:25 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCf-0001c2-8s; Wed, 18 Aug 2021 20:30:25 +0000 Received: by outflank-mailman (input) for mailman id 168323; Wed, 18 Aug 2021 20:30:24 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mGSCe-000714-Nn for xen-devel@lists.xenproject.org; Wed, 18 Aug 2021 20:30:24 +0000 Received: from mail-pf1-x432.google.com (unknown [2607:f8b0:4864:20::432]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 987880ea-60b2-4804-8cff-7b21d3fb1597; Wed, 18 Aug 2021 20:29:55 +0000 (UTC) Received: by mail-pf1-x432.google.com with SMTP id 7so3368494pfl.10 for ; Wed, 18 Aug 2021 13:29:55 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::1]) by smtp.gmail.com with ESMTPSA id h25sm663775pfo.68.2021.08.18.13.29.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Aug 2021 13:29:53 -0700 (PDT) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list X-Inumbo-ID: 987880ea-60b2-4804-8cff-7b21d3fb1597 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=mzhpzYQx8peh1hdfIxEJjNatsuoe8FeZa6ijWCK1xjE=; b=h4CssbkPRxoitKam7/BAJ4YSIkbQ5wgEJmqRDamJcE7VRRfD3gKOIrhe8dba7nvdcG JO/OTO50Hhffn4Umpq9ojl3V03aoRR1GNGIxxFq9zvKKj4mRLIimKh6SCJk4KwbIgT67 jg1h4NTO/yhv4RRs8TDmaogpTJx6qx8SV7ijUXV2UmX34ROA2Nvugc451XcdHP3zShf0 gdyLMDdgCehTZ4oNytgVAXoEo3NMB2lGpGW/fRzLDhPq/V+6xHB9mzSURLPWWeAtWUMm Isf6PRsLvjb3cKOacE8R4KxzyqDHnrPs/r0bEs25a371/Qnw6QqLu2WH7dGOLSWfGav+ qcDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=mzhpzYQx8peh1hdfIxEJjNatsuoe8FeZa6ijWCK1xjE=; b=tJdtfGvHFiqW6y4EYvjPRHZY58ccai7zuQLGKBhq0A8AywChA5Q8JDiwBVc+O2KAjA jkb6/UswL/P48+UwrQaZfSf/6HANWbBh1RxXdlEHRgOGA0bp1DBKwtTQpMD401UljInV nfSvr8VB92OK85hsZN7/XqRS04litUXs7KGn9NW6cn6wa1bD8lfgU8dW29o5fwuYVGc2 xDD5951DC+X6o3AO7BHANUVUdQyH2Nk/ZIagP9UmiJ5CbHys60xQ+IABbkaWWbl+R1kk UtpfnV/FzvrVBnDB2W3vzhbmT3jcQpg9BblU6HvS6xKjl5ybXHFWSrURo6I7IILVjtU+ KhWA== X-Gm-Message-State: AOAM532WiHJAW4BiaA48KfEBQlYalERvmtilS1/pXZ3c+mN9QBdJOuld cK81hqMfz/YvWP2qR+jp+76wmnwt+E1aCWnd X-Google-Smtp-Source: ABdhPJzSC9bUuemsB4if7L49hfh2BOsBCLPEaZDrpMrX0BOd6P+1gfwEGSXAxdUsbBvPto83tIMMEQ== X-Received: by 2002:a62:87c5:0:b029:3b5:f90f:c2eb with SMTP id i188-20020a6287c50000b02903b5f90fc2ebmr11339383pfe.28.1629318594044; Wed, 18 Aug 2021 13:29:54 -0700 (PDT) Sender: Bobby Eshleman From: Bobby Eshleman To: xen-devel@lists.xenproject.org Cc: Bobby Eshleman , Stefano Stabellini , Julien Grall , Volodymyr Babchuk , Jan Beulich , Andrew Cooper , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Wei Liu , Elena Ufimtseva , Jun Nakajima , Kevin Tian , George Dunlap , Ian Jackson Subject: [PATCH v3 6/6] x86: change asm/debugger.h to xen/debugger.h Date: Wed, 18 Aug 2021 13:29:07 -0700 Message-Id: X-Mailer: git-send-email 2.32.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1629318657599100001 Content-Type: text/plain; charset="utf-8" This commit allows non-x86 architecture to omit the file asm/debugger.h if they do not require it. It changes debugger.h to be a general xen/debugger.h which, if CONFIG_CRASH_DEBUG, resolves to include asm/debugger.h. It also changes all asm/debugger.h includes to xen/debugger.h. Because it is no longer required, arm/debugger.h is removed. Signed-off-by: Bobby Eshleman Acked-by: Julien Grall --- Changes in v3: - No longer introduces a fake TRAP_invalid_op for arm to consume, it is not necessary given the removal of the arm calls now precedes this patch. - Instead of defining prototypes that arch/ is expected to implement, this version simply #includes when CONFIG_CRASH_DEBUG. xen/arch/x86/traps.c | 2 +- xen/common/domain.c | 2 +- xen/common/gdbstub.c | 2 +- xen/common/keyhandler.c | 2 +- xen/common/shutdown.c | 2 +- xen/drivers/char/console.c | 2 +- xen/include/asm-arm/debugger.h | 15 ---------- xen/include/asm-x86/debugger.h | 15 ---------- xen/include/xen/debugger.h | 51 ++++++++++++++++++++++++++++++++++ 9 files changed, 57 insertions(+), 36 deletions(-) delete mode 100644 xen/include/asm-arm/debugger.h create mode 100644 xen/include/xen/debugger.h diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index 5947ed25d6..a540f0832e 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -62,7 +63,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/common/domain.c b/xen/common/domain.c index 6b71c6d6a9..a87d814b38 100644 --- a/xen/common/domain.c +++ b/xen/common/domain.c @@ -11,6 +11,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include #include #include -#include #include #include #include diff --git a/xen/common/gdbstub.c b/xen/common/gdbstub.c index 848c1f4327..1d7b98cdac 100644 --- a/xen/common/gdbstub.c +++ b/xen/common/gdbstub.c @@ -38,12 +38,12 @@ #include #include #include -#include #include #include #include #include #include +#include #include #include =20 diff --git a/xen/common/keyhandler.c b/xen/common/keyhandler.c index 8b9f378371..1eafaef9b2 100644 --- a/xen/common/keyhandler.c +++ b/xen/common/keyhandler.c @@ -3,6 +3,7 @@ */ =20 #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include =20 static unsigned char keypress_key; diff --git a/xen/common/shutdown.c b/xen/common/shutdown.c index abde48aa4c..a933ee001e 100644 --- a/xen/common/shutdown.c +++ b/xen/common/shutdown.c @@ -2,13 +2,13 @@ #include #include #include +#include #include #include #include #include #include #include -#include #include =20 /* opt_noreboot: If true, machine will need manual reset on error. */ diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 7d0a603d03..3d1cdde821 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -26,7 +27,6 @@ #include #include #include -#include #include #include /* for do_console_io */ #include diff --git a/xen/include/asm-arm/debugger.h b/xen/include/asm-arm/debugger.h deleted file mode 100644 index ac776efa78..0000000000 --- a/xen/include/asm-arm/debugger.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifndef __ARM_DEBUGGER_H__ -#define __ARM_DEBUGGER_H__ - -#define debugger_trap_fatal(v, r) (0) -#define debugger_trap_immediate() ((void) 0) - -#endif /* __ARM_DEBUGGER_H__ */ -/* - * Local variables: - * mode: C - * c-file-style: "BSD" - * c-basic-offset: 4 - * indent-tabs-mode: nil - * End: - */ diff --git a/xen/include/asm-x86/debugger.h b/xen/include/asm-x86/debugger.h index 8f6222956e..b9eeed395c 100644 --- a/xen/include/asm-x86/debugger.h +++ b/xen/include/asm-x86/debugger.h @@ -25,9 +25,6 @@ #include #include #include - -#ifdef CONFIG_CRASH_DEBUG - #include =20 static inline bool debugger_trap_fatal( @@ -40,16 +37,4 @@ 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 - #endif /* __X86_DEBUGGER_H__ */ diff --git a/xen/include/xen/debugger.h b/xen/include/xen/debugger.h new file mode 100644 index 0000000000..166fad9d2e --- /dev/null +++ b/xen/include/xen/debugger.h @@ -0,0 +1,51 @@ +/*************************************************************************= ***** + * Generic hooks into arch-dependent Xen. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; If not, see . + * + * Each debugger should define two functions here: + * + * 1. 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). + * + * 2. 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 s= tate + * 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 + +#else + +#include + +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__ */ --=20 2.32.0