arm64: errata: use arm_smccc_1_1_get_conduit()

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>
This commit is contained in:
Mark Rutland 2019-08-09 14:22:41 +01:00 committed by Catalin Marinas
parent 6b7fe77c33
commit c98bd29917
1 changed files with 12 additions and 25 deletions

View File

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