coresight: trbe: Workaround Cortex-A510 erratas
v2 cover coresight: trbe: Workaround Cortex-A510 erratas
This series adds three different workarounds in the TRBE driver for
Cortex-A510 specific erratas. But first, this adds Cortex-A510 specific cpu part number definition in the platform. This series applies on 5.16-rc8.
Relevant errata documents can be found here.
https://developer.arm.com/documentation/SDEN2397239/900
https://developer.arm.com/documentation/SDEN2397589/900
Changes in V2:
Accommodated most review comments from the previous version.
- Split all patches into CPU errata definition, detection and TRBE workarounds
- s/TRBE_WORKAROUND_SYSREG_WRITE_FAILURE/TRBE_NEEDS_DRAIN_AFTER_DISABLE
- s/TRBE_WORKAROUND_CORRUPTION_WITH_ENABLE/TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE
- s/trbe_may_fail_sysreg_write()/trbe_needs_drain_after_disable()
- s/trbe_may_corrupt_with_enable()/trbe_needs_ctxt_sync_after_enable()
- Updated Kconfig help message for config ARM64_ERRATUM_1902691
- Updated error message for trbe_is_broken() detection
- Added new trblimitr parameter to set_trbe_enabled(), improving performance
- Added COMPILE_TEST dependency in the errata, until TRBE part is available
Changes in V1:
https://lore.kernel.org/lkml/[email protected]/
Anshuman Khandual (7):
arm64: Add Cortex-A510 CPU part definition
arm64: errata: Add detection for TRBE ignored system register writes
arm64: errata: Add detection for TRBE invalid prohibited states
arm64: errata: Add detection for TRBE trace data corruption
coresight: trbe: Work around the ignored system register writes
coresight: trbe: Work around the invalid prohibited states
coresight: trbe: Work around the trace data corruption
Documentation/arm64/silicon-errata.rst | 6 + arch/arm64/Kconfig | 59 ++++++++++ arch/arm64/include/asm/cputype.h | 2 + arch/arm64/kernel/cpu_errata.c | 27 +++++ arch/arm64/tools/cpucaps | 3 + drivers/hwtracing/coresight/coresight-trbe.c | 114 ++++++++++++++----- drivers/hwtracing/coresight/coresight-trbe.h | 8 -- 7 files changed, 183 insertions(+), 36 deletions(-)
Signature · 1 line
2.25.1
PATCH v2 1/7 arm64: Add Cortex-A510 CPU part definition
Add the CPU Partnumbers for the new Arm designs.
--- arch/arm64/include/asm/cputype.h | 2 ++ 1 file changed, 2 insertions(+)
arch/arm64/include/asm/cputype.h +2 -0
@@ -73,6 +73,7 @@#define ARM_CPU_PART_CORTEX_A76 0xD0B#define ARM_CPU_PART_NEOVERSE_N1 0xD0C#define ARM_CPU_PART_CORTEX_A77 0xD0D +#define ARM_CPU_PART_CORTEX_A510 0xD46#define ARM_CPU_PART_CORTEX_A710 0xD47#define ARM_CPU_PART_NEOVERSE_N2 0xD49
@@ -115,6 +116,7 @@#define MIDR_CORTEX_A76 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A76)#define MIDR_NEOVERSE_N1 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N1)#define MIDR_CORTEX_A77 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A77) +#define MIDR_CORTEX_A510 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A510)#define MIDR_CORTEX_A710 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_CORTEX_A710)#define MIDR_NEOVERSE_N2 MIDR_CPU_MODEL(ARM_CPU_IMP_ARM, ARM_CPU_PART_NEOVERSE_N2)#define MIDR_THUNDERX MIDR_CPU_MODEL(ARM_CPU_IMP_CAVIUM, CAVIUM_CPU_PART_THUNDERX)
Signature · 1 line
2.25.1
Re: [PATCH V2 1/7] arm64: Add Cortex-A510 CPU part definition
Quoted 9 lines · Anshuman Khandual
Add the CPU Partnumbers for the new Arm designs.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Suzuki Poulose <[email protected]>Reviewed-by Suzuki K Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
PATCH v2 2/7 arm64: errata: Add detection for TRBE ignored system register writes
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers TRBLIMITR_EL1, TRBPTR_EL1, TRBBASER_EL1, TRBSR_EL1 and TRBTRG_EL1 will be ignored and not be effected. This adds a new errata ARM64_ERRATUM_2064142 in arm64 errata framework.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 18 ++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 30 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -52,6 +52,8 @@ stable kernels. | Allwinner | A64/R18 | UNKNOWN1 | SUN50I_ERRATUM_UNKNOWN1 | +----------------+-----------------+-----------------+-----------------------------+ +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A510 | #2064142 | ARM64_ERRATUM_2064142 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
arch/arm64/Kconfig +18 -0
@@ -778,6 +778,24 @@ config ARM64_ERRATUM_2224489 If unsure, say Y. +config ARM64_ERRATUM_2064142 + bool "Cortex-A510: 2064142: workaround TRBE register writes while disabled" + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + default y + help + This option adds the workaround for ARM Cortex-A510 erratum 2064142. + + Affected Cortex-A510 core might fail to write into system registers after the + TRBE has been disabled. Under some conditions after the TRBE has been disabled + writes into TRBE registers TRBLIMITR_EL1, TRBPTR_EL1, TRBBASER_EL1, TRBSR_EL1, + and TRBTRG_EL1 will be ignored and will not be effected. + + Work around this in the driver by executing TSB CSYNC and DSB after collection + is stopped and before performing a system register write to one of the affected + registers. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/kernel/cpu_errata.c +9 -0
@@ -597,6 +597,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { .type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE, CAP_MIDR_RANGE_LIST(trbe_write_out_of_range_cpus), }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_2064142 + { + .desc = "ARM erratum 2064142", + .capability = ARM64_WORKAROUND_2064142, + + /* Cortex-A510 r0p0 - r0p2 */ + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) + }, #endif { }
arch/arm64/tools/cpucaps +1 -0
@@ -55,6 +55,7 @@ WORKAROUND_1418040 WORKAROUND_1463225 WORKAROUND_1508412 WORKAROUND_1542419 +WORKAROUND_2064142 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
Signature · 1 line
2.25.1
Re: [PATCH V2 2/7] arm64: errata: Add detection for TRBE ignored system register writes
Quoted 7 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers
TRBLIMITR_EL1,TRBPTR_EL1,TRBBASER_EL1,TRBSR_EL1andTRBTRG_EL1will be ignored and not be effected. This adds a new errataARM64_ERRATUM_2064142in arm64 errata framework.
Quoted 9 lines
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Re: [PATCH V2 2/7] arm64: errata: Add detection for TRBE ignored system register writes
In reply to Anshuman KhandualQuoted 16 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers
TRBLIMITR_EL1,TRBPTR_EL1,TRBBASER_EL1,TRBSR_EL1andTRBTRG_EL1will be ignored and not be effected. This adds a new errataARM64_ERRATUM_2064142in arm64 errata framework.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Quoted 7 lines
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 18 ++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 30 insertions(+)
PATCH v2 3/7 arm64: errata: Add detection for TRBE invalid prohibited states
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #2038923 might get TRBE into an inconsistent view on whether trace is prohibited within the CPU. As a result, the trace buffer or trace buffer state might be corrupted. This happens after TRBE buffer has been enabled by setting TRBLIMITR_EL1.E, followed by just a single context synchronization event before execution changes from a context, in which trace is prohibited to one where it isn't, or vice versa. In these mentioned conditions, the view of whether trace is prohibited is inconsistent between parts of the CPU, and the trace buffer or the trace buffer state might be corrupted. This adds a new errata ARM64_ERRATUM_2038923 in arm64 errata framework.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 23 +++++++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 35 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -54,6 +54,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A510 | #2064142 | ARM64_ERRATUM_2064142 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A510 | #2038923 | ARM64_ERRATUM_2038923 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
arch/arm64/Kconfig +23 -0
@@ -796,6 +796,29 @@ config ARM64_ERRATUM_2064142 If unsure, say Y. +config ARM64_ERRATUM_2038923 + bool "Cortex-A510: 2038923: workaround TRBE corruption with enable" + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + default y + help + This option adds the workaround for ARM Cortex-A510 erratum 2038923. + + Affected Cortex-A510 core might cause an inconsistent view on whether trace is + prohibited within the CPU. As a result, the trace buffer or trace buffer state + might be corrupted. This happens after TRBE buffer has been enabled by setting + TRBLIMITR_EL1.E, followed by just a single context synchronization event before + execution changes from a context, in which trace is prohibited to one where it + isn't, or vice versa. In these mentioned conditions, the view of whether trace + is prohibited is inconsistent between parts of the CPU, and the trace buffer or + the trace buffer state might be corrupted. + + Work around this in the driver by preventing an inconsistent view of whether the + trace is prohibited or not based on TRBLIMITR_EL1.E by immediately following a + change to TRBLIMITR_EL1.E with at least one ISB instruction before an ERET, or + two ISB instructions if no ERET is to take place. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/kernel/cpu_errata.c +9 -0
@@ -607,6 +607,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) },#endif +#ifdef CONFIG_ARM64_ERRATUM_2038923 + { + .desc = "ARM erratum 2038923", + .capability = ARM64_WORKAROUND_2038923, + + /* Cortex-A510 r0p0 - r0p2 */ + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) + }, +#endif { } };
arch/arm64/tools/cpucaps +1 -0
@@ -56,6 +56,7 @@ WORKAROUND_1463225 WORKAROUND_1508412 WORKAROUND_1542419 WORKAROUND_2064142 +WORKAROUND_2038923 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
Signature · 1 line
2.25.1
Re: [PATCH V2 3/7] arm64: errata: Add detection for TRBE invalid prohibited states
Quoted 11 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2038923 might get TRBE into an inconsistent view on whether trace is prohibited within the CPU. As a result, the trace buffer or trace buffer state might be corrupted. This happens after TRBE buffer has been enabled by setting TRBLIMITR_EL1.E, followed by just a single context synchronization event before execution changes from a context, in which trace is prohibited to one where it isn't, or vice versa. In these mentioned conditions, the view of whether trace is prohibited is inconsistent between parts of the CPU, and the trace buffer or the trace buffer state might be corrupted. This adds a new errata
ARM64_ERRATUM_2038923in arm64 errata framework.
Quoted 9 lines
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Re: [PATCH V2 3/7] arm64: errata: Add detection for TRBE invalid prohibited states
In reply to Anshuman KhandualQuoted 20 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2038923 might get TRBE into an inconsistent view on whether trace is prohibited within the CPU. As a result, the trace buffer or trace buffer state might be corrupted. This happens after TRBE buffer has been enabled by setting TRBLIMITR_EL1.E, followed by just a single context synchronization event before execution changes from a context, in which trace is prohibited to one where it isn't, or vice versa. In these mentioned conditions, the view of whether trace is prohibited is inconsistent between parts of the CPU, and the trace buffer or the trace buffer state might be corrupted. This adds a new errata
ARM64_ERRATUM_2038923in arm64 errata framework.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Quoted 1 line
---
Quoted 85 lines
Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 23 +++++++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 35 insertions(+)Documentation/arm64/silicon-errata.rst +2
-0@@ -54,6 +54,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A510 | #2064142 | ARM64_ERRATUM_2064142 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A510 | #2038923 | ARM64_ERRATUM_2038923 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |arch/arm64/Kconfig +23
-0@@ -796,6 +796,29 @@ config ARM64_ERRATUM_2064142 If unsure, say Y. +config ARM64_ERRATUM_2038923 + bool "Cortex-A510: 2038923: workaround TRBE corruption with enable" + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + default y + help + This option adds the workaround for ARM Cortex-A510 erratum 2038923. + + Affected Cortex-A510 core might cause an inconsistent view on whether trace is + prohibited within the CPU. As a result, the trace buffer or trace buffer state + might be corrupted. This happens after TRBE buffer has been enabled by setting + TRBLIMITR_EL1.E, followed by just a single context synchronization event before + execution changes from a context, in which trace is prohibited to one where it + isn't, or vice versa. In these mentioned conditions, the view of whether trace + is prohibited is inconsistent between parts of the CPU, and the trace buffer or + the trace buffer state might be corrupted. + + Work around this in the driver by preventing an inconsistent view of whether the + trace is prohibited or not based on TRBLIMITR_EL1.E by immediately following a + change to TRBLIMITR_EL1.E with at least one ISB instruction before an ERET, or + two ISB instructions if no ERET is to take place. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default yarch/arm64/kernel/cpu_errata.c +9
-0@@ -607,6 +607,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = { ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) },#endif +#ifdef CONFIG_ARM64_ERRATUM_2038923 + { + .desc = "ARM erratum 2038923", + .capability = ARM64_WORKAROUND_2038923, + + /* Cortex-A510 r0p0 - r0p2 */ + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) + }, +#endif { } };arch/arm64/tools/cpucaps +1
-0@@ -56,6 +56,7 @@ WORKAROUND_1463225 WORKAROUND_1508412 WORKAROUND_1542419 WORKAROUND_2064142 +WORKAROUND_2038923 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
PATCH v2 4/7 arm64: errata: Add detection for TRBE trace data corruption
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. So effectively TRBE is broken and hence cannot be used to capture trace data. This adds a new errata ARM64_ERRATUM_1902691 in arm64 errata framework.
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 18 ++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 30 insertions(+)
Documentation/arm64/silicon-errata.rst +2 -0
@@ -56,6 +56,8 @@ stable kernels. +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A510 | #2038923 | ARM64_ERRATUM_2038923 | +----------------+-----------------+-----------------+-----------------------------+ +| ARM | Cortex-A510 | #1902691 | ARM64_ERRATUM_1902691 | ++----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #826319 | ARM64_ERRATUM_826319 | +----------------+-----------------+-----------------+-----------------------------+ | ARM | Cortex-A53 | #827319 | ARM64_ERRATUM_827319 |
arch/arm64/Kconfig +18 -0
@@ -819,6 +819,24 @@ config ARM64_ERRATUM_2038923 If unsure, say Y. +config ARM64_ERRATUM_1902691 + bool "Cortex-A510: 1902691: workaround TRBE trace corruption" + depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + default y + help + This option adds the workaround for ARM Cortex-A510 erratum 1902691. + + Affected Cortex-A510 core might cause trace data corruption, when being written + into the memory. Effectively TRBE is broken and hence cannot be used to capture + trace data. + + Work around this problem in the driver by just preventing TRBE initialization on + affected cpus. The firmware must have disabled the access to TRBE for the kernel + on such implementations. This will cover the kernel for any firmware that doesn't + do this already. + + If unsure, say Y. + config CAVIUM_ERRATUM_22375 bool "Cavium erratum 22375, 24313" default y
arch/arm64/kernel/cpu_errata.c +9 -0
@@ -615,6 +615,15 @@ const struct arm64_cpu_capabilities arm64_errata[] = {/* Cortex-A510 r0p0 - r0p2 */ ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 2) }, +#endif +#ifdef CONFIG_ARM64_ERRATUM_1902691 + { + .desc = "ARM erratum 1902691", + .capability = ARM64_WORKAROUND_1902691, + + /* Cortex-A510 r0p0 - r0p1 */ + ERRATA_MIDR_REV_RANGE(MIDR_CORTEX_A510, 0, 0, 1) + }, #endif { }
arch/arm64/tools/cpucaps +1 -0
@@ -57,6 +57,7 @@ WORKAROUND_1508412 WORKAROUND_1542419 WORKAROUND_2064142 WORKAROUND_2038923 +WORKAROUND_1902691 WORKAROUND_TRBE_OVERWRITE_FILL_MODE WORKAROUND_TSB_FLUSH_FAILURE WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
Signature · 1 line
2.25.1
Re: [PATCH V2 4/7] arm64: errata: Add detection for TRBE trace data corruption
Quoted 5 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. So effectively TRBE is broken and hence cannot be used to capture trace data. This adds a new errata
ARM64_ERRATUM_1902691in arm64 errata framework.
Quoted 9 lines
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Re: [PATCH V2 4/7] arm64: errata: Add detection for TRBE trace data corruption
In reply to Anshuman KhandualQuoted 14 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. So effectively TRBE is broken and hence cannot be used to capture trace data. This adds a new errata
ARM64_ERRATUM_1902691in arm64 errata framework.Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>
Quoted 6 lines
--- Documentation/arm64/silicon-errata.rst | 2 ++ arch/arm64/Kconfig | 18 ++++++++++++++++++ arch/arm64/kernel/cpu_errata.c | 9 +++++++++ arch/arm64/tools/cpucaps | 1 + 4 files changed, 30 insertions(+)
PATCH v2 5/7 coresight: trbe: Work around the ignored system register writes
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers TRBLIMITR_EL1, TRBPTR_EL1, TRBBASER_EL1, TRBSR_EL1 and TRBTRG_EL1 will be ignored and not be effected.
Work around this problem in the TRBE driver by executing TSB CSYNC and DSB just after the trace collection has stopped and before performing a system register write to one of the affected registers. This just updates the TRBE driver as required.
--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 54 ++++++++++++++------ drivers/hwtracing/coresight/coresight-trbe.h | 8 --- 3 files changed, 39 insertions(+), 25 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -780,7 +780,7 @@ config ARM64_ERRATUM_2224489 config ARM64_ERRATUM_2064142 bool "Cortex-A510: 2064142: workaround TRBE register writes while disabled" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 2064142.
drivers/hwtracing/coresight/coresight-trbe.c +38 -16
156 lines not on this page · raw message
drivers/hwtracing/coresight/coresight-trbe.h +0 -8
@@ -91,14 +91,6 @@ static inline bool is_trbe_running(u64 trbsr)#define TRBE_FILL_MODE_WRAP 1#define TRBE_FILL_MODE_CIRCULAR_BUFFER 3 -static inline void set_trbe_disabled (void ) -{ -u64 trblimitr =read_sysreg_s (SYS_TRBLIMITR_EL1 ); - - trblimitr &= ~TRBLIMITR_ENABLE ; -write_sysreg_s (trblimitr,SYS_TRBLIMITR_EL1 ); -} -static inline bool get_trbe_flag_update (u64 trbidr) {return trbidr &TRBIDR_FLAG ;
Signature · 1 line
2.25.1
Re: [PATCH V2 5/7] coresight: trbe: Work around the ignored system register writes
Quoted 88 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers
TRBLIMITR_EL1,TRBPTR_EL1,TRBBASER_EL1,TRBSR_EL1andTRBTRG_EL1will be ignored and not be effected.Work around this problem in the TRBE driver by executing TSB CSYNC and DSB just after the trace collection has stopped and before performing a system register write to one of the affected registers. This just updates the TRBE driver as required.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 54 ++++++++++++++------ drivers/hwtracing/coresight/coresight-trbe.h | 8 --- 3 files changed, 39 insertions(+), 25 deletions(-)arch/arm64/Kconfig +1
-1@@ -780,7 +780,7 @@ config ARM64_ERRATUM_2224489 config ARM64_ERRATUM_2064142 bool "Cortex-A510: 2064142: workaround TRBE register writes while disabled" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 2064142.drivers/hwtracing/coresight/coresight-trbe.c +9
-4@@ -91,10 +91,12 @@ struct trbe_buf {*/ #define TRBE_WORKAROUND_OVERWRITE_FILL_MODE 0#define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1 +#define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE ] =ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE , [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE ] =ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE , + [TRBE_NEEDS_DRAIN_AFTER_DISABLE ] =ARM64_WORKAROUND_2064142 ,-1 ,/* Sentinel, must be the last entry */ };@@ -167,6 +169,11 @@ static inline bool trbe_may_write_out_of_range(struct trbe_cpudata *cpudata)return trbe_has_erratum (cpudata,TRBE_WORKAROUND_WRITE_OUT_OF_RANGE ); } +static inline bool trbe_needs_drain_after_disable (struct trbe_cpudata *cpudata) +{ +return trbe_has_erratum (cpudata,TRBE_NEEDS_DRAIN_AFTER_DISABLE ); +} +static int trbe_alloc_node (struct perf_event *event) {if (event->cpu ==-1 )@@ -174,30 +181,42 @@ static int trbe_alloc_node(struct perf_event *event)return cpu_to_node (event->cpu); } -static void trbe_drain_buffer (void ) +static inline void trbe_drain_buffer (void ) {tsb_csync ();dsb (nsh); } -static void trbe_drain_and_disable_local (void ) +static inline void set_trbe_disabled (struct trbe_cpudata *cpudata) {u64 trblimitr =read_sysreg_s (SYS_TRBLIMITR_EL1 ); -trbe_drain_buffer (); -/* * Disable the TRBE without clearing LIMITPTR which
drivers/hwtracing/coresight/coresight-trbe.c static int trbe_alloc_node(struct perf_event *event) · line 205
Quoted 10 lines
drivers/hwtracing/coresight/coresight-trbe.c +6
-0* might be required for fetching the buffer limits. */ trblimitr &= ~TRBLIMITR_ENABLE ;write_sysreg_s (trblimitr,SYS_TRBLIMITR_EL1 ); + +/* +* Errata affected TRBE implementation will need TSB CSYNC and +* DSB in order to prevent subsequent writes into certain TRBE +* system registers from being ignored and not effected. +*/
minor nit: This comment could be moved to the definition of the function "trbe_needs_drain_after_disable()" to make more sense. The name is implicit here indicating, why we are doing a drain.
Either ways:
Re: [PATCH V2 5/7] coresight: trbe: Work around the ignored system register writes
Quoted 88 lines · Suzuki K Poulose
Quoted 87 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2064142 might fail to write into certain system registers after the TRBE has been disabled. Under some conditions after TRBE has been disabled, writes into certain TRBE registers
TRBLIMITR_EL1,TRBPTR_EL1,TRBBASER_EL1,TRBSR_EL1andTRBTRG_EL1will be ignored and not be effected.Work around this problem in the TRBE driver by executing TSB CSYNC and DSB just after the trace collection has stopped and before performing a system register write to one of the affected registers. This just updates the TRBE driver as required.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>---
arch/arm64/Kconfig | 2 +-drivers/hwtracing/coresight/coresight-trbe.c| 54 ++++++++++++++------drivers/hwtracing/coresight/coresight-trbe.h| 8 ---3 files changed, 39 insertions(+), 25 deletions(-)arch/arm64/Kconfig +0
-0@@ -780,7 +780,7 @@ config ARM64_ERRATUM_2224489config
ARM64_ERRATUM_2064142
bool "Cortex-A510: 2064142: workaround TRBE register writes while disabled" - depends onCOMPILE_TEST# Until the CoreSight TRBE driver changes are in + depends onCORESIGHT_TRBE
default y
help
This option adds the workaround for ARM Cortex-A510 erratum 2064142.drivers/hwtracing/coresight/coresight-trbe.c +2
-0@@ -91,10 +91,12 @@ struct trbe_buf {*/ #define TRBE_WORKAROUND_OVERWRITE_FILL_MODE 0 #define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1 +#define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2 static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE] = ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE, [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE] = ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE, + [TRBE_NEEDS_DRAIN_AFTER_DISABLE] = ARM64_WORKAROUND_2064142,-1, /* Sentinel, must be the last entry */
};
@@ -167,6 +169,11 @@ static inline booltrbe_may_write_out_of_range(struct trbe_cpudata *cpudata)returntrbe_has_erratum(cpudata, TRBE_WORKAROUND_WRITE_OUT_OF_RANGE);
}
+static inline booltrbe_needs_drain_after_disable(struct trbe_cpudata *cpudata)drivers/hwtracing/coresight/coresight-trbe.c +4
-0+{ + return trbe_has_erratum(cpudata, TRBE_NEEDS_DRAIN_AFTER_DISABLE); +} +static int
trbe_alloc_node(struct perf_event *event){
if (event->cpu== -1)drivers/hwtracing/coresight/coresight-trbe.c +4
-1@@ -174,30 +181,42 @@ static int trbe_alloc_node(struct perf_event *event) return cpu_to_node(event->cpu); } -static void trbe_drain_buffer(void) +static inline voidtrbe_drain_buffer (void) { tsb_csync(); dsb(nsh); } -static void trbe_drain_and_disable_local(void) +static inline void set_trbe_disabled(struct trbe_cpudata *cpudata) { u64 trblimitr = read_sysreg_s(SYS_TRBLIMITR_EL1); - trbe_drain_buffer(); - /* * Disable the TRBE without clearing LIMITPTR which * might be required for fetching the buffer limits. */ trblimitr &= ~TRBLIMITR_ENABLE; write_sysreg_s(trblimitr, SYS_TRBLIMITR_EL1); + + /*
Quoted 8 lines
drivers/hwtracing/coresight/coresight-trbe.c static int trbe_alloc_node(struct perf_event *event) · line 205
Quoted 4 lines
drivers/hwtracing/coresight/coresight-trbe.c +4
-0+* Errata affected TRBE implementation will need TSB CSYNC and +* DSB in order to prevent subsequent writes into certain TRBE +* system registers from being ignored and not effected. +*/ minor nit: This comment could be moved to the definition of the function "
trbe_needs_drain_after_disable()" to make more sense. The name is implicit here indicating, why we are doing a drain.
Sure, will move the comment just before the function definition.
Quoted 5 lines
Either ways:
Reviewed-by Suzuki K Poulose <[email protected]>
PATCH v2 6/7 coresight: trbe: Work around the invalid prohibited states
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #2038923 might get TRBE into an inconsistent view on whether trace is prohibited within the CPU. As a result, the trace buffer or trace buffer state might be corrupted. This happens after TRBE buffer has been enabled by setting TRBLIMITR_EL1.E, followed by just a single context synchronization event before execution changes from a context, in which trace is prohibited to one where it isn't, or vice versa. In these mentioned conditions, the view of whether trace is prohibited is inconsistent between parts of the CPU, and the trace buffer or the trace buffer state might be corrupted.
Work around this problem in the TRBE driver by preventing an inconsistent view of whether the trace is prohibited or not based on TRBLIMITR_EL1.E by immediately following a change to TRBLIMITR_EL1.E with at least one ISB instruction before an ERET, or two ISB instructions if no ERET is to take place. This just updates the TRBE driver as required.
--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 48 +++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-)
arch/arm64/Kconfig +1 -1
@@ -798,7 +798,7 @@ config ARM64_ERRATUM_2064142 config ARM64_ERRATUM_2038923 bool "Cortex-A510: 2038923: workaround TRBE corruption with enable" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 2038923.
drivers/hwtracing/coresight/coresight-trbe.c +36 -12
103 lines not on this page · raw message
Signature · 1 line
2.25.1
Re: [PATCH V2 6/7] coresight: trbe: Work around the invalid prohibited states
Quoted 88 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #2038923 might get TRBE into an inconsistent view on whether trace is prohibited within the CPU. As a result, the trace buffer or trace buffer state might be corrupted. This happens after TRBE buffer has been enabled by setting TRBLIMITR_EL1.E, followed by just a single context synchronization event before execution changes from a context, in which trace is prohibited to one where it isn't, or vice versa. In these mentioned conditions, the view of whether trace is prohibited is inconsistent between parts of the CPU, and the trace buffer or the trace buffer state might be corrupted.
Work around this problem in the TRBE driver by preventing an inconsistent view of whether the trace is prohibited or not based on TRBLIMITR_EL1.E by immediately following a change to TRBLIMITR_EL1.E with at least one ISB instruction before an ERET, or two ISB instructions if no ERET is to take place. This just updates the TRBE driver as required.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 48 +++++++++++++++----- 2 files changed, 37 insertions(+), 13 deletions(-)arch/arm64/Kconfig +1
-1@@ -798,7 +798,7 @@ config ARM64_ERRATUM_2064142 config ARM64_ERRATUM_2038923 bool "Cortex-A510: 2038923: workaround TRBE corruption with enable" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 2038923.drivers/hwtracing/coresight/coresight-trbe.c +18
-0@@ -92,11 +92,13 @@ struct trbe_buf {#define TRBE_WORKAROUND_OVERWRITE_FILL_MODE 0#define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1#define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2 +#define TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE 3static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE ] =ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE , [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE ] =ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE , [TRBE_NEEDS_DRAIN_AFTER_DISABLE ] =ARM64_WORKAROUND_2064142 , + [TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ] =ARM64_WORKAROUND_2038923 ,-1 ,/* Sentinel, must be the last entry */ };@@ -174,6 +176,11 @@ static inline bool trbe_needs_drain_after_disable(struct trbe_cpudata *cpudata)return trbe_has_erratum (cpudata,TRBE_NEEDS_DRAIN_AFTER_DISABLE ); } +static inline bool trbe_needs_ctxt_sync_after_enable (struct trbe_cpudata *cpudata) +{ +return trbe_has_erratum (cpudata,TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ); +} +static int trbe_alloc_node (struct perf_event *event) {if (event->cpu ==-1 )@@ -187,6 +194,28 @@ static inline void trbe_drain_buffer(void)dsb (nsh); } +static inline void set_trbe_enabled (struct trbe_cpudata *cpudata,u64 trblimitr) +{ +/* +* Enable the TRBE without clearing LIMITPTR which +* might be required for fetching the buffer limits. +*/ + trblimitr |=TRBLIMITR_ENABLE ; +write_sysreg_s (trblimitr,SYS_TRBLIMITR_EL1 ); + +/* Synchronize the TRBE enable event */ +isb ();
drivers/hwtracing/coresight/coresight-trbe.c static inline void trbe_drain_buffer(void) · line 217
Quoted 10 lines
drivers/hwtracing/coresight/coresight-trbe.c +10
-0+ +/* +* Errata affected TRBE implementation will need an additional +* context synchronization in order to prevent an inconsistent +* TRBE prohibited region view on the CPU which could possibly +* corrupt the TRBE buffer or the TRBE state. +*/ +if (trbe_needs_ctxt_sync_after_enable (cpudata)) +isb (); +}
Similar to the previous patch, we may move the comment to the function where it is defined.
Either ways:
PATCH v2 7/7 coresight: trbe: Work around the trace data corruption
In reply to Anshuman KhandualTRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. Workaround this problem in the driver, by preventing TRBE initialization on affected cpus. The firmware must have disabled the access to TRBE for the kernel on such implementations. This will cover the kernel for any firmware that doesn't do this already. This just updates the TRBE driver as required.
--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)
arch/arm64/Kconfig +1 -1
@@ -821,7 +821,7 @@ config ARM64_ERRATUM_2038923 config ARM64_ERRATUM_1902691 bool "Cortex-A510: 1902691: workaround TRBE trace corruption" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 1902691.
drivers/hwtracing/coresight/coresight-trbe.c +12 -0
@@ -93,12 +93,14 @@ struct trbe_buf {#define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1#define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2#define TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE 3 +#define TRBE_IS_BROKEN 4static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE ] =ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE , [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE ] =ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE , [TRBE_NEEDS_DRAIN_AFTER_DISABLE ] =ARM64_WORKAROUND_2064142 , [TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ] =ARM64_WORKAROUND_2038923 , + [TRBE_IS_BROKEN ] =ARM64_WORKAROUND_1902691 ,-1 ,/* Sentinel, must be the last entry */ };
@@ -181,6 +183,11 @@ static inline bool trbe_needs_ctxt_sync_after_enable(struct trbe_cpudata *cpudatreturn trbe_has_erratum (cpudata,TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ); } +static inline bool trbe_is_broken (struct trbe_cpudata *cpudata) +{ +return trbe_has_erratum (cpudata,TRBE_IS_BROKEN ); +} +static int trbe_alloc_node (struct perf_event *event) {if (event->cpu ==-1 )
@@ -1288,6 +1295,11 @@ static void arm_trbe_probe_cpu(void *info)*/ trbe_check_errata (cpudata); +if (trbe_is_broken (cpudata)) { +pr_err ("Disabling TRBE on cpu%d due to erratum\n" , cpu); + goto cpu_clear; + } +/* * If the TRBE is affected by erratum TRBE_WORKAROUND_OVERWRITE_FILL_MODE, * we must always program the TBRPTR_EL1, 256bytes from a page
Signature · 1 line
2.25.1
Re: [PATCH V2 7/7] coresight: trbe: Work around the trace data corruption
Quoted 67 lines · Anshuman Khandual
TRBE implementations affected by Arm erratum #1902691 might corrupt trace data or deadlock, when it's being written into the memory. Workaround this problem in the driver, by preventing TRBE initialization on affected cpus. The firmware must have disabled the access to TRBE for the kernel on such implementations. This will cover the kernel for any firmware that doesn't do this already. This just updates the TRBE driver as required.
Cc Catalin Marinas <[email protected]>Cc Will Deacon <[email protected]>Cc Mathieu Poirier <[email protected]>Cc Suzuki Poulose <[email protected]>Signed-off-by Anshuman Khandual <[email protected]>--- arch/arm64/Kconfig | 2 +- drivers/hwtracing/coresight/coresight-trbe.c | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-)arch/arm64/Kconfig +1
-1@@ -821,7 +821,7 @@ config ARM64_ERRATUM_2038923 config ARM64_ERRATUM_1902691 bool "Cortex-A510: 1902691: workaround TRBE trace corruption" - depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in + depends on CORESIGHT_TRBE default y help This option adds the workaround for ARM Cortex-A510 erratum 1902691.drivers/hwtracing/coresight/coresight-trbe.c +7
-0@@ -93,12 +93,14 @@ struct trbe_buf {#define TRBE_WORKAROUND_WRITE_OUT_OF_RANGE 1#define TRBE_NEEDS_DRAIN_AFTER_DISABLE 2#define TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE 3 +#define TRBE_IS_BROKEN 4static int trbe_errata_cpucaps[] = { [TRBE_WORKAROUND_OVERWRITE_FILL_MODE ] =ARM64_WORKAROUND_TRBE_OVERWRITE_FILL_MODE , [TRBE_WORKAROUND_WRITE_OUT_OF_RANGE ] =ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE , [TRBE_NEEDS_DRAIN_AFTER_DISABLE ] =ARM64_WORKAROUND_2064142 , [TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ] =ARM64_WORKAROUND_2038923 , + [TRBE_IS_BROKEN ] =ARM64_WORKAROUND_1902691 ,-1 ,/* Sentinel, must be the last entry */ };@@ -181,6 +183,11 @@ static inline bool trbe_needs_ctxt_sync_after_enable(struct trbe_cpudata *cpudatreturn trbe_has_erratum (cpudata,TRBE_NEEDS_CTXT_SYNC_AFTER_ENABLE ); } +static inline bool trbe_is_broken (struct trbe_cpudata *cpudata) +{ +return trbe_has_erratum (cpudata,TRBE_IS_BROKEN ); +} +static int trbe_alloc_node (struct perf_event *event) {if (event->cpu ==-1 )@@ -1288,6 +1295,11 @@ static void arm_trbe_probe_cpu(void *info)*/
drivers/hwtracing/coresight/coresight-trbe.c static void arm_trbe_probe_cpu(void *info) · line 1305
Quoted 10 lines
drivers/hwtracing/coresight/coresight-trbe.c +5
-0trbe_check_errata (cpudata); +if (trbe_is_broken (cpudata)) { +pr_err ("Disabling TRBE on cpu%d due to erratum\n" , cpu); + goto cpu_clear; + } +/* * If the TRBE is affected by erratum TRBE_WORKAROUND_OVERWRITE_FILL_MODE, * we must always program the TBRPTR_EL1, 256bytes from a page