| 1 |
/* |
| 2 |
* Copyright (c) 2022, Arm Limited and Contributors. All rights reserved. |
| 3 |
* |
| 4 |
* SPDX-License-Identifier: BSD-3-Clause |
| 5 |
*/ |
| 6 |
|
| 7 |
#include <context.h> |
| 8 |
|
| 9 |
#if WORKAROUND_CVE_2022_23960 |
| 10 |
/* |
| 11 |
* This macro applies the mitigation for CVE-2022-23960. |
| 12 |
* The macro saves x2 to the CPU context. |
| 13 |
* SP should point to the CPU context. |
| 14 |
*/ |
| 15 |
.macro apply_cve_2022_23960_bhb_wa _bhb_loop_count |
| 16 |
str x2, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] |
| 17 |
|
| 18 |
/* CVE-BHB-NUM loop count */ |
| 19 |
mov x2, \_bhb_loop_count |
| 20 |
|
| 21 |
1: |
| 22 |
/* b pc+4 part of the workaround */ |
| 23 |
b 2f |
| 24 |
2: |
| 25 |
subs x2, x2, #1 |
| 26 |
bne 1b |
| 27 |
speculation_barrier |
| 28 |
ldr x2, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] |
| 29 |
.endm |
| 30 |
#endif /* WORKAROUND_CVE_2022_23960 */ |