]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
arm64: KVM: Report SMCCC_ARCH_WORKAROUND_1 BP hardening support
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 6 Feb 2018 17:56:14 +0000 (17:56 +0000)
committerKhalid Elmously <khalid.elmously@canonical.com>
Tue, 27 Feb 2018 16:33:23 +0000 (11:33 -0500)
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 <ard.biesheuvel@linaro.org>
Reviewed-by: Christoffer Dall <christoffer.dall@linaro.org>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit e47273d086236d06c3c2851fa8599971086b2a73)

CVE-2017-5753
CVE-2017-5715
CVE-2017-5754

Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
Acked-by: Brad Figg <brad.figg@canonical.com>
Acked-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm/include/asm/kvm_host.h
arch/arm64/include/asm/kvm_host.h
include/linux/arm-smccc.h
virt/kvm/arm/psci.c

index 4a879f6ff13bea92d189eec9370be73cd616705c..31fbb9285f62a8504eb4393ca7ea66ba385783a2 100644 (file)
@@ -293,4 +293,10 @@ int kvm_arm_vcpu_arch_get_attr(struct kvm_vcpu *vcpu,
 int kvm_arm_vcpu_arch_has_attr(struct kvm_vcpu *vcpu,
                               struct kvm_device_attr *attr);
 
+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__ */
index e923b58606e2bf8e33a76bd4a8a9a4c1336199c6..8ad208cb866c15dd587263203c299c73e9aee05f 100644 (file)
@@ -384,4 +384,9 @@ static inline void __cpu_init_stage2(void)
                  "PARange is %d bits, unsupported configuration!", parange);
 }
 
+static inline bool kvm_arm_harden_branch_predictor(void)
+{
+       return cpus_have_const_cap(ARM64_HARDEN_BRANCH_PREDICTOR);
+}
+
 #endif /* __ARM64_KVM_HOST_H__ */
index dc68aa5a7261c206468de7e47dd1131e748c5f8b..e1ef944ef1da9b5de7b48b2cabf2bd962719af23 100644 (file)
                           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 <linux/linkage.h>
index e105c1153794b864eadd150a1f6176e5f3193038..6919352cbf15e8d50b3742e32acfd152be4b18a8 100644 (file)
@@ -405,13 +405,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);