xen/arm: Add workaround for Cortex-A76/Neoverse-N1 erratum #1286807
PATCH 1/1 xen/arm: Add workaround for Cortex-A76/Neoverse-N1 erratum #1286807
On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual address for a cacheable mapping of a location is being accessed by a core while another core is remapping the virtual address to a new physical page using the recommended break-before-make sequence, then under very rare circumstances TLBI+DSB completes before a read using the translation being invalidated has been observed by other observers. The workaround repeats the TLBI+DSB operation.
--- docs/misc/arm/silicon-errata.txt | 2 ++ xen/arch/arm/Kconfig | 18 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 14 ++++++++++++++ xen/include/asm-arm/arm64/flushtlb.h | 29 +++++++++++++++++++--------- xen/include/asm-arm/cpufeature.h | 3 ++- 5 files changed, 56 insertions(+), 10 deletions(-)
docs/misc/arm/silicon-errata.txt +2 -0
@@ -53,5 +53,7 @@ stable hypervisors. | ARM | Cortex-A72 | #853709 | N/A | | ARM | Cortex-A73 | #858921 | ARM_ERRATUM_858921 | | ARM | Cortex-A76 | #1165522 | N/A | +| ARM | Cortex-A76 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | Neoverse-N1 | #1165522 | N/A +| ARM | Neoverse-N1 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | MMU-500 | #842869 | N/A |
xen/arch/arm/Kconfig +18 -0
@@ -244,6 +244,24 @@ config ARM_ERRATUM_858921 If unsure, say Y. +config ARM64_ERRATUM_1286807 + bool "Cortex-A76/Neoverse-N1: 1286807: Modification of the translation table for a virtual address might lead to read-after-read ordering violation" + default y + depends on ARM_64 + help + This option adds a workaround for ARM Cortex-A76/Neoverse-N1 erratum 1286807. + + On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual + address for a cacheable mapping of a location is being + accessed by a core while another core is remapping the virtual + address to a new physical page using the recommended + break-before-make sequence, then under very rare circumstances + TLBI+DSB completes before a read using the translation being + invalidated has been observed by other observers. The + workaround repeats the TLBI+DSB operation. + + If unsure, say Y. + endmenu config ARM64_HARDEN_BRANCH_PREDICTOR
xen/arch/arm/cpuerrata.c +14 -0
@@ -424,6 +424,20 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_ERRATUM_1286807 + { +/* Cortex-A76 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability =ARM64_WORKAROUND_REPEAT_TLBI , + MIDR_RANGE(MIDR_CORTEX_A76, 0, 3 << MIDR_VARIANT_SHIFT), + }, + { +/* Neoverse-N1 r0p0 - r3p0 */ + .desc ="ARM erratum 1286807" , + .capability = ARM64_WORKAROUND_REPEAT_TLBI, +MIDR_RANGE (MIDR_NEOVERSE_N1 ,0 ,3 <<MIDR_VARIANT_SHIFT ), + }, +#endif #ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR { .capability = ARM_HARDEN_BRANCH_PREDICTOR,
xen/include/asm-arm/arm64/flushtlb.h +20 -9
@@ -9,6 +9,11 @@* DSB ISH // Ensure the TLB invalidation has completed * ISB // See explanation below * +* ARM64_WORKAROUND_REPEAT_TLBI: +* Modification of the translation table for a virtual address might lead to +* read-after-read ordering violation. +* The workaround repeats TLBI+DSB operation. +* * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. *
@@ -16,15 +21,21 @@* (and therefore the TLB invalidation) before continuing. So we know * the TLBs cannot contain an entry for a mapping we may have removed. */ -#define TLB_HELPER (name, tlbop) \ -static inline void name(void) \ -{ \ - asm volatile( \ - "dsb ishst;" \ - "tlbi " # tlbop ";" \ - "dsb ish;" \ - "isb;" \ - : : : "memory"); \ +#define TLB_HELPER (name, tlbop) \ +static inline void name(void) \ +{ \ + asm volatile( \ + "dsb ishst;" \ + "tlbi " # tlbop ";" \ + ALTERNATIVE( \ + "nop; nop;", \ + "dsb ish;" \ + "tlbi " # tlbop ";", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_ERRATUM_1286807) \ + "dsb ish;" \ + "isb;" \ + : : : "memory"); \ }/* Flush local TLBs, current VMID only. */
xen/include/asm-arm/cpufeature.h +2 -1
@@ -46,8 +46,9 @@#define ARM_SMCCC_1_1 8#define ARM64_WORKAROUND_AT_SPECULATE 9#define ARM_WORKAROUND_858921 10 +#define ARM64_WORKAROUND_REPEAT_TLBI 11 -#define ARM_NCAPS 11 +#define ARM_NCAPS 12#ifndef __ASSEMBLY__
Signature · 1 line
2.28.0
Hi,
Quoted 11 lines · Michal Orzel
On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual address for a cacheable mapping of a location is being accessed by a core while another core is remapping the virtual address to a new physical page using the recommended break-before-make sequence, then under very rare circumstances TLBI+DSB completes before a read using the translation being invalidated has been observed by other observers. The workaround repeats the TLBI+DSB operation.
Signed-off-by Michal Orzel <[email protected]>
Cheers
Bertrand
Quoted 139 lines
---
docs/misc/arm/silicon-errata.txt | 2 ++ xen/arch/arm/Kconfig | 18 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 14 ++++++++++++++ xen/include/asm-arm/arm64/flushtlb.h | 29 +++++++++++++++++++--------- xen/include/asm-arm/cpufeature.h | 3 ++- 5 files changed, 56 insertions(+), 10 deletions(-)docs/misc/arm/silicon-errata.txt +0
-0@@ -53,5 +53,7 @@ stable hypervisors.| ARM | Cortex-A72 | #853709 | N/A | | ARM | Cortex-A73 | #858921 | ARM_ERRATUM_858921 | | ARM | Cortex-A76 | #1165522 | N/A | +| ARM | Cortex-A76 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | Neoverse-N1 | #1165522 | N/A +| ARM | Neoverse-N1 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | MMU-500 | #842869 | N/A |xen/arch/arm/Kconfig +18
-0@@ -244,6 +244,24 @@ config ARM_ERRATUM_858921 If unsure, say Y. +config ARM64_ERRATUM_1286807 + bool "Cortex-A76/Neoverse-N1: 1286807: Modification of the translation table for a virtual address might lead to read-after-read ordering violation" + default y + depends on ARM_64 + help + This option adds a workaround for ARM Cortex-A76/Neoverse-N1 erratum 1286807. + + On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual + address for a cacheable mapping of a location is being + accessed by a core while another core is remapping the virtual + address to a new physical page using the recommended + break-before-make sequence, then under very rare circumstances + TLBI+DSB completes before a read using the translation being + invalidated has been observed by other observers. The + workaround repeats the TLBI+DSB operation. + + If unsure, say Y. +endmenu
config
ARM64_HARDEN_BRANCH_PREDICTORxen/arch/arm/cpuerrata.c +14
-0@@ -424,6 +424,20 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_ERRATUM_1286807 + { +/* Cortex-A76 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability =ARM64_WORKAROUND_REPEAT_TLBI , + MIDR_RANGE(MIDR_CORTEX_A76, 0, 3 << MIDR_VARIANT_SHIFT), + }, + { +/* Neoverse-N1 r0p0 - r3p0 */ + .desc ="ARM erratum 1286807" , + .capability = ARM64_WORKAROUND_REPEAT_TLBI, +MIDR_RANGE (MIDR_NEOVERSE_N1 ,0 ,3 <<MIDR_VARIANT_SHIFT ), + }, +#endif #ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR { .capability = ARM_HARDEN_BRANCH_PREDICTOR,xen/include/asm-arm/arm64/flushtlb.h +20
-9@@ -9,6 +9,11 @@* DSB ISH // Ensure the TLB invalidation has completed * ISB // See explanation below * +* ARM64_WORKAROUND_REPEAT_TLBI: +* Modification of the translation table for a virtual address might lead to +* read-after-read ordering violation. +* The workaround repeats TLBI+DSB operation. +* * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. * @@ -16,15 +21,21 @@* (and therefore the TLB invalidation) before continuing. So we know * the TLBs cannot contain an entry for a mapping we may have removed. */ -#define TLB_HELPER (name, tlbop) \ -static inline void name(void) \ -{ \ - asm volatile( \ - "dsb ishst;" \ - "tlbi " # tlbop ";" \ - "dsb ish;" \ - "isb;" \ - : : : "memory"); \ +#define TLB_HELPER (name, tlbop) \ +static inline void name(void) \ +{ \ + asm volatile( \ + "dsb ishst;" \ + "tlbi " # tlbop ";" \ + ALTERNATIVE( \ + "nop; nop;", \ + "dsb ish;" \ + "tlbi " # tlbop ";", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_ERRATUM_1286807) \ + "dsb ish;" \ + "isb;" \ + : : : "memory"); \ }/* Flush local TLBs, current VMID only. */ xen/include/asm-arm/cpufeature.h +2
-1@@ -46,8 +46,9 @@#define ARM_SMCCC_1_1 8#define ARM64_WORKAROUND_AT_SPECULATE 9#define ARM_WORKAROUND_858921 10 +#define ARM64_WORKAROUND_REPEAT_TLBI 11 -#define ARM_NCAPS 11 +#define ARM_NCAPS 12#ifndef __ASSEMBLY__Signature · 1 line
2.28.0
Wei Chen
Reviewed-byHi,
Quoted 23 lines
-----Original Message-----
From: Xen-devel <[email protected]> On Behalf Of Bertrand Marquis
Sent: 2020年11月16日 16:48
To: Michal Orzel <[email protected]>
Cc: open list:X86 <[email protected]>; Stefano Stabellini <[email protected]>; Julien Grall <[email protected]>; Volodymyr Babchuk <[email protected]>
Subject: Re: [PATCH] xen/arm: Add workaround for Cortex-A76/Neoverse-N1 erratum #1286807Hi,
Quoted 10 lines · Michal Orzel
On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual address for a cacheable mapping of a location is being accessed by a core while another core is remapping the virtual address to a new physical page using the recommended break-before-make sequence, then under very rare circumstances TLBI+DSB completes before a read using the translation being invalidated has been observed by other observers. The workaround repeats the TLBI+DSB operation.
Quoted 3 lines
Quoted 1 line
Signed-off-by Michal Orzel <[email protected]>Reviewed-by Bertrand Marquis <[email protected]>
Quoted 153 lines
Cheers
Bertranddocs/misc/arm/silicon-
Quoted 9 lines
---
docs/misc/arm/silicon-errata.txt | 2 ++ xen/arch/arm/Kconfig | 18 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 14 ++++++++++++++ xen/include/asm-arm/arm64/flushtlb.h | 29 +++++++++++++++++++--------- xen/include/asm-arm/cpufeature.h | 3 ++- 5 files changed, 56 insertions(+), 10 deletions(-)docs/misc/arm/silicon- renamed from docs/misc/arm/silicon-errata.txt +0
-0errata.txt
Quoted 8 lines
index
552c4151d3..d183ba543f100644docs/misc/arm/silicon-errata.txt +0
-0@@ -53,5 +53,7 @@ stable hypervisors.| ARM | Cortex-A72 | #853709 | N/A | | ARM | Cortex-A73 | #858921 | ARM_ERRATUM_858921 | | ARM | Cortex-A76 | #1165522 | N/A | +| ARM | Cortex-A76 | #1286807 | ARM64_ERRATUM_1286807|
Quoted 2 lines
| ARM | Neoverse-N1 | #1165522 | N/A +| ARM | Neoverse-N1 | #1286807 | ARM64_ERRATUM_1286807|
xen/arch/arm/Kconfig config ARM_ERRATUM_858921 · line 248
Quoted 11 lines
| ARM | MMU-500 | #842869 | N/A |
xen/arch/arm/Kconfig +2
-0@@ -244,6 +244,24 @@ config ARM_ERRATUM_858921 If unsure, say Y. +config ARM64_ERRATUM_1286807 + bool "Cortex-A76/Neoverse-N1: 1286807: Modification of thetranslation table for a virtual address might lead to read-after-read ordering violation"
xen/arch/arm/Kconfig config ARM_ERRATUM_858921
Quoted 4 lines
xen/arch/arm/Kconfig +4
-0+ default y + depends on ARM_64 + help + This option adds a workaround for ARM Cortex-A76/Neoverse-N1erratum 1286807.
xen/arch/arm/Kconfig config ARM_ERRATUM_858921 · line 254
Quoted 2 lines
xen/arch/arm/Kconfig +2
-0+ + On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if avirtual
xen/arch/arm/cpuerrata.c static const struct arm_cpu_capabilities arm_errata[]
Quoted 18 lines
xen/arch/arm/Kconfig +10
-0+ address for a cacheable mapping of a location is being + accessed by a core while another core is remapping the virtual + address to a new physical page using the recommended + break-before-make sequence, then under very rare circumstances + TLBI+DSB completes before a read using the translation being + invalidated has been observed by other observers. The + workaround repeats the TLBI+DSB operation. + + If unsure, say Y. +endmenu
config
ARM64_HARDEN_BRANCH_PREDICTORxen/arch/arm/cpuerrata.c +0
-0@@ -424,6 +424,20 @@ static const struct arm_cpu_capabilities arm_errata[]= {
xen/include/asm-
Quoted 21 lines
xen/arch/arm/cpuerrata.c +14
-0(1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_ERRATUM_1286807 + { +/* Cortex-A76 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability =ARM64_WORKAROUND_REPEAT_TLBI , + MIDR_RANGE(MIDR_CORTEX_A76, 0, 3 << MIDR_VARIANT_SHIFT), + }, + { +/* Neoverse-N1 r0p0 - r3p0 */ + .desc ="ARM erratum 1286807" , + .capability = ARM64_WORKAROUND_REPEAT_TLBI, +MIDR_RANGE (MIDR_NEOVERSE_N1 ,0 ,3 <<MIDR_VARIANT_SHIFT ), + }, +#endif #ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR { .capability = ARM_HARDEN_BRANCH_PREDICTOR,xen/include/asm- renamed from xen/include/asm-arm/arm64/flushtlb.h +0
-0
arm/arm64/flushtlb.hxen/include/asm-
Quoted 47 lines
index ceec59542e..6726362211 100644
xen/include/asm-arm/arm64/flushtlb.h +20
-9@@ -9,6 +9,11 @@* DSB ISH // Ensure the TLB invalidation has completed * ISB // See explanation below * +* ARM64_WORKAROUND_REPEAT_TLBI: +* Modification of the translation table for a virtual address might lead to +* read-after-read ordering violation. +* The workaround repeats TLBI+DSB operation. +* * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. * @@ -16,15 +21,21 @@* (and therefore the TLB invalidation) before continuing. So we know * the TLBs cannot contain an entry for a mapping we may have removed. */ -#define TLB_HELPER (name, tlbop) \ -static inline void name(void) \ -{ \ - asm volatile( \ - "dsb ishst;" \ - "tlbi " # tlbop ";" \ - "dsb ish;" \ - "isb;" \ - : : : "memory"); \ +#define TLB_HELPER (name, tlbop) \ +static inline void name(void) \ +{ \ + asm volatile( \ + "dsb ishst;" \ + "tlbi " # tlbop ";" \ + ALTERNATIVE( \ + "nop; nop;", \ + "dsb ish;" \ + "tlbi " # tlbop ";", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_ERRATUM_1286807) \ + "dsb ish;" \ + "isb;" \ + : : : "memory"); \ }/* Flush local TLBs, current VMID only. */ xen/include/asm- renamed from xen/include/asm-arm/cpufeature.h +0
-0
arm/cpufeature.hQuoted 17 lines
index
016a9fe203..c7b5052992100644xen/include/asm-arm/cpufeature.h +2
-2@@ -46,8 +46,9 @@#define ARM_SMCCC_1_1 8#define ARM64_WORKAROUND_AT_SPECULATE 9#define ARM_WORKAROUND_858921 10 +#define ARM64_WORKAROUND_REPEAT_TLBI 11 -#define ARM_NCAPS 11 +#define ARM_NCAPS 12#ifndef __ASSEMBLY__ --2.28.0
Hi Michal,
Quoted 7 lines · Michal Orzel
On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual address for a cacheable mapping of a location is being accessed by a core while another core is remapping the virtual address to a new physical page using the recommended break-before-make sequence, then under very rare circumstances TLBI+DSB completes before a read using the translation being invalidated has been observed by other observers. The workaround repeats the TLBI+DSB operation.
The commit message suggests the second TLBI+DSB operation is only necessary for innershearable TLBs.
I agree that it is probably be best to cover all the TLB flush operations. However, it would be good to clarify it in the commit message that this is done on purpose.
Quoted 103 lines
Signed-off-by Michal Orzel <[email protected]>--- docs/misc/arm/silicon-errata.txt | 2 ++ xen/arch/arm/Kconfig | 18 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 14 ++++++++++++++ xen/include/asm-arm/arm64/flushtlb.h | 29 +++++++++++++++++++--------- xen/include/asm-arm/cpufeature.h | 3 ++- 5 files changed, 56 insertions(+), 10 deletions(-)docs/misc/arm/silicon-errata.txt +2
-0@@ -53,5 +53,7 @@ stable hypervisors. | ARM | Cortex-A72 | #853709 | N/A | | ARM | Cortex-A73 | #858921 | ARM_ERRATUM_858921 | | ARM | Cortex-A76 | #1165522 | N/A | +| ARM | Cortex-A76 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | Neoverse-N1 | #1165522 | N/A +| ARM | Neoverse-N1 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | MMU-500 | #842869 | N/A |xen/arch/arm/Kconfig +18
-0@@ -244,6 +244,24 @@ config ARM_ERRATUM_858921 If unsure, say Y. +config ARM64_ERRATUM_1286807 + bool "Cortex-A76/Neoverse-N1: 1286807: Modification of the translation table for a virtual address might lead to read-after-read ordering violation" + default y + depends on ARM_64 + help + This option adds a workaround for ARM Cortex-A76/Neoverse-N1 erratum 1286807. + + On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual + address for a cacheable mapping of a location is being + accessed by a core while another core is remapping the virtual + address to a new physical page using the recommended + break-before-make sequence, then under very rare circumstances + TLBI+DSB completes before a read using the translation being + invalidated has been observed by other observers. The + workaround repeats the TLBI+DSB operation. + + If unsure, say Y. + endmenu config ARM64_HARDEN_BRANCH_PREDICTORxen/arch/arm/cpuerrata.c +14
-0@@ -424,6 +424,20 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), },#endif +#ifdef CONFIG_ARM64_ERRATUM_1286807 + { +/* Cortex-A76 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability =ARM64_WORKAROUND_REPEAT_TLBI , + MIDR_RANGE(MIDR_CORTEX_A76, 0, 3 << MIDR_VARIANT_SHIFT), + }, + { +/* Neoverse-N1 r0p0 - r3p0 */ + .desc ="ARM erratum 1286807" , + .capability = ARM64_WORKAROUND_REPEAT_TLBI, +MIDR_RANGE (MIDR_NEOVERSE_N1 ,0 ,3 <<MIDR_VARIANT_SHIFT ), + }, +#endif #ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR { .capability = ARM_HARDEN_BRANCH_PREDICTOR,xen/include/asm-arm/arm64/flushtlb.h +5
-7@@ -9,6 +9,11 @@* DSB ISH // Ensure the TLB invalidation has completed * ISB // See explanation below * +* ARM64_WORKAROUND_REPEAT_TLBI: +* Modification of the translation table for a virtual address might lead to +* read-after-read ordering violation. +* The workaround repeats TLBI+DSB operation. +* * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. * @@ -16,15 +21,21 @@* (and therefore the TLB invalidation) before continuing. So we know * the TLBs cannot contain an entry for a mapping we may have removed. */ -#define TLB_HELPER (name, tlbop) \ -static inline void name(void) \ -{ \ - asm volatile( \ - "dsb ishst;" \ - "tlbi " # tlbop ";" \ - "dsb ish;" \
xen/include/asm-arm/arm64/flushtlb.h line 31
Quoted 10 lines
xen/include/asm-arm/arm64/flushtlb.h +8
-2- "isb;" \ - : : : "memory"); \ +#define TLB_HELPER (name, tlbop) \ +static inline void name(void) \ +{ \ + asm volatile( \ + "dsb ishst;" \ + "tlbi " # tlbop ";" \ + ALTERNATIVE( \ + "nop; nop;", \
This is a bit difficult to read. I would suggest to indent the arguments of ALTERNITIVE() by an extra soft tab.
xen/include/asm-arm/arm64/flushtlb.h line 35
Quoted 4 lines
xen/include/asm-arm/arm64/flushtlb.h +4
-0+"dsb ish;" \ + "tlbi " # tlbop ";", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_ERRATUM_1286807) \
I think it would be fine to have this code unconditionally built. But if you prefer to keep it conditionally, then I would suggest to introduce CONFIG_ARM64_WORKAROUND_REPEAT_TLBI and gate the ALTERNATIVE with it.
The new config would be selected by CONFIG_ARM64_ERRATUM_1286807. This will make easier for future workaround to use it (AFAICT there are other platforms require the same thing).
Cheers,
Signature · 1 line
Julien Grall
Quoted 11 lines · Julien Grall
Hi Michal,
Quoted 7 lines · Michal Orzel
On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual address for a cacheable mapping of a location is being accessed by a core while another core is remapping the virtual address to a new physical page using the recommended break-before-make sequence, then under very rare circumstances TLBI+DSB completes before a read using the translation being invalidated has been observed by other observers. The workaround repeats the TLBI+DSB operation.
Quoted 4 lines
The commit message suggests the second TLBI+DSB operation is only necessary for innershearable TLBs.
I agree that it is probably be best to cover all the TLB flush operations. However, it would be good to clarify it in the commit message that this is done on purpose.
Hi Julien,
Ok I agree that such note can be added.
I will push v2 then.
Quoted 124 lines
Quoted 100 lines
Signed-off-by Michal Orzel <[email protected]>---
docs/misc/arm/silicon-errata.txt | 2 ++ xen/arch/arm/Kconfig | 18 +++++++++++++++++ xen/arch/arm/cpuerrata.c | 14 ++++++++++++++xen/include/asm-arm/arm64/flushtlb.h| 29 +++++++++++++++++++--------- xen/include/asm-arm/cpufeature.h | 3 ++-5 files changed, 56 insertions(+), 10 deletions(-)docs/misc/arm/silicon-errata.txt +0
-0@@ -53,5 +53,7 @@ stable hypervisors.| ARM | Cortex-A72 | #853709 | N/A | | ARM | Cortex-A73 | #858921 | ARM_ERRATUM_858921 | | ARM | Cortex-A76 | #1165522 | N/A | +| ARM | Cortex-A76 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | Neoverse-N1 | #1165522 | N/A +| ARM | Neoverse-N1 | #1286807 | ARM64_ERRATUM_1286807 | | ARM | MMU-500 | #842869 | N/A |xen/arch/arm/Kconfig +0
-0@@ -244,6 +244,24 @@ config ARM_ERRATUM_858921If unsure, say Y.
+configARM64_ERRATUM_1286807
+ bool "Cortex-A76/Neoverse-N1: 1286807: Modification of the translation table for a virtual address might lead to read-after-read ordering violation" + default y
+ depends onARM_64
+ help
+ This option adds a workaround for ARM Cortex-A76/Neoverse-N1 erratum 1286807.xen/arch/arm/Kconfig +12
-0+ + On the affected Cortex-A76/Neoverse-N1 cores (r0p0 to r3p0), if a virtual + address for a cacheable mapping of a location is being + accessed by a core while another core is remapping the virtual + address to a new physical page using the recommended + break-before-make sequence, then under very rare circumstances + TLBI+DSB completes before a read using the translation being + invalidated has been observed by other observers. The + workaround repeats the TLBI+DSB operation. + + If unsure, say Y. +endmenu
configARM64_HARDEN_BRANCH_PREDICTORxen/arch/arm/cpuerrata.c +14
-0@@ -424,6 +424,20 @@ static const struct arm_cpu_capabilities arm_errata[] = { (1 << MIDR_VARIANT_SHIFT) | 2), }, #endif +#ifdef CONFIG_ARM64_ERRATUM_1286807 + { + /* Cortex-A76 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability = ARM64_WORKAROUND_REPEAT_TLBI, + MIDR_RANGE(MIDR_CORTEX_A76, 0, 3 << MIDR_VARIANT_SHIFT), + }, + { + /* Neoverse-N1 r0p0 - r3p0 */ + .desc = "ARM erratum 1286807", + .capability = ARM64_WORKAROUND_REPEAT_TLBI, + MIDR_RANGE(MIDR_NEOVERSE_N1, 0, 3 << MIDR_VARIANT_SHIFT), + }, +#endif #ifdef CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR { .capability = ARM_HARDEN_BRANCH_PREDICTOR,xen/include/asm-arm/arm64/flushtlb.h +5
-7@@ -9,6 +9,11 @@ * DSB ISH // Ensure the TLB invalidation has completed * ISB // See explanation below * + * ARM64_WORKAROUND_REPEAT_TLBI: + * Modification of the translation table for a virtual address might lead to + * read-after-read ordering violation. + * The workaround repeats TLBI+DSB operation. + * * For Xen page-tables the ISB will discard any instructions fetched * from the old mappings. *@@ -16,15 +21,21 @@* (and therefore the TLB invalidation) before continuing. So we know * the TLBs cannot contain an entry for a mapping we may have removed. */ -#define TLB_HELPER (name, tlbop) \ -static inline void name(void) \ -{ \ - asm volatile( \ - "dsb ishst;" \ - "tlbi " # tlbop ";" \ - "dsb ish;" \xen/include/asm-arm/arm64/flushtlb.h line 31
Quoted 10 lines
xen/include/asm-arm/arm64/flushtlb.h +8
-2- "isb;" \ - : : : "memory"); \ +#define TLB_HELPER (name, tlbop) \ +static inline void name(void) \ +{ \ + asm volatile( \ + "dsb ishst;" \ + "tlbi " # tlbop ";" \ + ALTERNATIVE( \ + "nop; nop;", \This is a bit difficult to read. I would suggest to indent the arguments of
ALTERNITIVE()by an extra soft tab.xen/include/asm-arm/arm64/flushtlb.h line 35
Quoted 4 lines
xen/include/asm-arm/arm64/flushtlb.h +4
-0+ "dsb ish;" \ + "tlbi " # tlbop ";", \ + ARM64_WORKAROUND_REPEAT_TLBI, \ + CONFIG_ARM64_ERRATUM_1286807) \I think it would be fine to have this code unconditionally built. But if you prefer to keep it conditionally, then I would suggest to introduce
CONFIG_ARM64_WORKAROUND_REPEAT_TLBIand gate the ALTERNATIVE with it.The new config would be selected by
CONFIG_ARM64_ERRATUM_1286807. This will make easier for future workaround to use it (AFAICT there are other platforms require the same thing).Cheers,