File tree Expand file tree Collapse file tree 6 files changed +23
-6
lines changed
Documentation/admin-guide Expand file tree Collapse file tree 6 files changed +23
-6
lines changed Original file line number Diff line number Diff line change @@ -439,10 +439,12 @@ The possible values in this file are:
439439 - System is protected by retpoline
440440 * - BHI: BHI_DIS_S
441441 - System is protected by BHI_DIS_S
442- * - BHI: SW loop
442+ * - BHI: SW loop; KVM SW loop
443443 - System is protected by software clearing sequence
444444 * - BHI: Syscall hardening
445445 - Syscalls are hardened against BHI
446+ * - BHI: Syscall hardening; KVM: SW loop
447+ - System is protected from userspace attacks by syscall hardening; KVM is protected by software clearing sequence
446448
447449Full mitigation might require a microcode update from the CPU
448450vendor. When the necessary microcode is not available, the kernel will
@@ -669,7 +671,8 @@ kernel command line.
669671 unconditionally disable.
670672 auto
671673 enable if hardware mitigation
672- control(BHI_DIS_S) is available.
674+ control(BHI_DIS_S) is available, otherwise
675+ enable alternate mitigation in KVM.
673676
674677For spectre_v2_user see Documentation/admin-guide/kernel-parameters.txt
675678
Original file line number Diff line number Diff line change 60716071
60726072 on - unconditionally enable.
60736073 off - unconditionally disable.
6074- auto - (default) enable only if hardware mitigation
6075- control(BHI_DIS_S) is available.
6074+ auto - (default) enable hardware mitigation
6075+ (BHI_DIS_S) if available, otherwise enable
6076+ alternate mitigation in KVM.
60766077
60776078 spectre_v2= [X86,EARLY] Control mitigation of Spectre variant 2
60786079 (indirect branch speculation) vulnerability.
Original file line number Diff line number Diff line change 469469#define X86_FEATURE_CLEAR_BHB_LOOP (21*32+ 1) /* "" Clear branch history at syscall entry using SW loop */
470470#define X86_FEATURE_BHI_CTRL (21*32+ 2) /* "" BHI_DIS_S HW control available */
471471#define X86_FEATURE_CLEAR_BHB_HW (21*32+ 3) /* "" BHI_DIS_S HW control enabled */
472+ #define X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT (21*32+ 4) /* "" Clear branch history at vmexit using SW loop */
472473
473474/*
474475 * BUG word(s)
Original file line number Diff line number Diff line change 330330.macro CLEAR_BRANCH_HISTORY
331331 ALTERNATIVE "" , "call clear_bhb_loop" , X86_FEATURE_CLEAR_BHB_LOOP
332332.endm
333+
334+ .macro CLEAR_BRANCH_HISTORY_VMEXIT
335+ ALTERNATIVE "" , "call clear_bhb_loop" , X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT
336+ .endm
333337#else
334338#define CLEAR_BRANCH_HISTORY
339+ #define CLEAR_BRANCH_HISTORY_VMEXIT
335340#endif
336341
337342#else /* __ASSEMBLY__ */
Original file line number Diff line number Diff line change @@ -1668,9 +1668,14 @@ static void __init bhi_select_mitigation(void)
16681668 if (!IS_ENABLED (CONFIG_X86_64 ))
16691669 return ;
16701670
1671+ /* Mitigate KVM by default */
1672+ setup_force_cpu_cap (X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT );
1673+ pr_info ("Spectre BHI mitigation: SW BHB clearing on vm exit\n" );
1674+
16711675 if (bhi_mitigation == BHI_MITIGATION_AUTO )
16721676 return ;
16731677
1678+ /* Mitigate syscalls when the mitigation is forced =on */
16741679 setup_force_cpu_cap (X86_FEATURE_CLEAR_BHB_LOOP );
16751680 pr_info ("Spectre BHI mitigation: SW BHB clearing on syscall\n" );
16761681}
@@ -2811,10 +2816,12 @@ static const char * const spectre_bhi_state(void)
28112816 else if (boot_cpu_has (X86_FEATURE_CLEAR_BHB_HW ))
28122817 return "; BHI: BHI_DIS_S" ;
28132818 else if (boot_cpu_has (X86_FEATURE_CLEAR_BHB_LOOP ))
2814- return "; BHI: SW loop" ;
2819+ return "; BHI: SW loop, KVM: SW loop " ;
28152820 else if (boot_cpu_has (X86_FEATURE_RETPOLINE ) &&
28162821 !(x86_read_arch_cap_msr () & ARCH_CAP_RRSBA ))
28172822 return "; BHI: Retpoline" ;
2823+ else if (boot_cpu_has (X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT ))
2824+ return "; BHI: Syscall hardening, KVM: SW loop" ;
28182825
28192826 return "; BHI: Vulnerable (Syscall hardening enabled)" ;
28202827}
Original file line number Diff line number Diff line change @@ -275,7 +275,7 @@ SYM_INNER_LABEL_ALIGN(vmx_vmexit, SYM_L_GLOBAL)
275275
276276 call vmx_spec_ctrl_restore_host
277277
278- CLEAR_BRANCH_HISTORY
278+ CLEAR_BRANCH_HISTORY_VMEXIT
279279
280280 /* Put return value in AX */
281281 mov %_ASM_BX, %_ASM_AX
You can’t perform that action at this time.
0 commit comments