Skip to content

Commit 8d81b2a

Browse files
Suzuki K Poulosewilldeacon
authored andcommitted
arm64: errata: Add detection for TRBE write to out-of-range
Arm Neoverse-N2 and Cortex-A710 cores are affected by an erratum where the trbe, under some circumstances, might write upto 64bytes to an address after the Limit as programmed by the TRBLIMITR_EL1.LIMIT. This might - - Corrupt a page in the ring buffer, which may corrupt trace from a previous session, consumed by userspace. - Hit the guard page at the end of the vmalloc area and raise a fault. To keep the handling simpler, we always leave the last page from the range, which TRBE is allowed to write. This can be achieved by ensuring that we always have more than a PAGE worth space in the range, while calculating the LIMIT for TRBE. And then the LIMIT pointer can be adjusted to leave the PAGE (TRBLIMITR.LIMIT -= PAGE_SIZE), out of the TRBE range while enabling it. This makes sure that the TRBE will only write to an area within its allowed limit (i.e, [head-head+size]) and we do not have to handle address faults within the driver. Cc: Anshuman Khandual <anshuman.khandual@arm.com> Cc: Mathieu Poirier <mathieu.poirier@linaro.org> Cc: Mike Leach <mike.leach@linaro.org> Cc: Leo Yan <leo.yan@linaro.org> Cc: Will Deacon <will@kernel.org> Cc: Mark Rutland <mark.rutland@arm.com> Reviewed-by: Anshuman Khandual <anshuman.khandual@arm.com> Reviewed-by: Mathieu Poirier <mathieu.poirier@linaro.org> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Signed-off-by: Suzuki K Poulose <suzuki.poulose@arm.com> Link: https://lore.kernel.org/r/20211019163153.3692640-5-suzuki.poulose@arm.com Signed-off-by: Will Deacon <will@kernel.org>
1 parent fa82d0b commit 8d81b2a

File tree

4 files changed

+66
-0
lines changed

4 files changed

+66
-0
lines changed

Documentation/arm64/silicon-errata.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ stable kernels.
9696
+----------------+-----------------+-----------------+-----------------------------+
9797
| ARM | Cortex-A710 | #2054223 | ARM64_ERRATUM_2054223 |
9898
+----------------+-----------------+-----------------+-----------------------------+
99+
| ARM | Cortex-A710 | #2224489 | ARM64_ERRATUM_2224489 |
100+
+----------------+-----------------+-----------------+-----------------------------+
99101
| ARM | Neoverse-N1 | #1188873,1418040| ARM64_ERRATUM_1418040 |
100102
+----------------+-----------------+-----------------+-----------------------------+
101103
| ARM | Neoverse-N1 | #1349291 | N/A |
@@ -106,6 +108,8 @@ stable kernels.
106108
+----------------+-----------------+-----------------+-----------------------------+
107109
| ARM | Neoverse-N2 | #2067961 | ARM64_ERRATUM_2067961 |
108110
+----------------+-----------------+-----------------+-----------------------------+
111+
| ARM | Neoverse-N2 | #2253138 | ARM64_ERRATUM_2253138 |
112+
+----------------+-----------------+-----------------+-----------------------------+
109113
| ARM | MMU-500 | #841119,826419 | N/A |
110114
+----------------+-----------------+-----------------+-----------------------------+
111115
+----------------+-----------------+-----------------+-----------------------------+

arch/arm64/Kconfig

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,47 @@ config ARM64_ERRATUM_2067961
740740

741741
If unsure, say Y.
742742

