refactor(cpus): undo errata mitigations

The workarounds introduced in the three patches starting at
888eafa00b assumed that any powerdown
request will be (forced to be) terminal. This assumption can no longer
be the case for new CPUs so there is a need to revisit these older
cores. Since we may wake up, we now need to respect the workaround's
recommendation that the workaround needs to be reverted on wakeup. So do
exactly that.

Introduce a new helper to toggle bits in assembly. This allows us to
call the workaround twice, with the first call setting the workaround
and second undoing it. This is also used for gelas' an travis' powerdown
routines. This is so the same function can be called again

Also fix the condition in the cpu helper macro as it was subtly wrong

Change-Id: Iff9e5251dc9d8670d085d88c070f78991955e7c3
Signed-off-by: Boyan Karatotev <boyan.karatotev@arm.com>
This commit is contained in:
Boyan Karatotev 2024-09-26 17:00:09 +01:00
parent bb801857ea
commit cc94e71b3a
5 changed files with 13 additions and 2 deletions

View file

@ -463,7 +463,7 @@
* clobbers: x0-x10 (PCS compliant)
*/
.macro apply_erratum _cpu:req, _cve:req, _id:req, _chosen:req, _get_rev=GET_CPU_REV
.if (\_chosen & \_get_rev)
.if (\_chosen && \_get_rev)
mov x9, x30
bl cpu_get_rev_var
mov x10, x0

View file

@ -162,6 +162,7 @@ workaround_reset_end cortex_a710, ERRATUM(2282622)
check_erratum_ls cortex_a710, ERRATUM(2282622), CPU_REV(2, 1)
.global erratum_cortex_a710_2291219_wa
workaround_runtime_start cortex_a710, ERRATUM(2291219), ERRATA_A710_2291219
/* Set/unset bit 36 in ACTLR2_EL1. The first call will set it, applying
* the workaround. Second call clears it to undo it. */

View file

@ -52,6 +52,7 @@ workaround_runtime_end cortex_x3, ERRATUM(2302506), NO_ISB
check_erratum_ls cortex_x3, ERRATUM(2302506), CPU_REV(1, 1)
.global erratum_cortex_x3_2313909_wa
workaround_runtime_start cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909
/* Set/unset bit 36 in ACTLR2_EL1. The first call will set it, applying
* the workaround. Second call clears it to undo it. */

View file

@ -165,6 +165,7 @@ workaround_reset_end neoverse_n2, ERRATUM(2280757)
check_erratum_ls neoverse_n2, ERRATUM(2280757), CPU_REV(0, 0)
.global erratum_neoverse_n2_2326639_wa
workaround_runtime_start neoverse_n2, ERRATUM(2326639), ERRATA_N2_2326639
/* Set/unset bit 36 in ACTLR2_EL1. The first call will set it, applying
* the workaround. Second call clears it to undo it. */

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2014-2024, Arm Limited and Contributors. All rights reserved.
* Copyright (c) 2014-2025, Arm Limited and Contributors. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
@ -131,4 +131,12 @@ func psci_power_down_wfi
1:
wfi
b 1b
/*
* in case the WFI wasn't terminal, we have to undo errata mitigations.
* These will be smart enough to handle being called the same way
*/
apply_erratum cortex_a710, ERRATUM(2291219), ERRATA_A710_2291219
apply_erratum cortex_x3, ERRATUM(2313909), ERRATA_X3_2313909, NO_GET_CPU_REV
apply_erratum neoverse_n2, ERRATUM(2326639), ERRATA_N2_2326639, NO_GET_CPU_REV
endfunc psci_power_down_wfi