|
@@ -67,7 +67,6 @@ static int cpu_enable_trap_ctr_access(void *__unused)
|
|
|
DEFINE_PER_CPU_READ_MOSTLY(struct bp_hardening_data, bp_hardening_data);
|
|
|
|
|
|
#ifdef CONFIG_KVM
|
|
|
-extern char __psci_hyp_bp_inval_start[], __psci_hyp_bp_inval_end[];
|
|
|
extern char __qcom_hyp_sanitize_link_stack_start[];
|
|
|
extern char __qcom_hyp_sanitize_link_stack_end[];
|
|
|
extern char __smccc_workaround_1_smc_start[];
|
|
@@ -116,8 +115,6 @@ static void __install_bp_hardening_cb(bp_hardening_cb_t fn,
|
|
|
spin_unlock(&bp_lock);
|
|
|
}
|
|
|
#else
|
|
|
-#define __psci_hyp_bp_inval_start NULL
|
|
|
-#define __psci_hyp_bp_inval_end NULL
|
|
|
#define __qcom_hyp_sanitize_link_stack_start NULL
|
|
|
#define __qcom_hyp_sanitize_link_stack_end NULL
|
|
|
#define __smccc_workaround_1_smc_start NULL
|
|
@@ -164,24 +161,25 @@ static void call_hvc_arch_workaround_1(void)
|
|
|
arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_WORKAROUND_1, NULL);
|
|
|
}
|
|
|
|
|
|
-static bool check_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *entry)
|
|
|
+static int enable_smccc_arch_workaround_1(void *data)
|
|
|
{
|
|
|
+ const struct arm64_cpu_capabilities *entry = data;
|
|
|
bp_hardening_cb_t cb;
|
|
|
void *smccc_start, *smccc_end;
|
|
|
struct arm_smccc_res res;
|
|
|
|
|
|
if (!entry->matches(entry, SCOPE_LOCAL_CPU))
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
|
|
|
if (psci_ops.smccc_version == SMCCC_VERSION_1_0)
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
|
|
|
switch (psci_ops.conduit) {
|
|
|
case PSCI_CONDUIT_HVC:
|
|
|
arm_smccc_1_1_hvc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
|
|
|
ARM_SMCCC_ARCH_WORKAROUND_1, &res);
|
|
|
if (res.a0)
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
cb = call_hvc_arch_workaround_1;
|
|
|
smccc_start = __smccc_workaround_1_hvc_start;
|
|
|
smccc_end = __smccc_workaround_1_hvc_end;
|
|
@@ -191,35 +189,18 @@ static bool check_smccc_arch_workaround_1(const struct arm64_cpu_capabilities *e
|
|
|
arm_smccc_1_1_smc(ARM_SMCCC_ARCH_FEATURES_FUNC_ID,
|
|
|
ARM_SMCCC_ARCH_WORKAROUND_1, &res);
|
|
|
if (res.a0)
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
cb = call_smc_arch_workaround_1;
|
|
|
smccc_start = __smccc_workaround_1_smc_start;
|
|
|
smccc_end = __smccc_workaround_1_smc_end;
|
|
|
break;
|
|
|
|
|
|
default:
|
|
|
- return false;
|
|
|
+ return 0;
|
|
|
}
|
|
|
|
|
|
install_bp_hardening_cb(entry, cb, smccc_start, smccc_end);
|
|
|
|
|
|
- return true;
|
|
|
-}
|
|
|
-
|
|
|
-static int enable_psci_bp_hardening(void *data)
|
|
|
-{
|
|
|
- const struct arm64_cpu_capabilities *entry = data;
|
|
|
-
|
|
|
- if (psci_ops.get_version) {
|
|
|
- if (check_smccc_arch_workaround_1(entry))
|
|
|
- return 0;
|
|
|
-
|
|
|
- install_bp_hardening_cb(entry,
|
|
|
- (bp_hardening_cb_t)psci_ops.get_version,
|
|
|
- __psci_hyp_bp_inval_start,
|
|
|
- __psci_hyp_bp_inval_end);
|
|
|
- }
|
|
|
-
|
|
|
return 0;
|
|
|
}
|
|
|
|
|
@@ -399,22 +380,22 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_CORTEX_A57),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_CORTEX_A72),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_CORTEX_A75),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
@@ -428,12 +409,12 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
{
|
|
|
.capability = ARM64_HARDEN_BRANCH_PREDICTOR,
|
|
|
MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
|
|
|
- .enable = enable_psci_bp_hardening,
|
|
|
+ .enable = enable_smccc_arch_workaround_1,
|
|
|
},
|
|
|
#endif
|
|
|
{
|