arm64: errata: use arm_smccc_1_1_get_conduit()
authorMark Rutland <mark.rutland@arm.com>
Fri, 9 Aug 2019 13:22:41 +0000 (14:22 +0100)
committerCatalin Marinas <catalin.marinas@arm.com>
Mon, 14 Oct 2019 09:55:13 +0000 (10:55 +0100)
Now that we have arm_smccc_1_1_get_conduit(), we can hide the PSCI
implementation details from the arm64 cpu errata code, so let's do so.

As arm_smccc_1_1_get_conduit() implicitly checks that the SMCCC version
is at least SMCCC_VERSION_1_1, we no longer need to check this
explicitly where switch statements have a default case, e.g. in
has_ssbd_mitigation().

There should be no functional change as a result of this patch.

Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Cc: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Suzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
arch/arm64/kernel/cpu_errata.c

index f593f4cffc0dd49a04301a66646863b4d6f9f281..9c0b011eee20b5fa566103da79294c2e66e51c08 100644 (file)
@@ -6,7 +6,6 @@
  */
 
 #include <linux/arm-smccc.h>
-#include <linux/psci.h>
 #include <linux/types.h>
 #include <linux/cpu.h>
 #include <asm/cpu.h>
@@ -166,9 +165,7 @@ static void install_bp_hardening_cb(bp_hardening_cb_t fn,
 }
 #endif /* CONFIG_KVM_INDIRECT_VECTORS */
 
-#include <uapi/linux/psci.h>
 #include <linux/arm-smccc.h>
-#include <linux/psci.h>
 
 static void call_smc_arch_workaround_1(void)
 {
@@ -212,11 +209,8 @@ static int detect_harden_bp_fw(void)
        struct arm_smccc_res res;
        u32 midr = read_cpuid_id();
 
-       if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
-               return -1;
-
-       switch (psci_ops.conduit) {
-       case PSCI_CONDUIT_HVC:
+       switch (arm_smccc_1_1_get_conduit()) {
+       case SMCCC_CONDUIT_HVC:
                arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_1, &res);
                switch ((int)res.a0) {
@@ -234,7 +228,7 @@ static int detect_harden_bp_fw(void)
                }
                break;
 
-       case PSCI_CONDUIT_SMC:
+       case SMCCC_CONDUIT_SMC:
                arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_1, &res);
                switch ((int)res.a0) {
@@ -308,11 +302,11 @@ void __init arm64_update_smccc_conduit(struct alt_instr *alt,
 
        BUG_ON(nr_inst != 1);
 
-       switch (psci_ops.conduit) {
-       case PSCI_CONDUIT_HVC:
+       switch (arm_smccc_1_1_get_conduit()) {
+       case SMCCC_CONDUIT_HVC:
                insn = aarch64_insn_get_hvc_value();
                break;
-       case PSCI_CONDUIT_SMC:
+       case SMCCC_CONDUIT_SMC:
                insn = aarch64_insn_get_smc_value();
                break;
        default:
@@ -351,12 +345,12 @@ void arm64_set_ssbd_mitigation(bool state)
                return;
        }
 
-       switch (psci_ops.conduit) {
-       case PSCI_CONDUIT_HVC:
+       switch (arm_smccc_1_1_get_conduit()) {
+       case SMCCC_CONDUIT_HVC:
                arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
                break;
 
-       case PSCI_CONDUIT_SMC:
+       case SMCCC_CONDUIT_SMC:
                arm_smccc_1_1_smc(ARM_SMCCC_ARCH_WORKAROUND_2, state, NULL);
                break;
 
@@ -390,20 +384,13 @@ static bool has_ssbd_mitigation(const struct arm64_cpu_capabilities *entry,
                goto out_printmsg;
        }
 
-       if (psci_ops.smccc_version == SMCCC_VERSION_1_0) {
-               ssbd_state = ARM64_SSBD_UNKNOWN;
-               if (!this_cpu_safe)
-                       __ssb_safe = false;
-               return false;
-       }
-
-       switch (psci_ops.conduit) {
-       case PSCI_CONDUIT_HVC:
+       switch (arm_smccc_1_1_get_conduit()) {
+       case SMCCC_CONDUIT_HVC:
                arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_2, &res);
                break;
 
-       case PSCI_CONDUIT_SMC:
+       case SMCCC_CONDUIT_SMC:
                arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
                                  ARM_SMCCC_ARCH_WORKAROUND_2, &res);
                break;