]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
arm64: Use firmware to detect CPUs that are not affected by Spectre-v2
authorMarc Zyngier <marc.zyngier@arm.com>
Wed, 11 Dec 2019 21:45:50 +0000 (14:45 -0700)
committerKhalid Elmously <khalid.elmously@canonical.com>
Wed, 18 Dec 2019 03:45:06 +0000 (22:45 -0500)
BugLink: https://bugs.launchpad.net/bugs/1854207
[ Upstream commit 517953c2c47f9c00a002f588ac856a5bc70cede3 ]

The SMCCC ARCH_WORKAROUND_1 service can indicate that although the
firmware knows about the Spectre-v2 mitigation, this particular
CPU is not vulnerable, and it is thus not necessary to call
the firmware on this CPU.

Let's use this information to our benefit.

Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Reviewed-by: Catalin Marinas <catalin.marinas@arm.com>
Tested-by: Stefan Wahren <stefan.wahren@i2se.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>
Signed-off-by: dann frazier <dann.frazier@canonical.com>
Acked-by: Colin Ian King <colin.king@canonical.com>
Acked-by: Connor Kuehl <connor.kuehl@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
arch/arm64/kernel/cpu_errata.c

index dd0a3dd0b6c36519dcbc171e481b261859f58c38..ef27d4ce4278c27c511eed19490afaef54578bc5 100644 (file)
@@ -192,22 +192,36 @@ static int detect_harden_bp_fw(void)
        case PSCI_CONDUIT_HVC:
                arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_1, &res);
-               if ((int)res.a0 < 0)
+               switch ((int)res.a0) {
+               case 1:
+                       /* Firmware says we're just fine */
+                       return 0;
+               case 0:
+                       cb = call_hvc_arch_workaround_1;
+                       /* This is a guest, no need to patch KVM vectors */
+                       smccc_start = NULL;
+                       smccc_end = NULL;
+                       break;
+               default:
                        return -1;
-               cb = call_hvc_arch_workaround_1;
-               /* This is a guest, no need to patch KVM vectors */
-               smccc_start = NULL;
-               smccc_end = NULL;
+               }
                break;
 
        case PSCI_CONDUIT_SMC:
                arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_1, &res);
-               if ((int)res.a0 < 0)
+               switch ((int)res.a0) {
+               case 1:
+                       /* Firmware says we're just fine */
+                       return 0;
+               case 0:
+                       cb = call_smc_arch_workaround_1;
+                       smccc_start = __smccc_workaround_1_smc_start;
+                       smccc_end = __smccc_workaround_1_smc_end;
+                       break;
+               default:
                        return -1;
-               cb = call_smc_arch_workaround_1;
-               smccc_start = __smccc_workaround_1_smc_start;
-               smccc_end = __smccc_workaround_1_smc_end;
+               }
                break;
 
        default: