From nobody Fri May 17 07:07:53 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=1632861074; cv=none; d=zohomail.com; s=zohoarc; b=Fqx41j5N6COvGOSIxLZDf83dIvGoEnADW7yPI1TZQcquuQt3hLBmN5bKZsAvnkSRx1Ekb+V+Iow6DzKYgGnx5n5yjwRKhmZG1IwPNjzWLq7QrbqqPS2XkW1noh1djvAU52S0EDYpe3tzlWFjsv8vMbBcr61wORwf3niFINNp8Ys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861074; 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=aL1RPHC7XBP5oiIG2Dk/CszzAwTr4Nhvy1GqQ47WLc3cPYa5NVsmsx2h+yS2WzHN4kFdXbPNz9Qm8//WaEgmbURUSBQ8d0PuG3tBgvmlWpNAFuS1nPBvAIspXrpZU3S/oH2zswaEXH3Xtf56dAyMML3G8TZr3a5gIjtWzQIRQ/4= 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 1632861074976568.059340546347; Tue, 28 Sep 2021 13:31:14 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198415.351900 (Exim 4.92) (envelope-from ) id 1mVJke-0004fF-Mu; Tue, 28 Sep 2021 20:30:56 +0000 Received: by outflank-mailman (output) from mailman id 198415.351900; Tue, 28 Sep 2021 20:30:56 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJke-0004f6-I7; Tue, 28 Sep 2021 20:30:56 +0000 Received: by outflank-mailman (input) for mailman id 198415; Tue, 28 Sep 2021 20:30:55 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJkd-0004O5-8X for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:30:55 +0000 Received: from mail-pl1-x629.google.com (unknown [2607:f8b0:4864:20::629]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id c46b5e31-a2db-4dc4-8b19-4e4c8adf388f; Tue, 28 Sep 2021 20:30:50 +0000 (UTC) Received: by mail-pl1-x629.google.com with SMTP id l6so14980324plh.9 for ; Tue, 28 Sep 2021 13:30:50 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30: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: c46b5e31-a2db-4dc4-8b19-4e4c8adf388f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ymbhtWJDlmnuoU0qSCptZumb6o8HnxQbmRZItmihOOU=; b=hr3dpobqy60MQ0/xIdFAi4fhITENVYsP9/vWT8arSnZjQqR85SucjebewT3a7Cip7s rDz2XoyDlJmCsWxgBwPMh67obBCcuVDQDJFqFD4AkJXIx7vEYNWlsGX7WSOJls20gJqt 1HNSWnnW8fFDv0k9Ok0Uk7ElpDGUtqxbDhigXsUrgmjrgz41LHOls+/SBAxaXVRNEt+r H6CKHkmIcShaC4+G/UP2Y7Zlx4/8X0NDW1/tVAHqoGiiX/o1mWCZQfMQJW6J+/D3WbbC z7sJHI20GYgOSBHqaPrrUfGaWeTyT/dA3xqF5Ml1OPjB1yudTRnsliOlS9ajk/hAQ1uA vR/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=3CMAcHGQ8FwfLbpS0S16/jcB9p3aF2yRm10gU2JxzHO8/vblA9FPXZTE6a/mCO8+Zt rL5t37AgPY2zfTYwv8Jfx5RHlfP9HXiu5IGNy8TzXZnnGFJCRMDRgKdYtgK41XHGlRPj Km7TKLhC/wV+JThvtg9feVx5wIv9FNxTf7Om8krSvxWxX4OdUDq7XMkbwewdRwkgMqqy YOfLQGYpEuuiY+HBfuyYUAqCqwNpz4LC50jRDGqpghUJqBOXsXtwyoUTGs2nlcC4sZOy IQoYWLRWLLj+JeFtu1PZio9fivfSKrGyVSg7Yrj8xP+sBgo9CiKD7QjfEDMUHuEUVBtd WdlQ== X-Gm-Message-State: AOAM530O+KBlm/R810fkc6Ne7h4pRita7cM3eqv4JZYFl0pJaIJcMhZT gz6OXSADfeaZIxCSJ1r0V5SPBfPxUKgx7xRg X-Google-Smtp-Source: ABdhPJwHV0Vtsr8CP1xdXrs4yT4Ov+taT2HHe+f6VfNoQo38IkWERMKnhvVM8wpIKHE/y1MgOqA5kQ== X-Received: by 2002:a17:90b:17ca:: with SMTP id me10mr2070593pjb.171.1632861049495; Tue, 28 Sep 2021 13:30: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 , George Dunlap , Ian Jackson Subject: [PATCH v4 1/6] arm/traps: remove debugger_trap_fatal() calls Date: Tue, 28 Sep 2021 13:30:24 -0700 Message-Id: <4c4f45280547564b2c16fd9ca09443314b8f3b6e.1632860589.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: 1632861076636100001 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 Fri May 17 07:07:53 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=1632861077; cv=none; d=zohomail.com; s=zohoarc; b=IdKkbmjTkbZB01ZXIPf8xU+juu17Zodd1xC/W/+ZGpiTWrwc/PpBUEhAoYqNds4cBbTv3ejjY4oZEzTcRzoCD37t35KYkmnQW0WY14Z45gZtpjhjQt1t9Y5Odb/exWePeas08gaX82ENoY/RZG/2TKJesE0YSc7vYYd/hkLYAjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861077; 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=H5uWePdNAFApbwchB0lEmCcQHqVtRGoM5xxH6A0jNPE=; b=j7th4sfCksXUWuq3TgTejjJXCL+0aROSb82YF4lgckCwFmE0pF17cvjb4LtfEzV++XT+35o+rU6IStqv9/AF8H45fI65hnzT5ypcO82KA6390T6PrAlUFGkJ4xOj51+wecWBJC/jwzv2kW0irK94DrdE89ZMU2erD8lMYUxl/cY= 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 1632861077758624.0320964767822; Tue, 28 Sep 2021 13:31:17 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198416.351911 (Exim 4.92) (envelope-from ) id 1mVJkk-00051C-4V; Tue, 28 Sep 2021 20:31:02 +0000 Received: by outflank-mailman (output) from mailman id 198416.351911; Tue, 28 Sep 2021 20:31:02 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJkk-000515-1T; Tue, 28 Sep 2021 20:31:02 +0000 Received: by outflank-mailman (input) for mailman id 198416; Tue, 28 Sep 2021 20:31:00 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJki-0004O5-8W for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:31:00 +0000 Received: from mail-pf1-x430.google.com (unknown [2607:f8b0:4864:20::430]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 545b2fb6-0eea-4f78-a11d-edba8a427652; Tue, 28 Sep 2021 20:30:51 +0000 (UTC) Received: by mail-pf1-x430.google.com with SMTP id b68so1940566pfb.10 for ; Tue, 28 Sep 2021 13:30:51 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30: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: 545b2fb6-0eea-4f78-a11d-edba8a427652 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H5uWePdNAFApbwchB0lEmCcQHqVtRGoM5xxH6A0jNPE=; b=OU8kbq/6odgsBLbuRYNvQcjSGO1agLQ/zNMWt3bSZnEt/x0KR4ZZVBJKRp646+p6a8 wFLoSKNevE3pDOho2bHyMPS1QohH6VwQ6R1WCZtYiLmU5ut4kE4rwXA4w/vGHRvb6WoP 2RBltHjW+YpY/nrFOPiKeg6cEpX5j/U/VpIv2LZD/7jSKWkaWVkthLzp2pf0TshKol3Y dmMpIiW5f5OR0Wf9C8uZm7wUrzd9gDkVUV+jiHXxzy//i9yj2GB62tqiGPJJOJA9i1uF Pd5GsekypPhshYhKjGPlzo1iG1RCBeLMyK4MM1ENZXf1m75IMxj0x4kJTnmevCYlJoiA 9Adw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=H5uWePdNAFApbwchB0lEmCcQHqVtRGoM5xxH6A0jNPE=; b=2MySHqMZYEwtT/m7mTG5BNW+3j0/4sr1cXRVNcXF2y+xucQSYpQ0tS85xpI0FNLTTI 8KYKFzP09P4SdhOm4oPW1VvOKh0kKUCmTnGUHuRLyT7LZFequK/nq29YX0eeHN7qzCCL MQkP4bNp8y3aAfr3u/3c0xS5uwKAOCy8B2eRJpqTbOLICRIFMJM4GL0RyH1sSSanh0w4 y904VqdcFasakPrXEa+/RAgb3oD1BuLxA3IL7CA9n94AwCR0GNJ6SKK+VX3tevjhQZvf L/FOd/UqvsiKXtmmT02FhtwcDv/6AydOKDFfOp0fPCA+SP/H0re0iaHA//F8B75U62om k6IA== X-Gm-Message-State: AOAM5325TX0a9ai8ExhvZG097UPxKvxaNpkts7tWIGuDNIkgnDKgNxhA v0f0KSG7GQp6VMc+7jhkWKFrYH4Kna0wUHB6 X-Google-Smtp-Source: ABdhPJxz/2L818H7HQdZtDgvXYda6K8y0D3UwBb5Vo5vRi3oUcVuGZc0LXJGRokADf5XuTPMpykXTw== X-Received: by 2002:a62:7dd3:0:b0:447:dd44:1580 with SMTP id y202-20020a627dd3000000b00447dd441580mr7427104pfc.19.1632861050693; Tue, 28 Sep 2021 13:30: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 , George Dunlap , Ian Jackson Subject: [PATCH v4 2/6] x86/debugger: separate Xen and guest debugging debugger_trap_* functions Date: Tue, 28 Sep 2021 13:30:25 -0700 Message-Id: <47e32bf1eb0cd18210df4273d564fa17d389f3ae.1632860589.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: 1632861078699100005 Content-Type: text/plain; charset="utf-8" The functions debugger_trap_fatal(), debugger_trap_immediate(), and debugger_trap_entry() are generic hook functions for debugger support. In practice, debugger_trap_fatal() and debugger_trap_immediate() are only used in the debugging of Xen itself and debugger_trap_entry() is only used in the debugging of guests. That is, debugger_trap_entry() 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() many not belong alongside the Xen debug functions. This commit fixes this by expanding inline debugger_trap_entry() into its usage sites in x86/traps.c and stubbing out domain_pause_for_debugger() when !CONFIG_GDBSX. 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 --- Changes in v4: - Reword commit message for accuracy (make weaker claims) - Fix "if { return } else if { return }" anti-pattern xen/arch/x86/domain.c | 2 +- xen/arch/x86/traps.c | 50 ++++++++++++++++++++-------------- xen/include/asm-x86/debugger.h | 42 ++-------------------------- 3 files changed, 33 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..772e2a5bfc 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) ) { @@ -1216,6 +1219,13 @@ void do_int3(struct cpu_user_regs *regs) return; } =20 + if ( guest_kernel_mode(curr, regs) && curr->domain->debugger_attached ) + { + curr->arch.gdbsx_vcpu_event =3D TRAP_int3; + domain_pause_for_debugger(); + return; + } + pv_inject_hw_exception(TRAP_int3, X86_EVENT_NO_EC); } =20 @@ -1492,9 +1502,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 +1600,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 +1892,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: * @@ -1995,6 +1996,12 @@ void do_debug(struct cpu_user_regs *regs) return; } =20 + if ( guest_kernel_mode(v, regs) && v->domain->debugger_attached ) + { + domain_pause_for_debugger(); + return; + } + /* Save debug status register where guest OS can peek at it */ v->arch.dr6 |=3D (dr6 & ~X86_DR6_DEFAULT); v->arch.dr6 &=3D (dr6 | ~X86_DR6_DEFAULT); @@ -2014,9 +2021,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 +2032,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 Fri May 17 07:07:53 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=1632861084; cv=none; d=zohomail.com; s=zohoarc; b=jm2TlAYsN3TTcV0T6Iixcxq40VX4kU0i8oQ/7NXv5dB4q3slWKf5v2KzXX+HjDAchA2OpAvXXZ6nZxAa3znr622/aU/M00D+HXH2UQYslilscJXwMpYThvH61cltIo3Py4T3QSVQLJgRkOWvAQ40ETH1goTYGx+uxpRAUSIrudE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861084; 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=3cH5NMmmhhrKVlr9rQQI0c7DM+lnZiRUgrGaScpUArg=; b=b13t5ZubBh+5AykNhbcRPGHkcq2jDMIo1Ig6YdWS/WdcsGH7s2fCn4R79ypsWU6TPOp/FoO0eGmMUg5+UMBTNqx8ljCmiLGKPjDz8lMA3xWsrjVX0WBaEEYs8hJSeEzHvF9sDvwWQ6viGoR2KnaXa2N5FJdWzwASV4un6Cx6KPM= 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 1632861084292257.58452776411525; Tue, 28 Sep 2021 13:31:24 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198417.351922 (Exim 4.92) (envelope-from ) id 1mVJkp-0005Qz-GI; Tue, 28 Sep 2021 20:31:07 +0000 Received: by outflank-mailman (output) from mailman id 198417.351922; Tue, 28 Sep 2021 20:31:07 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJkp-0005Qm-By; Tue, 28 Sep 2021 20:31:07 +0000 Received: by outflank-mailman (input) for mailman id 198417; Tue, 28 Sep 2021 20:31:05 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJkn-0004O5-8a for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:31:05 +0000 Received: from mail-pj1-x1029.google.com (unknown [2607:f8b0:4864:20::1029]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 1e1b3f39-e5a9-43d1-aa06-bc1981eaae04; Tue, 28 Sep 2021 20:30:53 +0000 (UTC) Received: by mail-pj1-x1029.google.com with SMTP id kn18so2846331pjb.5 for ; Tue, 28 Sep 2021 13:30:53 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30: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: 1e1b3f39-e5a9-43d1-aa06-bc1981eaae04 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=3cH5NMmmhhrKVlr9rQQI0c7DM+lnZiRUgrGaScpUArg=; b=MIwX4bL4cVoR5aRrDq6die7FAJDBGUpZdW1160GnVJ8yqc3g22G9120i7ZUT0ZlJCW GTE/j7wTTcWgOsbdmQQwA3g3GeKLZa3+aMkhnGMpN0NgPD9Sbo4FpyRqWjvnp363KTyS aiNoDK/AnsJGgB/ZjeIg4OcAGC59R8CkHpa3coNOVSXUI60uOF2YQyldH3hcrkmx/NaN Ls9sQKjAGKuyU8IgS8XIQmNXbL0LEIuorTSlPL7gvMFJ3TRdmoELARs0ubn3SwJvwCvD NZG8dNMy57Wua1xE63bM7SUL8NPSdF8W1Wzs8LD2/KqKdmRbrBVerAfR4mY9hDQf/TSA Tqng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=3cH5NMmmhhrKVlr9rQQI0c7DM+lnZiRUgrGaScpUArg=; b=vCeQn2UyLkpgW8ceEONqKrmZUgpxuxrGQ9q6ZpyNzp8jSOdlJGEHSD1909YPAsDMtF 01fmd5QXpoCFlvJXOiUetdSFxLHgl/X9AFAd3bcYNBuXlZRdJzLT83mB9+63bKtdpjuy os4p2tknOBXGdfUNGwJTJNIAYuQOTqgkiE+aZSzUjBPq6AapFuB4WPpvsdjStr63t/z6 sicMtrQJt762iyTwhsyZZC0s2qvTvkAA9japv2Dira1WzuYJ2u6gFgYBtRXLngGlXcgH MKG64p3bl3ArKmvd/6fAMhUYhaAX/Pl6KB+hQ9AncGVW+uapWB08gh8oyVLUYEB1uK19 qq4g== X-Gm-Message-State: AOAM5329xsZeTmxodGgitdFtCdoxrOROYDuOQC0ZNQn4bh4eSKb7Q3TM 87/RsjrOuqy6YKwoIcJDe2/Rcsoq0t1MVqdl X-Google-Smtp-Source: ABdhPJxlhP9wJVBhJuh8dHrjEZf/bP4hh4MfpGHaHA7u6jZFR1drBojqRdGgD/wzzQbgbQQvae6JtQ== X-Received: by 2002:a17:902:7c17:b0:13e:2dd5:e5c4 with SMTP id x23-20020a1709027c1700b0013e2dd5e5c4mr6932711pll.68.1632861052219; Tue, 28 Sep 2021 13:30: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 , George Dunlap , Ian Jackson Subject: [PATCH v4 3/6] arch/x86: rename debug.c to gdbsx.c Date: Tue, 28 Sep 2021 13:30:26 -0700 Message-Id: <389ae979063a4afc38d8dbadaf539e7f411a24ba.1632860589.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: 1632861085378100002 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 --- Changes in v4: - Alphebetize Makefile addition - Fix broken header guard - Include errno.h in gdbsx.h 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 | 19 +++++++++++++++++++ 5 files changed, 31 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..9fa2ea9aa1 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -20,7 +20,6 @@ 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-y +=3D delay.o obj-y +=3D desc.o obj-bin-y +=3D dmi_scan.init.o @@ -32,6 +31,7 @@ obj-y +=3D emul-i8254.o obj-y +=3D extable.o obj-y +=3D flushtlb.o obj-$(CONFIG_CRASH_DEBUG) +=3D gdbstub.o +obj-$(CONFIG_GDBSX) +=3D gdbsx.o obj-y +=3D hypercall.o obj-y +=3D i387.o obj-y +=3D i8259.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..473229a7fb --- /dev/null +++ b/xen/include/asm-x86/gdbsx.h @@ -0,0 +1,19 @@ +#ifndef __X86_GDBX_H__ +#define __X86_GDBX_H__ + +#include + +#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 Fri May 17 07:07:53 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=1632861085; cv=none; d=zohomail.com; s=zohoarc; b=LFOCEjaooEr2uNQmC1PDO+MAuWALuyx6FcVTfY20lYFJ0MdnjkhxLuAAEfvKg+FCvY5DFP5F4Z0AhKgn1JC3rBqlpf+AZqEmErFiNSDpGWY+gQO1Yy8g8AssFWTWQLC0ev6Y8d34pfGLrAkG6k/OZnHTZNI6nVfYkk/DK2ssYc0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861085; 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=l4OVntz5YtvdVmlmtqYpHPgYE8ss+lH0o06oBOChZro=; b=Rp8XtS2Z7sM0m/BHjFbWcX8wbsJSq75AvEf8pBgJ289aYUIHocShDjMgehqSSC+GG6CAF0wXdYhGWjflxoDZiTK3JBSotGG3PRXUu57mi34VJj/xOOAo6vspe926dTQRWetS4rEmT+sb1wEsKPiYzamOfvB9NGo1MkfJWS2j42M= 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 1632861085032367.03775375290115; Tue, 28 Sep 2021 13:31:25 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198418.351933 (Exim 4.92) (envelope-from ) id 1mVJkt-0005sK-OG; Tue, 28 Sep 2021 20:31:11 +0000 Received: by outflank-mailman (output) from mailman id 198418.351933; Tue, 28 Sep 2021 20:31: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 1mVJkt-0005s9-Kl; Tue, 28 Sep 2021 20:31:11 +0000 Received: by outflank-mailman (input) for mailman id 198418; Tue, 28 Sep 2021 20:31:10 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJks-0004O5-8v for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:31:10 +0000 Received: from mail-pf1-x42b.google.com (unknown [2607:f8b0:4864:20::42b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 78580ae5-8e8d-4452-b28d-b3fc6525a363; Tue, 28 Sep 2021 20:30:54 +0000 (UTC) Received: by mail-pf1-x42b.google.com with SMTP id n23so15363pfv.4 for ; Tue, 28 Sep 2021 13:30:54 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30: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: 78580ae5-8e8d-4452-b28d-b3fc6525a363 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=l4OVntz5YtvdVmlmtqYpHPgYE8ss+lH0o06oBOChZro=; b=q8F07rbAtlARTMyYiUPOm4yjeaBuF2S8aiD0hqdDsNYCRCZVqvGispWehmLcZxVwVl AsBpzR8uUaYwyaUqYDCWEupSDoj19lYbk4IX1Z55FLLzbXLjfi3eNTl+RIMQ/3cmSn/k HRbnbHHsXxFrtUREZRcFIO58VxwQC5tnT6TneKpocP8rVM451qHDvrTG2Zl+On5zBMpb cRWF5o2o+qw3H/ZNgtGDIZOwXOs0MOYQLFpawLWi0HNbHQhyikWtekMlLoi25EDmT9iy 5hFIt0LxoumBW4XJoqjG5NiQt7b6Rn66usK/E5vQ4s9+mZGUL0E/tda4FAWlNflo6Y69 YUtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=l4OVntz5YtvdVmlmtqYpHPgYE8ss+lH0o06oBOChZro=; b=IgaBcWmhA/eLS378Xr72vvqF0M2ZGm2r7s6DcMBP/cnMFSnI8ee7QUXs0njIbWxhIJ NQmzol5cDGX1ONZNE3ndyIrHwX6AIhgaEpSCWtuNctmZvf3gUaLtgkvHgfONLV587uqj aq9T0YDmA074PkXubZBPNR3wnLIE6FJtH1JYBLNhmKdPXTwsPzv0iywnre+0KDq1FKAa TgftaMhloqKCt790PB+lY+BqeNRtAYuo5z4hnjrWQpLGb/YEuEZdwGsqA9za4G46/1WJ jZPQ7eqZnQkMAsB3xEcIB2ltO5CjnXEIhVSV+kRautvkvz5dCxyp54iDU0sZx7F57U3u he6Q== X-Gm-Message-State: AOAM532WuBH5C9OOVCVN5zJkt0NGm4kw9xLZk5JLFzmXavwLzidrtURo 5P/2Ev7vAywGtcxQOi9mtj1lsj2LFH7DxCxs X-Google-Smtp-Source: ABdhPJzKTkAV1Mkw5cnVcJddv8t7cBFdUB0I737XGLV/GUex1rPODiz9G01QHQf0VBWiE0Wt3nqEjg== X-Received: by 2002:a63:24a:: with SMTP id 71mr6307537pgc.285.1632861053496; Tue, 28 Sep 2021 13:30:53 -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 , George Dunlap , Ian Jackson Subject: [PATCH v4 4/6] x86/gdbsx: expand dbg_rw_mem() inline Date: Tue, 28 Sep 2021 13:30:27 -0700 Message-Id: <472215cdfa754634f8070386bb3122bf3e3cedc1.1632860589.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: 1632861085371100001 Content-Type: text/plain; charset="utf-8" Because dbg_rw_mem() has only a single call site, this commit expands it inline. Signed-off-by: Bobby Eshleman Acked-by: Andrew Cooper --- Changes in v4: - Add DCO xen/arch/x86/gdbsx.c | 30 +++++++++--------------------- 1 file changed, 9 insertions(+), 21 deletions(-) diff --git a/xen/arch/x86/gdbsx.c b/xen/arch/x86/gdbsx.c index adea0f017b..9c8827c6c4 100644 --- a/xen/arch/x86/gdbsx.c +++ b/xen/arch/x86/gdbsx.c @@ -151,33 +151,21 @@ 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 Fri May 17 07:07:53 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=1632861089; cv=none; d=zohomail.com; s=zohoarc; b=Mv8srOFO+0Zka6J1DlAYEoQnHxqrR3oFN/GS2ijnsa7nnBrlifeUcMBk5Cjs+bkE5RCxpDLXgPIghi+P69gxL+Y/NAuJUmb5NRb/sSNqpy1d1zPoV1iK3AIcMfyErsjnMgvLDThnMR/kk+IKgqHoKpiQ/3ESWZeCVnzEyl703Xk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861089; 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=iOTjHkk69+BVgT4XjnVLkopnx7Nv/jMSlcVqlEzwOf4=; b=NBxHCyE1LW7upy96kukbB+RqCLvlCI1E9EDFWerVx2u52PcNQJ1qm65LWH85ei+ZiBSxQ0MyGPoWpWnBwWohM1ToPlZlJ/NcV2TRse4nn4rkEvyeRRVcH0fAmpxTEht5T6qOvTRlMvnbUDUMK6QEcDqjX+DWPR4pF1aPo3GuUFA= 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 1632861089976593.4851030586829; Tue, 28 Sep 2021 13:31:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198420.351944 (Exim 4.92) (envelope-from ) id 1mVJky-0006H9-41; Tue, 28 Sep 2021 20:31:16 +0000 Received: by outflank-mailman (output) from mailman id 198420.351944; Tue, 28 Sep 2021 20:31: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 1mVJkx-0006Gl-Ta; Tue, 28 Sep 2021 20:31:15 +0000 Received: by outflank-mailman (input) for mailman id 198420; Tue, 28 Sep 2021 20:31:15 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJkx-0004O5-9D for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:31:15 +0000 Received: from mail-pj1-x102b.google.com (unknown [2607:f8b0:4864:20::102b]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 3abad95c-4747-4e64-8b3d-839af013ab0a; Tue, 28 Sep 2021 20:30:55 +0000 (UTC) Received: by mail-pj1-x102b.google.com with SMTP id on12-20020a17090b1d0c00b001997c60aa29so2589570pjb.1 for ; Tue, 28 Sep 2021 13:30:55 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30:54 -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: 3abad95c-4747-4e64-8b3d-839af013ab0a DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=iOTjHkk69+BVgT4XjnVLkopnx7Nv/jMSlcVqlEzwOf4=; b=ixGQGSdM1o7e/kVIG+47VRcbnwP/vXS0o8jMQexxab0GzYf8PJNNWViiyQKF52ALca j4oGXHHOTtMJzG5g/hLNhLFXTERigp4f+CI2c3e2jHPdxPnjKffk5O+HONJ3NHExE1iT ASJZTXQnJ0KGEZoDGy+1nw1ikTkNyxO7RsXqbJrVygFa84P2DxMDgGV6IvyUOZIy2SxH 8NqzI5MVwg8mOtj2ASKCAKWVxWdIg93BrmAPu828QfCrm7PF3et0N24cubRHJ+reX2wU sFmAcm0iJ1R5Rr7T2rgqIoOrfkm1tpl61hqGbGwH+0NrVbiKa4PcXY0WA2NI49/1R08M nTuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=iOTjHkk69+BVgT4XjnVLkopnx7Nv/jMSlcVqlEzwOf4=; b=d6tCFfaHEhxiEM1XI7AKx3oNc/JTSXMwNnWzM1kIioWBe5gUzFb/QxTKDD8cjI51tR Gx54k1pUi2Uc6Q0PKxGWMwJmoz0ljFqeZMGZFKoJBzZnSb7vOtriWKKJEO6iwE48Fous Wju90TSo7gLR4UcseRocEc5tzp0mIb+sMn+cnjkDmWyyS9KQV+ZBihIiUTjpyQ1gP2J2 KFP+iCZWJbaOMbIgZiOoe202BKZLilVlbVBnO9/HZadsBPFKi+S20wMDsxFZpst4dqXC EpXSdAOW53lXA4AGOJzu7BVDjRMQ7cxEZV4pZdCZsjxvE5lEUyVXzA+twPmR/Iu0/COR s10g== X-Gm-Message-State: AOAM53305xQd0LINvXmensioMEeiAyZvUj88ecK14ykhww+N5Ryc1XbC Z6EiRKSzdOCy9kMG4IrHV4OBtpqqKHHN3C99 X-Google-Smtp-Source: ABdhPJymLtx9yWhdUPkYTejlM8Zfr8ITa+y4p33yqB84Ts+javy1zYt7RsZzAu8n9wjVBBspMqjfpg== X-Received: by 2002:a17:902:bf8c:b0:13e:2b58:c2af with SMTP id v12-20020a170902bf8c00b0013e2b58c2afmr6916505pls.74.1632861054943; Tue, 28 Sep 2021 13:30: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 , George Dunlap , Ian Jackson Subject: [PATCH v4 5/6] arch/x86: move domain_pause_for_debugger() to domain.h Date: Tue, 28 Sep 2021 13:30:28 -0700 Message-Id: <5de82c39ffae1d65c8ab7142b05d304f9d4ddae9.1632860589.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: 1632861091811100001 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 Reviewed-by: Andrew Cooper --- Changes in v3: - domain_pause_for_debugger() is now moved into debugger.h, not a new file debugger.c Changes in v4: - Don't unnecessarily include 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 ++ 4 files changed, 2 insertions(+), 4 deletions(-) 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 772e2a5bfc..742fa9e2ca 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -62,7 +62,6 @@ #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 Fri May 17 07:07:53 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=1632861094; cv=none; d=zohomail.com; s=zohoarc; b=SQVo+wYJ+NXCd7uOKrZaWhibllPKYECeMoB8n6Wh8B99Wg5APCyBkFV37vO1ClaG8WrhVYTO8GG+S7CiL6cGt4oGn46ywoPlGIrcXs66QrmVu9HD1hyqOtILySGmfEeAmQaQZt2yp7fNGkR2j+NFtykiO1/lGrwSZOElinkI5TM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1632861094; 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=er5faQ/st6GZye51adynMEU5HSlpMR7iwTJec4b9TtQ=; b=mFud+0pJwW8rb9so1kYqFdJ9nSA1v6f1+LOPBCR6S2EiY5BfWowvvXyry157V7Nc01YhSPMfKQ/o3C9/EvH65WE8QfYofxcOsWHaPzPxF2UkyaIMMKzkfQLKKtTthTaSc8ghnl0rs/2CFStCf+ajR+nhF62DbndrffJ/HINNd78= 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 1632861094977549.9886862111271; Tue, 28 Sep 2021 13:31:34 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.198423.351955 (Exim 4.92) (envelope-from ) id 1mVJl3-0006tJ-FP; Tue, 28 Sep 2021 20:31:21 +0000 Received: by outflank-mailman (output) from mailman id 198423.351955; Tue, 28 Sep 2021 20:31:21 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJl3-0006t8-Bs; Tue, 28 Sep 2021 20:31:21 +0000 Received: by outflank-mailman (input) for mailman id 198423; Tue, 28 Sep 2021 20:31:20 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1mVJl2-0004O5-9I for xen-devel@lists.xenproject.org; Tue, 28 Sep 2021 20:31:20 +0000 Received: from mail-pf1-x42f.google.com (unknown [2607:f8b0:4864:20::42f]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id ad3a4beb-484e-4986-b3e6-d1314893e9a2; Tue, 28 Sep 2021 20:30:57 +0000 (UTC) Received: by mail-pf1-x42f.google.com with SMTP id w19so19832006pfn.12 for ; Tue, 28 Sep 2021 13:30:57 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:4c02:4c00::5]) by smtp.gmail.com with ESMTPSA id p15sm44201pfn.31.2021.09.28.13.30.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 28 Sep 2021 13:30:55 -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: ad3a4beb-484e-4986-b3e6-d1314893e9a2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=er5faQ/st6GZye51adynMEU5HSlpMR7iwTJec4b9TtQ=; b=o85TT2UfMEB+cmfXfH4HpYaImrks1IEaD2YggbPCmcwkX9St2K8GM9HI9JyW2Yj0Hr g0p6meZ1346IppM4mS0I7rXJ+KGkorCm3594/SQAQJafbuORffI4kzanmc9pHNITfxXJ sLvvznt1/Qsd4TCUP/kYJJ57eigIqtg2QZEE5aNc9xzPFQPHB2aCHovOND/TMOZbV0yd zjM512H29H+ooNuLUMCnM3vPcv2Mxmwa4spCgR4Jnunzu6/AwzQncwF7a66b7bhrKAHz tt5J2vdvHVroEuJA8lnCs43rPN8LS+bV777aP3kTnxzx2OsskhcR7kS5mzQr9n1j+4Pq 1vmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=er5faQ/st6GZye51adynMEU5HSlpMR7iwTJec4b9TtQ=; b=YVKH3UyHBRAm+SfliQJxU6wre/HxVD2NBKxmQO/KhITvfASJ880Ng3GReD1MlI+L9j QSvRyLlZUP4P7/2YwRTPXQ8/ZQFbpSeugksh0KUpNSAwrPFoWAlrlzI0V2RZib1ph+k0 zSBINFqPYrIrTGd5DqR4z4gOdklS7Br7Lb3HnoGmqua4ftLdmENv4WzJ2Fondw73xYKp f8xPmYEzYDRX7Sl6gD/21cNEHv13hf4cONl5fjoTDHd/FuOb/r+SmekT3VD1uKhntNOw hSq1M6oJcCWflelUicqmSjqk+ZwBQj/E2gWU0p7SGQo2+8DbW5EqIEodRZV3rhzcPtyw eGwg== X-Gm-Message-State: AOAM533fo6CucR60qcYs8tgypfVw8VG52Al4wF0k2ZT+W+dswG0dPRCi DI+eu1AVs161bVLYRCLlfFVnEV/lSlqvCykI X-Google-Smtp-Source: ABdhPJxiI0TvKS/plq0MCTX0bETK0mqEoV9I6fx4ued2x3fw34vZ90o7HgedhDr+VfoqMwzxvzdthg== X-Received: by 2002:a63:3408:: with SMTP id b8mr6418520pga.340.1632861056227; Tue, 28 Sep 2021 13:30:56 -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 , George Dunlap , Ian Jackson Subject: [PATCH v4 6/6] x86: change asm/debugger.h to xen/debugger.h Date: Tue, 28 Sep 2021 13:30:29 -0700 Message-Id: <8c340b24b41af349069ad55e1f0421e17fad1d6f.1632860589.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: 1632861096199100001 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 --- Changes in v4: - Replace #include with `struct cpu_user_regs` xen/arch/x86/traps.c | 1 + 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(+), 35 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 742fa9e2ca..36d7fc6238 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -35,6 +35,7 @@ #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..ddaa4a938b --- /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 + +struct cpu_user_regs; + +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