From patchwork Mon Jul 16 17:27:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 142082 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp2677793ljj; Mon, 16 Jul 2018 10:29:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeqd+VQSSNsmzVmO58YAFyo3acEOTNklBVL0ZpaF32xarNkVlzOFoWJykWV8HEdMTWZCNu9 X-Received: by 2002:a24:d442:: with SMTP id x63-v6mr14196568itg.152.1531762186203; Mon, 16 Jul 2018 10:29:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531762186; cv=none; d=google.com; s=arc-20160816; b=hdVB0g3cn/AmUrtSkiCZrLtSW5RYxinKj0o7Jg83PyIUAdZAQFrkocq5TVQEpaPl9m q6IaFa76KkfU/sRkONUPc5msnAwcn3Y8MSnlqKiZltHw13fmOmy9A6d10wyr3XgkJ4T+ GVrXVJ94oAULFPVHZGuRv6X0UAZUlDIVDWnDigBEX4xQ44TObAlWWdV/8YK7eTesQGoC MTbvv9Ls37BTgK1Xs2DNympzg55VqaQHy2619Teactci240A95IQg6Y4RKTGOlLWqxUr 6QjeGx9IIHfAqqvNJPgaj4OWoFedimSNXdp9BsqmVNQRqX+2DQFfq1ZdQeZNdliQHrey 33qw== 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 :arc-authentication-results; bh=j4VYrY5Ycp4iAWoKC7XLiqjnlAUNk9Pm224+VzH/F4c=; b=E/sh7+rQNAcPrui+6VjQEu76HWux5J+Cug4RnLDLzTdhivqZ2iiQuNEWQNJWAbvioL rEfA1yDMJkym94SviElVP+jo6uQOxlNLNGplhqlAiN/I/PQ8paoRrZn+gtLVcLJ2KmVO rk6mBvhrFLN6ClJ+vY1joqZ8bEQtRdjeLHrke+FPcI9dFZYA4w8IcR+xZMaFBZCbZr4+ K+Ut1MqXy4pNacrYGRTq7SHq9GjVzIHWMQYlHkdS4b6VjvNpczm0iOHPUM7dQ6KCmi5U gMoHf/XEG3TjMs6ebsXelO8XQ3anaeDSXfcwoSMo2G8qLRIe9p3XssRtgbICLjHyj95R uBcA== 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 94-v6si24577766iod.67.2018.07.16.10.29.46 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Jul 2018 10:29:46 -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 1ff7He-0006ee-2t; Mon, 16 Jul 2018 17:27:38 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1ff7Hc-0006cS-Ml for xen-devel@lists.xenproject.org; Mon, 16 Jul 2018 17:27:36 +0000 X-Inumbo-ID: 8d3ad9f9-891d-11e8-a6a9-d7ebe60f679a Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 8d3ad9f9-891d-11e8-a6a9-d7ebe60f679a; Mon, 16 Jul 2018 17:27:45 +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 950BF15AD; Mon, 16 Jul 2018 10:27:35 -0700 (PDT) Received: from e108454-lin.cambridge.arm.com (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id AB1453F5B1; Mon, 16 Jul 2018 10:27:34 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Mon, 16 Jul 2018 18:27:12 +0100 Message-Id: <20180716172712.20294-16-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180716172712.20294-1-julien.grall@arm.com> References: <20180716172712.20294-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH 15/15] 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, Julien Grall 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 --- 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 d1bf69b245..6751e4d754 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);