Skip to content

Commit 93916be

Browse files
Marc Zyngierwilldeacon
authored andcommitted
arm64: Enable workaround for Cavium TX2 erratum 219 when running SMT
It appears that the only case where we need to apply the TX2_219_TVM mitigation is when the core is in SMT mode. So let's condition the enabling on detecting a CPU whose MPIDR_EL1.Aff0 is non-zero. Cc: <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Signed-off-by: Will Deacon <[email protected]>
1 parent d3ec3a0 commit 93916be

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

arch/arm64/kernel/cpu_errata.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <asm/cpu.h>
1313
#include <asm/cputype.h>
1414
#include <asm/cpufeature.h>
15+
#include <asm/smp_plat.h>
1516

1617
static bool __maybe_unused
1718
is_affected_midr_range(const struct arm64_cpu_capabilities *entry, int scope)
@@ -623,6 +624,30 @@ check_branch_predictor(const struct arm64_cpu_capabilities *entry, int scope)
623624
return (need_wa > 0);
624625
}
625626

627+
static const __maybe_unused struct midr_range tx2_family_cpus[] = {
628+
MIDR_ALL_VERSIONS(MIDR_BRCM_VULCAN),
629+
MIDR_ALL_VERSIONS(MIDR_CAVIUM_THUNDERX2),
630+
{},
631+
};
632+
633+
static bool __maybe_unused
634+
needs_tx2_tvm_workaround(const struct arm64_cpu_capabilities *entry,
635+
int scope)
636+
{
637+
int i;
638+
639+
if (!is_affected_midr_range_list(entry, scope) ||
640+
!is_hyp_mode_available())
641+
return false;
642+
643+
for_each_possible_cpu(i) {
644+
if (MPIDR_AFFINITY_LEVEL(cpu_logical_map(i), 0) != 0)
645+
return true;
646+
}
647+
648+
return false;
649+
}
650+
626651
#ifdef CONFIG_HARDEN_EL2_VECTORS
627652

628653
static const struct midr_range arm64_harden_el2_vectors[] = {
@@ -851,6 +876,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
851876
.type = ARM64_CPUCAP_LOCAL_CPU_ERRATUM,
852877
.matches = has_cortex_a76_erratum_1463225,
853878
},
879+
#endif
880+
#ifdef CONFIG_CAVIUM_TX2_ERRATUM_219
881+
{
882+
.desc = "Cavium ThunderX2 erratum 219 (KVM guest sysreg trapping)",
883+
.capability = ARM64_WORKAROUND_CAVIUM_TX2_219_TVM,
884+
ERRATA_MIDR_RANGE_LIST(tx2_family_cpus),
885+
.matches = needs_tx2_tvm_workaround,
886+
},
854887
#endif
855888
{
856889
}

0 commit comments

Comments
 (0)