Skip to content

Commit ab3906c

Browse files
committed
Merge branch 'for-next/errata' into for-next/core
* for-next/errata: (3 commits) arm64: Workaround for Cortex-A55 erratum 1530923 ...
2 parents aa246c0 + 275fa0e commit ab3906c

File tree

9 files changed

+61
-25
lines changed

9 files changed

+61
-25
lines changed

Documentation/arm64/silicon-errata.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ stable kernels.
8888
+----------------+-----------------+-----------------+-----------------------------+
8989
| ARM | Cortex-A76 | #1463225 | ARM64_ERRATUM_1463225 |
9090
+----------------+-----------------+-----------------+-----------------------------+
91+
| ARM | Cortex-A55 | #1530923 | ARM64_ERRATUM_1530923 |
92+
+----------------+-----------------+-----------------+-----------------------------+
9193
| ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 |
9294
+----------------+-----------------+-----------------+-----------------------------+
9395
| ARM | Neoverse-N1 | #1349291 | N/A |

arch/arm64/Kconfig

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,9 +518,13 @@ config ARM64_ERRATUM_1418040
518518

519519
If unsure, say Y.
520520

521+
config ARM64_WORKAROUND_SPECULATIVE_AT_VHE
522+
bool
523+
521524
config ARM64_ERRATUM_1165522
522525
bool "Cortex-A76: Speculative AT instruction using out-of-context translation regime could cause subsequent request to generate an incorrect translation"
523526
default y
527+
select ARM64_WORKAROUND_SPECULATIVE_AT_VHE
524528
help
525529
This option adds a workaround for ARM Cortex-A76 erratum 1165522.
526530

@@ -530,6 +534,19 @@ config ARM64_ERRATUM_1165522
530534

531535
If unsure, say Y.
532536

537+
config ARM64_ERRATUM_1530923
538+
bool "Cortex-A55: Speculative AT instruction using out-of-context translation regime could cause subsequent request to generate an incorrect translation"
539+
default y
540+
select ARM64_WORKAROUND_SPECULATIVE_AT_VHE
541+
help
542+
This option adds a workaround for ARM Cortex-A55 erratum 1530923.
543+
544+
Affected Cortex-A55 cores (r0p0, r0p1, r1p0, r2p0) could end-up with
545+
corrupted TLBs by speculating an AT instruction during a guest
546+
context switch.
547+
548+
If unsure, say Y.
549+
533550
config ARM64_ERRATUM_1286807
534551
bool "Cortex-A76: Modification of the translation table for a virtual address might lead to read-after-read ordering violation"
535552
default y
@@ -546,9 +563,13 @@ config ARM64_ERRATUM_1286807
546563
invalidated has been observed by other observers. The
547564
workaround repeats the TLBI+DSB operation.
548565

566+
config ARM64_WORKAROUND_SPECULATIVE_AT_NVHE
567+
bool
568+
549569
config ARM64_ERRATUM_1319367
550570
bool "Cortex-A57/A72: Speculative AT instruction using out-of-context translation regime could cause subsequent request to generate an incorrect translation"
551571
default y
572+
select ARM64_WORKAROUND_SPECULATIVE_AT_NVHE
552573
help
553574
This option adds work arounds for ARM Cortex-A57 erratum 1319537
554575
and A72 erratum 1319367

arch/arm64/include/asm/cpucaps.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
#define ARM64_SSBS 34
4545
#define ARM64_WORKAROUND_1418040 35
4646
#define ARM64_HAS_SB 36
47-
#define ARM64_WORKAROUND_1165522 37
47+
#define ARM64_WORKAROUND_SPECULATIVE_AT_VHE 37
4848
#define ARM64_HAS_ADDRESS_AUTH_ARCH 38
4949
#define ARM64_HAS_ADDRESS_AUTH_IMP_DEF 39
5050
#define ARM64_HAS_GENERIC_AUTH_ARCH 40
@@ -55,7 +55,7 @@
5555
#define ARM64_WORKAROUND_CAVIUM_TX2_219_TVM 45
5656
#define ARM64_WORKAROUND_CAVIUM_TX2_219_PRFM 46
5757
#define ARM64_WORKAROUND_1542419 47
58-
#define ARM64_WORKAROUND_1319367 48
58+
#define ARM64_WORKAROUND_SPECULATIVE_AT_NVHE 48
5959
#define ARM64_HAS_E0PD 49
6060

