blob: e0e41cc47ccf1aa4f32444a3642d3747c277a7ad [file] [log] [blame]
Bipin Ravi86499742022-01-18 01:59:06 -06001/*
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
211:
22 /* b pc+4 part of the workaround */
23 b 2f
242:
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 */