Received: by 10.223.176.5 with SMTP id f5csp1729782wra; Sun, 4 Feb 2018 10:40:31 -0800 (PST) X-Google-Smtp-Source: AH8x224HSGo5uDP0dbSzjlRMMqOzUoa8NT986KBYcr4M1mnKNWr5LZDAo/pmrLESdomTbO5QVXMN X-Received: by 2002:a17:902:2803:: with SMTP id e3-v6mr9648768plb.447.1517769631335; Sun, 04 Feb 2018 10:40:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517769631; cv=none; d=google.com; s=arc-20160816; b=db2SeNrYpKNbEiVFNtooBLJRJPqQNu02gmIkLYoB2m0Mo2yJ6vmOh6PM14yo0QJm1m mRl6TavIzvVjzelgEL6zhyQTwURUdXPqMHuwBKiDSq9YCnHuOZD0vRojeOjVGMEsmS5/ c5uZkZwEj7TwFGxCT5Hh/wMoLo6NNPEWfyySjLTlpHSzZ3Yw6f579zXZNqyoCCPzRTnB p9/tV3IzR6joHSrGcWqusQfubgCyfEy992+pspIKUA0WH9IK8y+45Afwr0SToFmi0fj/ AydjzRo+AE/PBNUszL89qJlJrhOXUgWzgGSMVePIiHYhGThuGA5lFdcaa//ZojcGZ9IO iG2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature:arc-authentication-results; bh=DpgdlX7ihpVD91PUh2JN0SwqbFCGQMZnOW4PKksakgg=; b=Fi4YzM7tRZEw0IA6UulBSdiu/RwVGARz6iePnS1kP7/NRGAtAD1MWtulJR1DGhQcm/ Fcn3kf8gX2o7upIcSfM+Xw5oabiL79W0UbF4G+0UZhAUnIhJpubVgIeThNA6QDQLi/e1 0Fx5UveSkZo4jD3Usgliq2bowcGjVtVdaaUoLeZRo0/uC9Hf8FWXIaIsFGG6pfdFqFBp M5Aujtx8ZAAuh5g/KtNeDW2/gsMQAESEDOR8YO8o0+Rtm2UE5deAj7LeP4lkWesom1gA PHVjrClxFJt4Md05miOkOu88oL4gMK1Gov65VXht0cuTjJqo4zt6k5sz6ppGeubIqQY7 XOig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LB9t5j9z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 66-v6si5659880pld.630.2018.02.04.10.40.16; Sun, 04 Feb 2018 10:40:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LB9t5j9z; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752201AbeBDSjV (ORCPT + 99 others); Sun, 4 Feb 2018 13:39:21 -0500 Received: from mail-wm0-f68.google.com ([74.125.82.68]:40467 "EHLO mail-wm0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751651AbeBDSjE (ORCPT ); Sun, 4 Feb 2018 13:39:04 -0500 Received: by mail-wm0-f68.google.com with SMTP id v123so21747803wmd.5 for ; Sun, 04 Feb 2018 10:39:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=DpgdlX7ihpVD91PUh2JN0SwqbFCGQMZnOW4PKksakgg=; b=LB9t5j9zGYwDjuEQlNiZCzoioGznCYxZ+5Si4iZtX7Z6epQaowKBZMCqJvjsPru2o3 7iqWvEqF0hnt1iaYn/ypn49SPbQElOERKexP7Osqo/eR0We399S/bwcMLcffaXsXqeuE HYyPT/J7Z2mOASWe6tXWJ7fLdOdGUfEMFb1K4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=DpgdlX7ihpVD91PUh2JN0SwqbFCGQMZnOW4PKksakgg=; b=EiZmGRH8e1RYFcQCgzVlt0pbehGYYC10Fghjj/6iqtC9f06NNofsC3gc+McIrb7txu 0rzUQ4vywLhnTPnY7R8RZQ8e1li1tSxsS6diVmaZiG5eP1besvdxBDH4hWMSdy7Ji/FU x3EboNxODGRJGCO4z8IHO36vFyRMhKAnHSmindVmxppxRRwH5YtvEFlRLb/53XQS3H+E ksskzitj8KWBpN8yCJt33dge5HCSY+OS1oXp6put5JbAnZ1A5DhYQBXDSvAoH1hCMI5M Lb9Dy6IH8jEb66ePUY2RoNg9EoJtkjF7NK4av8OzNEwlDi770LYMjhbq+a3APEVU6GAQ m1gQ== X-Gm-Message-State: AKwxytcZEfw328/pGwW2LDrnLs8GlNbEQE7oJdjZlEnQiGB9BtSgFhQB xf/nJCXqcx9YBEG1o36y4HEFUQ== X-Received: by 10.80.225.3 with SMTP id h3mr74856797edl.194.1517769542691; Sun, 04 Feb 2018 10:39:02 -0800 (PST) Received: from localhost (x50d2404e.cust.hiper.dk. [80.210.64.78]) by smtp.gmail.com with ESMTPSA id p57sm6718496edc.33.2018.02.04.10.39.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 04 Feb 2018 10:39:01 -0800 (PST) Date: Sun, 4 Feb 2018 19:39:01 +0100 From: Christoffer Dall To: Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu, Catalin Marinas , Will Deacon , Peter Maydell , Lorenzo Pieralisi , Mark Rutland , Robin Murphy , Ard Biesheuvel , Andrew Jones , Hanjun Guo , Jayachandran C , Jon Masters , Russell King - ARM Linux Subject: Re: [PATCH v3 11/18] arm64: KVM: Report SMCCC_ARCH_WORKAROUND_1 BP hardening support Message-ID: <20180204183901.GO21802@cbox> References: <20180201114657.7323-1-marc.zyngier@arm.com> <20180201114657.7323-12-marc.zyngier@arm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180201114657.7323-12-marc.zyngier@arm.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 01, 2018 at 11:46:50AM +0000, Marc Zyngier wrote: > A new feature of SMCCC 1.1 is that it offers firmware-based CPU > workarounds. In particular, SMCCC_ARCH_WORKAROUND_1 provides > BP hardening for CVE-2017-5715. > > If the host has some mitigation for this issue, report that > we deal with it using SMCCC_ARCH_WORKAROUND_1, as we apply the > host workaround on every guest exit. Reviewed-by: Christoffer Dall > > Signed-off-by: Marc Zyngier > --- > arch/arm/include/asm/kvm_host.h | 7 +++++++ > arch/arm64/include/asm/kvm_host.h | 6 ++++++ > include/linux/arm-smccc.h | 5 +++++ > virt/kvm/arm/psci.c | 9 ++++++++- > 4 files changed, 26 insertions(+), 1 deletion(-) > > diff --git a/arch/arm/include/asm/kvm_host.h b/arch/arm/include/asm/kvm_host.h > index e9d57060d88c..6c05e3b13081 100644 > --- a/arch/arm/include/asm/kvm_host.h > +++ b/arch/arm/include/asm/kvm_host.h > @@ -309,4 +309,11 @@ static inline void kvm_fpsimd_flush_cpu_state(void) {} > > static inline void kvm_arm_vhe_guest_enter(void) {} > static inline void kvm_arm_vhe_guest_exit(void) {} > + > +static inline bool kvm_arm_harden_branch_predictor(void) > +{ > + /* No way to detect it yet, pretend it is not there. */ > + return false; > +} > + > #endif /* __ARM_KVM_HOST_H__ */ > diff --git a/arch/arm64/include/asm/kvm_host.h b/arch/arm64/include/asm/kvm_host.h > index 10af386642c6..448d3b9a58cb 100644 > --- a/arch/arm64/include/asm/kvm_host.h > +++ b/arch/arm64/include/asm/kvm_host.h > @@ -418,4 +418,10 @@ static inline void kvm_arm_vhe_guest_exit(void) > { > local_daif_restore(DAIF_PROCCTX_NOIRQ); > } > + > +static inline bool kvm_arm_harden_branch_predictor(void) > +{ > + return cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR); > +} > + > #endif /* __ARM64_KVM_HOST_H__ */ > diff --git a/include/linux/arm-smccc.h b/include/linux/arm-smccc.h > index dc68aa5a7261..e1ef944ef1da 100644 > --- a/include/linux/arm-smccc.h > +++ b/include/linux/arm-smccc.h > @@ -73,6 +73,11 @@ > ARM_SMCCC_SMC_32, \ > 0, 1) > > +#define ARM_SMCCC_ARCH_WORKAROUND_1 \ > + ARM_SMCCC_CALL_VAL(ARM_SMCCC_FAST_CALL, \ > + ARM_SMCCC_SMC_32, \ > + 0, 0x8000) > + > #ifndef __ASSEMBLY__ > > #include > diff --git a/virt/kvm/arm/psci.c b/virt/kvm/arm/psci.c > index 2efacbe7b1a2..22c24561d07d 100644 > --- a/virt/kvm/arm/psci.c > +++ b/virt/kvm/arm/psci.c > @@ -406,13 +406,20 @@ int kvm_hvc_call_handler(struct kvm_vcpu *vcpu) > { > u32 func_id = smccc_get_function(vcpu); > u32 val = PSCI_RET_NOT_SUPPORTED; > + u32 feature; > > switch (func_id) { > case ARM_SMCCC_VERSION_FUNC_ID: > val = ARM_SMCCC_VERSION_1_1; > break; > case ARM_SMCCC_ARCH_FEATURES_FUNC_ID: > - /* Nothing supported yet */ > + feature = smccc_get_arg1(vcpu); > + switch(feature) { > + case ARM_SMCCC_ARCH_WORKAROUND_1: > + if (kvm_arm_harden_branch_predictor()) > + val = 0; > + break; > + } > break; > default: > return kvm_psci_call(vcpu); > -- > 2.14.2 >