6161
#define ARM64_NCAPS 50

arch/arm64/include/asm/kvm_host.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,7 @@ static inline bool kvm_arch_requires_vhe(void)
571571
return true;
572572

573573
/* Some implementations have defects that confine them to VHE */
574-
if (cpus_have_cap(ARM64_WORKAROUND_1165522))
574+
if (cpus_have_cap(ARM64_WORKAROUND_SPECULATIVE_AT_VHE))
575575
return true;
576576

577577
return false;

arch/arm64/include/asm/kvm_hyp.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,11 @@ static __always_inline void __hyp_text __load_guest_stage2(struct kvm *kvm)
9191
write_sysreg(kvm_get_vttbr(kvm), vttbr_el2);
9292

9393
/*
94-
* ARM erratum 1165522 requires the actual execution of the above
95-
* before we can switch to the EL1/EL0 translation regime used by
94+
* ARM errata 1165522 and 1530923 require the actual execution of the
95+
* above before we can switch to the EL1/EL0 translation regime used by
9696
* the guest.
9797
*/
98-
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_1165522));
98+
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT_VHE));
9999
}
100100

101101
#endif /* __ARM64_KVM_HYP_H__ */

arch/arm64/kernel/cpu_errata.c

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -759,6 +759,20 @@ static const struct arm64_cpu_capabilities erratum_843419_list[] = {
759759
};
760760
#endif
761761

762+
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT_VHE
763+
static const struct midr_range erratum_speculative_at_vhe_list[] = {
764+
#ifdef CONFIG_ARM64_ERRATUM_1165522
765+
/* Cortex A76 r0p0 to r2p0 */
766+
MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 2, 0),
767+
#endif
768+
#ifdef CONFIG_ARM64_ERRATUM_1530923
769+
/* Cortex A55 r0p0 to r2p0 */
770+
MIDR_RANGE(MIDR_CORTEX_A55, 0, 0, 2, 0),
771+
#endif
772+
{},
773+
};
774+
#endif
775+
762776
const struct arm64_cpu_capabilities arm64_errata[] = {
763777
#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
764778
{
@@ -885,12 +899,11 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
885899
ERRATA_MIDR_RANGE_LIST(erratum_1418040_list),
886900
},
887901
#endif
888-
#ifdef CONFIG_ARM64_ERRATUM_1165522
902+
#ifdef CONFIG_ARM64_WORKAROUND_SPECULATIVE_AT_VHE
889903
{
890-
/* Cortex-A76 r0p0 to r2p0 */
891-
.desc = "ARM erratum 1165522",
892-
.capability = ARM64_WORKAROUND_1165522,
893-
ERRATA_MIDR_RANGE(MIDR_CORTEX_A76, 0, 0, 2, 0),
904+
.desc = "ARM errata 1165522, 1530923",
905+
.capability = ARM64_WORKAROUND_SPECULATIVE_AT_VHE,
906+
ERRATA_MIDR_RANGE_LIST(erratum_speculative_at_vhe_list),
894907
},
895908
#endif
896909
#ifdef CONFIG_ARM64_ERRATUM_1463225
@@ -927,7 +940,7 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
927940
#ifdef CONFIG_ARM64_ERRATUM_1319367
928941
{
929942
.desc = "ARM erratum 1319367",
930-
.capability = ARM64_WORKAROUND_1319367,
943+
.capability = ARM64_WORKAROUND_SPECULATIVE_AT_NVHE,
931944
ERRATA_MIDR_RANGE_LIST(ca57_a72),
932945
},
933946
#endif

arch/arm64/kvm/hyp/switch.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static void __hyp_text __activate_traps_nvhe(struct kvm_vcpu *vcpu)
127127

128128
write_sysreg(val, cptr_el2);
129129

130-
if (cpus_have_const_cap(ARM64_WORKAROUND_1319367)) {
130+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE)) {
131131
struct kvm_cpu_context *ctxt = &vcpu->arch.ctxt;
132132

133133
isb();
@@ -166,11 +166,11 @@ static void deactivate_traps_vhe(void)
166166
write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
167167

168168
/*
169-
* ARM erratum 1165522 requires the actual execution of the above
170-
* before we can switch to the EL2/EL0 translation regime used by
169+
* ARM errata 1165522 and 1530923 require the actual execution of the
170+
* above before we can switch to the EL2/EL0 translation regime used by
171171
* the host.
172172
*/
173-
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_1165522));
173+
asm(ALTERNATIVE("nop", "isb", ARM64_WORKAROUND_SPECULATIVE_AT_VHE));
174174