743+
config ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
744+
bool
745+
746+
config ARM64_ERRATUM_2253138
747+
bool "Neoverse-N2: 2253138: workaround TRBE writing to address out-of-range"
748+
depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in
749+
depends on CORESIGHT_TRBE
750+
default y
751+
select ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
752+
help
753+
This option adds the workaround for ARM Neoverse-N2 erratum 2253138.
754+
755+
Affected Neoverse-N2 cores might write to an out-of-range address, not reserved
756+
for TRBE. Under some conditions, the TRBE might generate a write to the next
757+
virtually addressed page following the last page of the TRBE address space
758+
(i.e., the TRBLIMITR_EL1.LIMIT), instead of wrapping around to the base.
759+
760+
Work around this in the driver by always making sure that there is a
761+
page beyond the TRBLIMITR_EL1.LIMIT, within the space allowed for the TRBE.
762+
763+
If unsure, say Y.
764+
765+
config ARM64_ERRATUM_2224489
766+
bool "Cortex-A710: 2224489: workaround TRBE writing to address out-of-range"
767+
depends on COMPILE_TEST # Until the CoreSight TRBE driver changes are in
768+
depends on CORESIGHT_TRBE
769+
default y
770+
select ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
771+
help
772+
This option adds the workaround for ARM Cortex-A710 erratum 2224489.
773+
774+
Affected Cortex-A710 cores might write to an out-of-range address, not reserved
775+
for TRBE. Under some conditions, the TRBE might generate a write to the next
776+
virtually addressed page following the last page of the TRBE address space
777+
(i.e., the TRBLIMITR_EL1.LIMIT), instead of wrapping around to the base.
778+
779+
Work around this in the driver by always making sure that there is a
780+
page beyond the TRBLIMITR_EL1.LIMIT, within the space allowed for the TRBE.
781+
782+
If unsure, say Y.
783+
743784
config CAVIUM_ERRATUM_22375
744785
bool "Cavium erratum 22375, 24313"
745786
default y

arch/arm64/kernel/cpu_errata.c

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,6 +364,18 @@ static const struct midr_range tsb_flush_fail_cpus[] = {
364364
};
365365
#endif /* CONFIG_ARM64_WORKAROUND_TSB_FLUSH_FAILURE */
366366

367+
#ifdef CONFIG_ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
368+
static struct midr_range trbe_write_out_of_range_cpus[] = {
369+
#ifdef CONFIG_ARM64_ERRATUM_2253138
370+
MIDR_ALL_VERSIONS(MIDR_NEOVERSE_N2),
371+
#endif
372+
#ifdef CONFIG_ARM64_ERRATUM_2224489
373+
MIDR_ALL_VERSIONS(MIDR_CORTEX_A710),
374+
#endif
375+
{},
376+
};
377+
#endif /* CONFIG_ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE */
378+
367379
const struct arm64_cpu_capabilities arm64_errata[] = {
368380
#ifdef CONFIG_ARM64_WORKAROUND_CLEAN_CACHE
369381
{
@@ -577,6 +589,14 @@ const struct arm64_cpu_capabilities arm64_errata[] = {
577589
.capability = ARM64_WORKAROUND_TSB_FLUSH_FAILURE,
578590
ERRATA_MIDR_RANGE_LIST(tsb_flush_fail_cpus),
579591
},
592+
#endif
593+
#ifdef CONFIG_ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
594+
{
595+
.desc = "ARM erratum 2253138 or 2224489",
596+
.capability = ARM64_WORKAROUND_TRBE_WRITE_OUT_OF_RANGE,
597+
.type = ARM64_CPUCAP_WEAK_LOCAL_CPU_FEATURE,
598+
CAP_MIDR_RANGE_LIST(trbe_write_out_of_range_cpus),
599+
},
580600
#endif
581601
{
582602
}

arch/arm64/tools/cpucaps

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ WORKAROUND_1508412
5555
WORKAROUND_1542419
5656
WORKAROUND_TRBE_OVERWRITE_FILL_MODE
5757
WORKAROUND_TSB_FLUSH_FAILURE
58+
WORKAROUND_TRBE_WRITE_OUT_OF_RANGE
5859
WORKAROUND_CAVIUM_23154
5960
WORKAROUND_CAVIUM_27456
6061
WORKAROUND_CAVIUM_30115

0 commit comments

Comments
 (0)