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