From patchwork Mon Feb 5 13:20:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 126874 Delivered-To: patch@linaro.org Received: by 10.46.124.24 with SMTP id x24csp1970028ljc; Mon, 5 Feb 2018 05:26:29 -0800 (PST) X-Google-Smtp-Source: AH8x225/NQpE+Pd5M1HuHzVgGJE91JIdANzwidWxaaxIFIVDEoK/mebx9JoMV+w8Ri+wZn87Fb66 X-Received: by 10.36.71.204 with SMTP id t195mr8777222itb.102.1517837189581; Mon, 05 Feb 2018 05:26:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517837189; cv=none; d=google.com; s=arc-20160816; b=eP9kFawS816FL2N75h9bZx7LMbN8GTqAb0BtGUfPib9vWTsg2kTkxTOmE9/j9EiBqU EkUT45GAJzqLNFJaSEp012bz87hdUQ6PIyxWRUmiDqzI1Nr7ZOjsn/LdkDdM10pf6H1C ti+uWT+tkPuGoLUx3UCkAb50sixw6Ve4NmvLLfkMOEenUMkmrEIQUVCIvb5DyL2jsa8l dBvYsHNTYTI3SsYaM3azTdiQWm8m5TmavYcte1LyOubEs6CKLphmThour5paRhJCZn/f F0NzSkXbr9EqjguqK/RJzuCnysqU3U8PsL4jV3nfViSkWYawVFocgadhJoTAUXiSuo1k PDnA== 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 :list-subscribe:list-help:list-post:list-unsubscribe:list-id :precedence:subject:cc:references:in-reply-to:message-id:date:to :from:arc-authentication-results; bh=oFi1Xgx2tPakkrAndFxveD8mXOd7nGFVDyZScGCzG3g=; b=EDWWrvR1tdUfGZbeCoLEMAZK83Vw8l1k8A6URa+td0Ic3ISNjiYgscACH2LCMDHWjd TNYB2WTex1VYHyp6lJpEOGlYNpTRLsbk7MqPvHYAVfpRL+FLWwjyw1ifCfRm7C6BsMwq JP8OKWwGyadcQhuUor2EkOmAWK5HOLcTx0joPOMgUBCEzRQ4yF6Qq8e5JnIdMZZFYR6i wJ82Y5sbI884mZqFJ+7/t117bsI9hz3ZIuuskq/gKu4CBk00cbRMs27xf8mk8PrqPBBp iJ68vWq0yD+5WOv/5T1XkclvJMfU5+0maav9JBO68nBjDMgTgWTxrHfGaBQD40mbGfqX CXew== 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 s23si973937ios.196.2018.02.05.05.26.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 05 Feb 2018 05:26:29 -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.84_2) (envelope-from ) id 1eigkv-0008Rz-TT; Mon, 05 Feb 2018 13:24:21 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eigku-0008Rt-NN for xen-devel@lists.xen.org; Mon, 05 Feb 2018 13:24:20 +0000 X-Inumbo-ID: 6e39bee9-0a77-11e8-b9b1-635ca7ef6cff Received: from foss.arm.com (unknown [217.140.101.70]) by us1-amaz-eas1.inumbo.com (Halon) with ESMTP id 6e39bee9-0a77-11e8-b9b1-635ca7ef6cff; Mon, 05 Feb 2018 13:21:10 +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 CF15E1596; Mon, 5 Feb 2018 05:20:24 -0800 (PST) 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 E08A43F24D; Mon, 5 Feb 2018 05:20:23 -0800 (PST) From: Julien Grall To: xen-devel@lists.xen.org Date: Mon, 5 Feb 2018 13:20:07 +0000 Message-Id: <20180205132011.27996-6-julien.grall@arm.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180205132011.27996-1-julien.grall@arm.com> References: <20180205132011.27996-1-julien.grall@arm.com> Cc: Julien Grall , sstabellini@kernel.org, andre.przywara@linaro.org Subject: [Xen-devel] [PATCH 5/7] xen/arm: vsmc: Implement SMCCC_ARCH_WORKAROUND_1 BP hardening support X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" SMCCC 1.1 offers firmware-based CPU workarounds. In particular, SMCCC_ARCH_WORKAROUND_1 provides BP hardening for variant 2 of XSA-254 (CVE-2017-5715). If the hypervisor has some mitigation for this issue, report that we deal with it using SMCCC_ARCH_WORKAROUND_1, as we apply the hypervisor workaround on every guest exit. Signed-off-by: Julien Grall Reviewed-by: Volodymyr Babchuk --- xen/arch/arm/vsmc.c | 22 ++++++++++++++++++++-- xen/include/asm-arm/smccc.h | 6 ++++++ 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/xen/arch/arm/vsmc.c b/xen/arch/arm/vsmc.c index a708aa5e81..144a1cd761 100644 --- a/xen/arch/arm/vsmc.c +++ b/xen/arch/arm/vsmc.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -93,8 +94,25 @@ static bool handle_arch(struct cpu_user_regs *regs) return true; case ARM_SMCCC_ARCH_FEATURES_FID: - /* Nothing supported yet */ - set_user_reg(regs, 0, -1); + { + uint32_t arch_func_id = get_user_reg(regs, 1); + int ret = -1; + + switch ( arch_func_id ) + { + case ARM_SMCCC_ARCH_WORKAROUND_1_FID: + if ( cpus_have_cap(ARM_HARDEN_BRANCH_PREDICTOR) ) + ret = 0; + break; + } + + set_user_reg(regs, 0, ret); + + return true; + } + + case ARM_SMCCC_ARCH_WORKAROUND_1_FID: + /* No return value */ return true; } diff --git a/xen/include/asm-arm/smccc.h b/xen/include/asm-arm/smccc.h index 431389c118..b790fac17c 100644 --- a/xen/include/asm-arm/smccc.h +++ b/xen/include/asm-arm/smccc.h @@ -115,6 +115,12 @@ static inline uint32_t smccc_get_owner(register_t funcid) ARM_SMCCC_OWNER_ARCH, \ 0x1) +#define ARM_SMCCC_ARCH_WORKAROUND_1_FID \ + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ + ARM_SMCCC_CONV_32, \ + ARM_SMCCC_OWNER_ARCH, \ + 0x8000) + /* Only one error code defined in SMCCC */ #define ARM_SMCCC_ERR_UNKNOWN_FUNCTION (-1)