aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm64/kernel/cpu_errata.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c
index 60cf87c4deb7..a9c3ad4f7948 100644
--- a/arch/arm64/kernel/cpu_errata.c
+++ b/arch/arm64/kernel/cpu_errata.c
@@ -109,7 +109,6 @@ cpu_enable_trap_ctr_access(const struct arm64_cpu_capabilities *__unused)
109 109
110atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1); 110atomic_t arm64_el2_vector_last_slot = ATOMIC_INIT(-1);
111 111
112#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
113#include <asm/mmu_context.h> 112#include <asm/mmu_context.h>
114#include <asm/cacheflush.h> 113#include <asm/cacheflush.h>
115 114
@@ -270,11 +269,11 @@ static int detect_harden_bp_fw(void)
270 ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1)) 269 ((midr & MIDR_CPU_MODEL_MASK) == MIDR_QCOM_FALKOR_V1))
271 cb = qcom_link_stack_sanitization; 270 cb = qcom_link_stack_sanitization;
272 271
273 install_bp_hardening_cb(cb, smccc_start, smccc_end); 272 if (IS_ENABLED(CONFIG_HARDEN_BRANCH_PREDICTOR))
273 install_bp_hardening_cb(cb, smccc_start, smccc_end);
274 274
275 return 1; 275 return 1;
276} 276}
277#endif /* CONFIG_HARDEN_BRANCH_PREDICTOR */
278 277
279#ifdef CONFIG_ARM64_SSBD 278#ifdef CONFIG_ARM64_SSBD
280DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required); 279DEFINE_PER_CPU_READ_MOSTLY(u64, arm64_ssbd_callback_required);
@@ -513,7 +512,6 @@ cpu_enable_cache_maint_trap(const struct arm64_cpu_capabilities *__unused)
513 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \ 512 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, \
514 CAP_MIDR_RANGE_LIST(midr_list) 513 CAP_MIDR_RANGE_LIST(midr_list)
515 514
516#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
517/* 515/*
518 * List of CPUs that do not need any Spectre-v2 mitigation at all. 516 * List of CPUs that do not need any Spectre-v2 mitigation at all.
519 */ 517 */
@@ -545,6 +543,12 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope)
545 if (!need_wa) 543 if (!need_wa)
546 return false; 544 return false;
547 545
546 if (!IS_ENABLED(CONFIG_HARDEN_BRANCH_PREDICTOR)) {
547 pr_warn_once("spectrev2 mitigation disabled by kernel configuration\n");
548 __hardenbp_enab = false;
549 return false;
550 }
551
548 /* forced off */ 552 /* forced off */
549 if (__nospectre_v2) { 553 if (__nospectre_v2) {
550 pr_info_once("spectrev2 mitigation disabled by command line option\n"); 554 pr_info_once("spectrev2 mitigation disabled by command line option\n");
@@ -556,7 +560,6 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope)
556 560
557 return (need_wa > 0); 561 return (need_wa > 0);
558} 562}
559#endif
560 563
561#ifdef CONFIG_HARDEN_EL2_VECTORS 564#ifdef CONFIG_HARDEN_EL2_VECTORS
562 565
@@ -731,13 +734,11 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
731 ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73), 734 ERRATA_MIDR_ALL_VERSIONS(MIDR_CORTEX_A73),
732 }, 735 },
733#endif 736#endif
734#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR
735 { 737 {
736 .capability = ARM64_HARDEN_BRANCH_PREDICTOR, 738 .capability = ARM64_HARDEN_BRANCH_PREDICTOR,
737 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM, 739 .type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
738 .matches = check_branch_predictor, 740 .matches = check_branch_predictor,
739 }, 741 },
740#endif
741#ifdef CONFIG_HARDEN_EL2_VECTORS 742#ifdef CONFIG_HARDEN_EL2_VECTORS
742 { 743 {
743 .desc = "EL2 vector hardening", 744 .desc = "EL2 vector hardening",