From patchwork Wed Aug 18 20:29:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bobby Eshleman X-Patchwork-Id: 12445329 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6E7E8C4338F for ; Wed, 18 Aug 2021 20:30:45 +0000 (UTC) Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 16706610D2 for ; Wed, 18 Aug 2021 20:30:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 16706610D2 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.xenproject.org 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 X-Outflank-Mailman: Message body and most headers restored to incoming version 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-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_Pau_Monn=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 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 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 @@ */ #include +#include #include #include #include @@ -20,7 +21,6 @@ #include #include #include -#include #include 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 /* 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 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" ); -#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 state + * 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__ */