From patchwork Mon Oct 8 18:33:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 148434 Delivered-To: patch@linaro.org Received: by 2002:a2e:8595:0:0:0:0:0 with SMTP id b21-v6csp3982210lji; Mon, 8 Oct 2018 11:36:24 -0700 (PDT) X-Google-Smtp-Source: ACcGV60RodEfetXUjJpkwyESbQ08HPU0PPBEhUr9JZEusAUozJbQ1qhdX/xgEZHsqcXGS9VzFsl1 X-Received: by 2002:a6b:7312:: with SMTP id e18-v6mr15409536ioh.94.1539023783945; Mon, 08 Oct 2018 11:36:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539023783; cv=none; d=google.com; s=arc-20160816; b=Ng1ZWoUy+6W1gw5YcEiTlSGl0gja9lIO8P6eipWyXBFOqXwDUQhnpybyofOEXJcEmU 4aNi4zMxYQ5qhoGndXSpqefpUi9QOvTeYlAmg/Ylih4oLVmmxIReFT53TkJvdzft78dT 7m2bs07JL95vS5p1ReR1Px4f/ExTz0FEzRU9TciSNAL1A8lsoQZVPhCqvfwQaavGwskN aStk4HrfHNDrjXZt0IPK9wT7DUHyeg7LeXudZBoJPfsbtRJ89O6GW5QWx9Doqtd/tWpW hSCHkJYbnKljiUnQw04fGLIyrH5WzPbRy/IfeA5E+2SzlR1Kl00Xqfrh+qdg0/2EyMGF Us7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:references:in-reply-to:message-id:date:to:from; bh=QdrF4pMdsnwDL9BXNMuESblwcuju3HTGaAKCo+K0Z+8=; b=nIea9bTY83hzcFHTzjYwAmmZAVlLr9yA83cOJwmO5ihCUAPm4EblW0ASYtasw53wq9 9o5Ibkk08MCgICWg0NsIN3KpoQa+QBk8LrCpO7Kzyl47TM9A5zO4bRGDUyV+1t/rOdJ0 G+Xz2OOMuRFKOjD0rvpN5wm7deSYxvai46VyZH2czsepADIJJ9LlZJN75nuxMA/JJtSU KtbViPFQq4v9KWPwONPT7PPLW4Jhjbw60gbpU57KFM2zKghF6D2mV+zXk5+Tzcbizm9i k+UASX+C6l1XNLnIkTKcZdNXYI1cd6L4ycRlASliwCzxYnG+wHRnlQ/VhjFgs1jF1A0X yUmg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Return-Path: Received: from lists.xenproject.org (lists.xenproject.org. [192.237.175.120]) by mx.google.com with ESMTPS id v191-v6si1931875ita.72.2018.10.08.11.36.23 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Oct 2018 11:36:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of xen-devel-bounces@lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g9aM4-0005f0-Od; Mon, 08 Oct 2018 18:34:08 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1g9aM3-0005eU-My for xen-devel@lists.xen.org; Mon, 08 Oct 2018 18:34:07 +0000 X-Inumbo-ID: eb09c9ec-cb28-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id eb09c9ec-cb28-11e8-a6a9-d7ebe60f679a; Mon, 08 Oct 2018 18:35:23 +0000 (UTC) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id D06CDED1; Mon, 8 Oct 2018 11:34:06 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.196.50]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id E6A9E3F5B3; Mon, 8 Oct 2018 11:34:05 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 8 Oct 2018 19:33:41 +0100 Message-Id: <20181008183352.16291-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181008183352.16291-1-julien.grall@arm.com> References: <20181008183352.16291-1-julien.grall@arm.com> Subject: [Xen-devel] [RFC 05/16] xen/arm: traps: Move the implementation of GUEST_BUG_ON in traps.h X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" GUEST_BUG_ON may be used in other files doing guest emulation. Signed-off-by: Julien Grall Acked-by: Stefano Stabellini --- The patch was previously sent separately. --- xen/arch/arm/traps.c | 24 ------------------------ xen/include/asm-arm/traps.h | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c index 9251ae50b8..b40798084d 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -68,30 +68,6 @@ static inline void check_stack_alignment_constraints(void) { #endif } -/* - * GUEST_BUG_ON is intended for checking that the guest state has not been - * corrupted in hardware and/or that the hardware behaves as we - * believe it should (i.e. that certain traps can only occur when the - * guest is in a particular mode). - * - * The intention is to limit the damage such h/w bugs (or spec - * misunderstandings) can do by turning them into Denial of Service - * attacks instead of e.g. information leaks or privilege escalations. - * - * GUEST_BUG_ON *MUST* *NOT* be used to check for guest controllable state! - * - * Compared with regular BUG_ON it dumps the guest vcpu state instead - * of Xen's state. - */ -#define guest_bug_on_failed(p) \ -do { \ - show_execution_state(guest_cpu_user_regs()); \ - panic("Guest Bug: %pv: '%s', line %d, file %s\n", \ - current, p, __LINE__, __FILE__); \ -} while (0) -#define GUEST_BUG_ON(p) \ - do { if ( unlikely(p) ) guest_bug_on_failed(#p); } while (0) - #ifdef CONFIG_ARM_32 static int debug_stack_lines = 20; #define stack_words_per_line 8 diff --git a/xen/include/asm-arm/traps.h b/xen/include/asm-arm/traps.h index 70b52d1d16..0acf7de67d 100644 --- a/xen/include/asm-arm/traps.h +++ b/xen/include/asm-arm/traps.h @@ -9,6 +9,30 @@ # include #endif +/* + * GUEST_BUG_ON is intended for checking that the guest state has not been + * corrupted in hardware and/or that the hardware behaves as we + * believe it should (i.e. that certain traps can only occur when the + * guest is in a particular mode). + * + * The intention is to limit the damage such h/w bugs (or spec + * misunderstandings) can do by turning them into Denial of Service + * attacks instead of e.g. information leaks or privilege escalations. + * + * GUEST_BUG_ON *MUST* *NOT* be used to check for guest controllable state! + * + * Compared with regular BUG_ON it dumps the guest vcpu state instead + * of Xen's state. + */ +#define guest_bug_on_failed(p) \ +do { \ + show_execution_state(guest_cpu_user_regs()); \ + panic("Guest Bug: %pv: '%s', line %d, file %s\n", \ + current, p, __LINE__, __FILE__); \ +} while (0) +#define GUEST_BUG_ON(p) \ + do { if ( unlikely(p) ) guest_bug_on_failed(#p); } while (0) + int check_conditional_instr(struct cpu_user_regs *regs, const union hsr hsr); void advance_pc(struct cpu_user_regs *regs, const union hsr hsr);