diff --git a/arch/arm64/include/asm/assembler.h b/arch/arm64/include/asm/assembler.h index cb0f24bd31bc..305b607eda3b 100644 --- a/arch/arm64/include/asm/assembler.h +++ b/arch/arm64/include/asm/assembler.h @@ -512,7 +512,9 @@ alternative_endif .macro __mitigate_spectre_bhb_loop tmp #ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY +#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR alternative_cb spectre_bhb_patch_loop_iter +#endif mov \tmp, #32 // Patched to correct the immediate alternative_cb_end .Lspectre_bhb_loop\@: diff --git a/arch/arm64/kernel/cpu_errata.c b/arch/arm64/kernel/cpu_errata.c index ae364d6b37ac..3b97ad7d6b08 100644 --- a/arch/arm64/kernel/cpu_errata.c +++ b/arch/arm64/kernel/cpu_errata.c @@ -562,7 +562,9 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .capability = ARM64_SPECTRE_BHB, .matches = is_spectre_bhb_affected, #ifdef CONFIG_MITIGATE_SPECTRE_BRANCH_HISTORY +#ifdef CONFIG_HARDEN_BRANCH_PREDICTOR .cpu_enable = spectre_bhb_enable_mitigation, +#endif #endif }, {