From patchwork Tue Dec 4 20:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 152847 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp8503214ljp; Tue, 4 Dec 2018 12:29:12 -0800 (PST) X-Google-Smtp-Source: AFSGD/VK6XR66djy/LJuEZD++BfVUQP6wVV7uUnztE3/J1Y9Jt6D/hQ20KJqkS6e+lgpwA9BfkK5 X-Received: by 2002:a25:1d56:: with SMTP id d83mr10284169ybd.392.1543955352572; Tue, 04 Dec 2018 12:29:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543955352; cv=none; d=google.com; s=arc-20160816; b=W5Fau9+Qkyh/6pSbVxuThUrQ5kEiylwbezOxCbHBs6QW+JZlJ9W8ZbWukgJ6OpvzJo cE3Rn2GYP3/emTW7LfdT4Ny6xig/0NkAPKZZM9rAyS+7eEFxasX+W1Jr1xH4wh5IgxjV DerRMrXCfPpWTXQBbWENbRumD7nUPcFmv8XrP6Zpl0ZBCb4Mp0T6ZXUaVPUEt/WQ9EwI rfYJ33I3yWoE6NQs4+EGQVFGFrbgnfZADtZ8C85ncoVJcDD9CRyAFJmylwO0wPPqUuBO yzW0EbulJuDwV7NtHh2L1gkXbzFsUZytjoxc/uXDJHTyznkNMENj8uIThGjvHRs1KK3Y C82w== 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=PIX8FJZyS6hUguf1SNJCP5pgvTf/WCu+V/GDgun9FHQ=; b=py/VEFELTEFfo4bu9uLMogOfFZhulBqInhmvmtO5XOqgGE3yAXgC/bONcRTM0AdOx8 VmkLHJo8v7Cr1HmTL/J4GKcQpI1rWbrBiMnN6zSbdSk6lTvmUXd29dzDS8DAlP6o4/Qa MBVsitNh5K5SB1+1jdwKvUEKZEPI1h1rE+esvVmUOV5IDZxEPlQN5glyrAunf1tr08rj gIV5koXEc9Xe2HmEHkHCmwrqcfiAidrN09WWb3OoRPu49l1qQVvdBkQmH53OmXlwNXEE w0t4vdS4bpIV1NDbQqvuHRB9nR5XRAFOCKTq3ffC0psvbc/UUlV1g11009Qjc4baAPpr p5uA== 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 x131-v6si10373252yba.249.2018.12.04.12.29.12 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 04 Dec 2018 12:29:12 -0800 (PST) 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 1gUHIP-0000F6-IM; Tue, 04 Dec 2018 20:27:53 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1gUHIN-0000Ck-JE for xen-devel@lists.xenproject.org; Tue, 04 Dec 2018 20:27:51 +0000 X-Inumbo-ID: 11acab24-f803-11e8-bfe5-4b39350725be Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTP id 11acab24-f803-11e8-bfe5-4b39350725be; Tue, 04 Dec 2018 20:27:50 +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 AC9D315BF; Tue, 4 Dec 2018 12:27:19 -0800 (PST) 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 E38623F614; Tue, 4 Dec 2018 12:27:18 -0800 (PST) From: Julien Grall To: xen-devel@lists.xenproject.org Date: Tue, 4 Dec 2018 20:26:36 +0000 Message-Id: <20181204202651.8836-3-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181204202651.8836-1-julien.grall@arm.com> References: <20181204202651.8836-1-julien.grall@arm.com> Subject: [Xen-devel] [PATCH for-4.12 v2 02/17] 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 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. Changes in v2: - Add Stefano's acked-by --- 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 c05a8ad25c..94fe1a6da7 100644 --- a/xen/arch/arm/traps.c +++ b/xen/arch/arm/traps.c @@ -67,30 +67,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 6d8a43a691..997c37884e 100644 --- a/xen/include/asm-arm/traps.h +++ b/xen/include/asm-arm/traps.h @@ -10,6 +10,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);