]> xenbits.xensource.com Git - xen.git/commit
xen/arm: Add Spectre BHB handling
authorRahul Singh <rahul.singh@arm.com>
Mon, 14 Feb 2022 18:47:32 +0000 (18:47 +0000)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Tue, 8 Mar 2022 17:12:50 +0000 (17:12 +0000)
commitd340fad8be324e1760ea29d7c25658a8aec83306
treebcd804e043e17a26f2244b65284304c3fdbd4065
parent2e519fd8c1e3e7ae5370a6638615d2a52169db28
xen/arm: Add Spectre BHB handling

This commit is adding Spectre BHB handling to Xen on Arm.
The commit is introducing new alternative code to be executed during
exception entry:
- SMCC workaround 3 call
- loop workaround (with 8, 24 or 32 iterations)
- use of new clearbhb instruction

Cpuerrata is modified by this patch to apply the required workaround for
CPU affected by Spectre BHB when CONFIG_ARM64_HARDEN_BRANCH_PREDICTOR is
enabled.

To do this the system previously used to apply smcc workaround 1 is
reused and new alternative code to be copied in the exception handler is
introduced.

To define the type of workaround required by a processor, 4 new cpu
capabilities are introduced (for each number of loop and for smcc
workaround 3).

When a processor is affected, enable_spectre_bhb_workaround is called
and if the processor does not have CSV2 set to 3 or ECBHB feature (which
would mean that the processor is doing what is required in hardware),
the proper code is enabled at exception entry.

In the case where workaround 3 is not supported by the firmware, we
enable workaround 1 when possible as it will also mitigate Spectre BHB
on systems without CSV2.

This is part of XSA-398 / CVE-2022-23960.

Signed-off-by: Bertrand Marquis <bertrand.marquis@arm.com>
Signed-off-by: Rahul Singh <rahul.singh@arm.com>
Acked-by: Julien Grall <julien@xen.org>
(cherry picked from commit 62c91eb66a2904eefb1d1d9642e3697a1e3c3a3c)
xen/arch/arm/arm64/bpi.S
xen/arch/arm/cpuerrata.c
xen/include/asm-arm/arm64/macros.h
xen/include/asm-arm/cpufeature.h
xen/include/asm-arm/smccc.h