Bipin Ravi | 8649974 | 2022-01-18 01:59:06 -0600 | [diff] [blame] | 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-x3 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 | stp x2, x3, [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 | dsb sy |
| 28 | isb |
| 29 | ldp x2, x3, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2] |
| 30 | .endm |
| 31 | #endif /* WORKAROUND_CVE_2022_23960 */ |