175175
write_sysreg(CPACR_EL1_DEFAULT, cpacr_el1);
176176
write_sysreg(vectors, vbar_el1);
@@ -181,7 +181,7 @@ static void __hyp_text __deactivate_traps_nvhe(void)
181181
{
182182
u64 mdcr_el2 = read_sysreg(mdcr_el2);
183183

184-
if (cpus_have_const_cap(ARM64_WORKAROUND_1319367)) {
184+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE)) {
185185
u64 val;
186186

187187
/*

arch/arm64/kvm/hyp/sysreg-sr.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ static void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
118118
write_sysreg(ctxt->sys_regs[MPIDR_EL1], vmpidr_el2);
119119
write_sysreg(ctxt->sys_regs[CSSELR_EL1], csselr_el1);
120120

121-
if (!cpus_have_const_cap(ARM64_WORKAROUND_1319367)) {
121+
if (!cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE)) {
122122
write_sysreg_el1(ctxt->sys_regs[SCTLR_EL1], SYS_SCTLR);
123123
write_sysreg_el1(ctxt->sys_regs[TCR_EL1], SYS_TCR);
124124
} else if (!ctxt->__hyp_running_vcpu) {
@@ -149,7 +149,7 @@ static void __hyp_text __sysreg_restore_el1_state(struct kvm_cpu_context *ctxt)
149149
write_sysreg(ctxt->sys_regs[PAR_EL1], par_el1);
150150
write_sysreg(ctxt->sys_regs[TPIDR_EL1], tpidr_el1);
151151

152-
if (cpus_have_const_cap(ARM64_WORKAROUND_1319367) &&
152+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE) &&
153153
ctxt->__hyp_running_vcpu) {
154154
/*
155155
* Must only be done for host registers, hence the context

arch/arm64/kvm/hyp/tlb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ static void __hyp_text __tlb_switch_to_guest_vhe(struct kvm *kvm,
2323

2424
local_irq_save(cxt->flags);
2525

26-
if (cpus_have_const_cap(ARM64_WORKAROUND_1165522)) {
26+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_VHE)) {
2727
/*
28-
* For CPUs that are affected by ARM erratum 1165522, we
29-
* cannot trust stage-1 to be in a correct state at that
28+
* For CPUs that are affected by ARM errata 1165522 or 1530923,
29+
* we cannot trust stage-1 to be in a correct state at that
3030
* point. Since we do not want to force a full load of the
3131
* vcpu state, we prevent the EL1 page-table walker to
3232
* allocate new TLBs. This is done by setting the EPD bits
@@ -63,7 +63,7 @@ static void __hyp_text __tlb_switch_to_guest_vhe(struct kvm *kvm,
6363
static void __hyp_text __tlb_switch_to_guest_nvhe(struct kvm *kvm,
6464
struct tlb_inv_context *cxt)
6565
{
66-
if (cpus_have_const_cap(ARM64_WORKAROUND_1319367)) {
66+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE)) {
6767
u64 val;
6868

6969
/*
@@ -103,7 +103,7 @@ static void __hyp_text __tlb_switch_to_host_vhe(struct kvm *kvm,
103103
write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
104104
isb();
105105

106-
if (cpus_have_const_cap(ARM64_WORKAROUND_1165522)) {
106+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_VHE)) {
107107
/* Restore the registers to what they were */
108108
write_sysreg_el1(cxt->tcr, SYS_TCR);
109109
write_sysreg_el1(cxt->sctlr, SYS_SCTLR);
@@ -117,7 +117,7 @@ static void __hyp_text __tlb_switch_to_host_nvhe(struct kvm *kvm,
117117
{
118118
write_sysreg(0, vttbr_el2);
119119

120-
if (cpus_have_const_cap(ARM64_WORKAROUND_1319367)) {
120+
if (cpus_have_const_cap(ARM64_WORKAROUND_SPECULATIVE_AT_NVHE)) {
121121
/* Ensure write of the host VMID */
122122
isb();
123123
/* Restore the host's TCR_EL1 */

0 commit comments

Comments
 (0)