Skip to content

Commit d3d2a5a

Browse files
laurenw-armTrustedFirmware Code Review
authored andcommitted
Merge "fix(cpus): workaround for Cortex-X3 erratum 2615812" into integration
2 parents bf09c41 + c7e698c commit d3d2a5a

File tree

4 files changed

+55
-4
lines changed

4 files changed

+55
-4
lines changed

docs/design/cpu-specific-build-macros.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,10 @@ For Cortex-X3, the following errata build flags are defined :
601601
Cortex-X3 CPU. This needs to be enabled only for revisions r0p0 and r1p0
602602
of the CPU, it is fixed in r1p1.
603603

604+
- ``ERRATA_X3_2615812``: This applies errata 2615812 workaround to Cortex-X3
605+
CPU. This needs to be enabled only for revisions r0p0, r1p0 and r1p1 of the
606+
CPU, it is still open.
607+
604608
For Cortex-A510, the following errata build flags are defined :
605609

606610
- ``ERRATA_A510_1922240``: This applies errata 1922240 workaround to

include/lib/cpus/aarch64/cortex_x3.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#define CORTEX_X3_MIDR U(0x410FD4E0)
1111

1212
/* Cortex-X3 loop count for CVE-2022-23960 mitigation */
13-
#define CORTEX_X3_BHB_LOOP_COUNT U(132)
13+
#define CORTEX_X3_BHB_LOOP_COUNT U(132)
1414

1515
/*******************************************************************************
1616
* CPU Extended Control register specific definitions
@@ -20,8 +20,10 @@
2020
/*******************************************************************************
2121
* CPU Power Control register specific definitions
2222
******************************************************************************/
23-
#define CORTEX_X3_CPUPWRCTLR_EL1 S3_0_C15_C2_7
24-
#define CORTEX_X3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT U(1)
23+
#define CORTEX_X3_CPUPWRCTLR_EL1 S3_0_C15_C2_7
24+
#define CORTEX_X3_CPUPWRCTLR_EL1_CORE_PWRDN_BIT U(1)
25+
#define CORTEX_X3_CPUPWRCTLR_EL1_WFI_RET_CTRL_BITS_SHIFT U(4)
26+
#define CORTEX_X3_CPUPWRCTLR_EL1_WFE_RET_CTRL_BITS_SHIFT U(7)
2527

2628
/*******************************************************************************
2729
* CPU Auxiliary Control register 2 specific definitions.

lib/cpus/aarch64/cortex_x3.S

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ func check_errata_cve_2022_23960
5959
endfunc check_errata_cve_2022_23960
6060

6161
func cortex_x3_reset_func
62+
mov x19, x30
6263
/* Disable speculative loads */
6364
msr SSBS, xzr
6465

@@ -71,8 +72,14 @@ func cortex_x3_reset_func
7172
msr vbar_el3, x0
7273
#endif /* IMAGE_BL31 && WORKAROUND_CVE_2022_23960 */
7374

75+
bl cpu_get_rev_var
76+
77+
#if ERRATA_X3_2615812
78+
bl errata_cortex_x3_2615812_wa
79+
#endif /* ERRATA_X3_2615812 */
80+
7481
isb
75-
ret
82+
ret x19
7683
endfunc cortex_x3_reset_func
7784

7885
/* ----------------------------------------------------------------------
@@ -103,6 +110,35 @@ func check_errata_2313909
103110
b cpu_rev_var_ls
104111
endfunc check_errata_2313909
105112

113+
/* ----------------------------------------------------------------------
114+
* Errata Workaround for Cortex-X3 Erratum 2615812 on power-on.
115+
* This applies to revision r0p0, r1p0, r1p1 of Cortex-X3. Open.
116+
* Inputs:
117+
* x0: variant[4:7] and revision[0:3] of current cpu.
118+
* Shall clobber: x0-x1, x17
119+
* ----------------------------------------------------------------------
120+
*/
121+
func errata_cortex_x3_2615812_wa
122+
/* Check revision. */
123+
mov x17, x30
124+
bl check_errata_2615812
125+
cbz x0, 1f
126+
127+
/* Disable retention control for WFI and WFE. */
128+
mrs x0, CORTEX_X3_CPUPWRCTLR_EL1
129+
bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFI_RET_CTRL_BITS_SHIFT, #3
130+
bfi x0, xzr, #CORTEX_X3_CPUPWRCTLR_EL1_WFE_RET_CTRL_BITS_SHIFT, #3
131+
msr CORTEX_X3_CPUPWRCTLR_EL1, x0
132+
1:
133+
ret x17
134+
endfunc errata_cortex_x3_2615812_wa
135+
136+
func check_errata_2615812
137+
/* Applies to r1p1 and below. */
138+
mov x1, #0x11
139+
b cpu_rev_var_ls
140+
endfunc check_errata_2615812
141+
106142
#if REPORT_ERRATA
107143
/*
108144
* Errata printing function for Cortex-X3. Must follow AAPCS.
@@ -118,6 +154,7 @@ func cortex_x3_errata_report
118154
* checking functions of each errata.
119155
*/
120156
report_errata ERRATA_X3_2313909, cortex_x3, 2313909
157+
report_errata ERRATA_X3_2615812, cortex_x3, 2615812
121158
report_errata WORKAROUND_CVE_2022_23960, cortex_x3, cve_2022_23960
122159

123160
ldp x8, x30, [sp], #16

lib/cpus/cpu-ops.mk

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,10 @@ ERRATA_X2_2371105 ?=0
659659
# to revisions r0p0 and r1p0 of the Cortex-X3 cpu, it is fixed in r1p1.
660660
ERRATA_X3_2313909 ?=0
661661

662+
# Flag to apply erratum 2615812 workaround on powerdown. This erratum applies
663+
# to revisions r0p0, r1p0, r1p1 of the Cortex-X3 cpu, it is still open.
664+
ERRATA_X3_2615812 ?=0
665+
662666
# Flag to apply erratum 1922240 workaround during reset. This erratum applies
663667
# to revision r0p0 of the Cortex-A510 cpu and is fixed in r0p1.
664668
ERRATA_A510_1922240 ?=0
@@ -1288,6 +1292,10 @@ $(eval $(call add_define,ERRATA_X2_2371105))
12881292
$(eval $(call assert_boolean,ERRATA_X3_2313909))
12891293
$(eval $(call add_define,ERRATA_X3_2313909))
12901294

1295+
# Process ERRATA_X3_2615812 flag
1296+
$(eval $(call assert_boolean,ERRATA_X3_2615812))
1297+
$(eval $(call add_define,ERRATA_X3_2615812))
1298+
12911299
# Process ERRATA_A510_1922240 flag
12921300
$(eval $(call assert_boolean,ERRATA_A510_1922240))
12931301
$(eval $(call add_define,ERRATA_A510_1922240))

0 commit comments

Comments
 (0)