blob: bf266583c84c0f82ef0136c7570309bcafe219b3 [file] [log] [blame]
Bipin Ravi86499742022-01-18 01:59:06 -06001/*
Govindraj Rajaeee28e72023-08-01 15:52:40 -05002 * Copyright (c) 2022, Arm Limited and Contributors. All rights reserved.
Bipin Ravi86499742022-01-18 01:59:06 -06003 *
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.
Bipin Ravi9ee6dd42022-10-13 17:25:51 -050012 * The macro saves x2 to the CPU context.
Bipin Ravi86499742022-01-18 01:59:06 -060013 * SP should point to the CPU context.
14 */
15 .macro apply_cve_2022_23960_bhb_wa _bhb_loop_count
Bipin Ravi9ee6dd42022-10-13 17:25:51 -050016 str x2, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
Bipin Ravi86499742022-01-18 01:59:06 -060017
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
Bipin Ravi9ee6dd42022-10-13 17:25:51 -050027 speculation_barrier
28 ldr x2, [sp, #CTX_GPREGS_OFFSET + CTX_GPREG_X2]
Bipin Ravi86499742022-01-18 01:59:06 -060029 .endm
30#endif /* WORKAROUND_CVE_2022_23960 */