Received: by 10.223.185.116 with SMTP id b49csp2236592wrg; Thu, 15 Feb 2018 08:32:28 -0800 (PST) X-Google-Smtp-Source: AH8x224g3XUqmj2C5w9eo/qqYxzyra2KQQBT6lTcRgzkT3NzpEzyU8iS8QB3EaMQr/QW6evfYNZx X-Received: by 10.99.108.72 with SMTP id h69mr2626089pgc.302.1518712348731; Thu, 15 Feb 2018 08:32:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518712348; cv=none; d=google.com; s=arc-20160816; b=bFFRnWjlhyLBBXK5d2RzeNQi2HAEv3cIwynOK9ro52X11UiWC97bVwo8BsjwnO1WaC DzA8RYFp04W1b9dN+XGu9ss6RTWAntdH8VRC0taDPsL60lB2jDKiesSKCIka89LCxbqJ g4cIuUaGO6NUP8v2G+JnZi4P8hSeV08fq3eCCPReFIJv/XwT5bFu1Vk8cCYQDxk9b0q7 UklWIKxTcCKhUE3YWra4YpVyZn+Yjbq402q0i0U1fELyGNH5T8KQeHFnYcX04cXKON8Y 2dCBE1LjM9YIpXSVkQzyVHSDMCd9M4nHe9CLNipwwuZxcJzxyI1xAyFcTRanoc9bE1Vl jgsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=HNUb+XYfylSnW2iXsV0WdUZ864ramp40kUNrzGqzlM0=; b=qfaKHWmBzcag7udNdEZzAsHbXmtJL1P2sEjay9GTisPjT46qtBnCyw9axDi2/z/GLM AC7zLz+A0DCA/AcB3GGUz4vZZYba6q34uyaphk3Cp2/7kXDfbESeWlQGd0rOZT8TZWpQ Sv56pqeGgu8zuc+FOjeMUfR/sWCvDdWwu77sePQctjJE3PM4NK1mUMq0KxQYWgHndv/J VmAsQ2qydFSrxFdckw+G4DVcWkMisexakJ0TkiN/N65dS90ZUQ8H6mnDvY8TLvhmkMqM 6pzYDEbBNOzS1PJOlUFfx5kpBmOEuil3CSAbOVBodEJG3iE9e8Y203HzcDclgINAvMUr KiEg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y128si3141464pfy.110.2018.02.15.08.32.14; Thu, 15 Feb 2018 08:32:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1425973AbeBOQbA (ORCPT + 99 others); Thu, 15 Feb 2018 11:31:00 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33236 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424137AbeBOPmP (ORCPT ); Thu, 15 Feb 2018 10:42:15 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 73C4DF91; Thu, 15 Feb 2018 15:42:14 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ard Biesheuvel , Christoffer Dall , Marc Zyngier , Catalin Marinas , Will Deacon Subject: [PATCH 4.15 080/202] [Variant 2/Spectre-v2] arm64: KVM: Report SMCCC_ARCH_WORKAROUND_1 BP hardening support Date: Thu, 15 Feb 2018 16:16:20 +0100 Message-Id: <20180215151717.656570345@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Marc Zyngier Commit 6167ec5c9145 upstream. 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. Tested-by: Ard Biesheuvel Reviewed-by: Christoffer Dall Signed-off-by: Marc Zyngier Signed-off-by: Catalin Marinas Signed-off-by: Will Deacon Conflicts: arch/arm/include/asm/kvm_host.h arch/arm64/include/asm/kvm_host.h Signed-off-by: Greg Kroah-Hartman --- arch/arm/include/asm/kvm_host.h | 6 ++++++ arch/arm64/include/asm/kvm_host.h | 5 +++++ include/linux/arm-smccc.h | 5 +++++ virt/kvm/arm/psci.c | 9 ++++++++- 4 files changed, 24 insertions(+), 1 deletion(-) --- a/arch/arm/include/asm/kvm_host.h +++ b/arch/arm/include/asm/kvm_host.h @@ -301,4 +301,10 @@ int kvm_arm_vcpu_arch_has_attr(struct kv /* All host FP/SIMD state is restored on guest exit, so nothing to save: */ static inline void kvm_fpsimd_flush_cpu_state(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__ */ --- a/arch/arm64/include/asm/kvm_host.h +++ b/arch/arm64/include/asm/kvm_host.h @@ -396,4 +396,9 @@ static inline void kvm_fpsimd_flush_cpu_ sve_flush_cpu_state(); } +static inline bool kvm_arm_harden_branch_predictor(void) +{ + return cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR); +} + #endif /* __ARM64_KVM_HOST_H__ */ --- 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 --- a/virt/kvm/arm/psci.c +++ b/virt/kvm/arm/psci.c @@ -405,13 +405,20 @@ int kvm_hvc_call_handler(struct kvm_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);