Skip to content

Commit acce5ee

Browse files
committed
x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI
jira LE-2015 cve {CVE-2024-2201 cve RHEL-28203] cve [RHEL-45492 cve Long) cve (Waiman cve CONFIG_MITIGATION_SPECTRE_BHI cve with cve ON,OFF Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4 commit-author Josh Poimboeuf <[email protected]> commit 4f51173 Empty-Commit: Cherry-Pick Conflicts during history rebuild. Will be included in final tarball splat. Ref for failed cherry-pick at: ciq/ciq_backports/kernel-5.14.0-427.42.1.el9_4/4f511739.failed For consistency with the other CONFIG_MITIGATION_* options, replace the CONFIG_SPECTRE_BHI_{ON,OFF} options with a single CONFIG_MITIGATION_SPECTRE_BHI option. [ mingo: Fix ] Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Linus Torvalds <[email protected]> Cc: Nikolay Borisov <[email protected]> Link: https://lore.kernel.org/r/3833812ea63e7fdbe36bf8b932e63f70d18e2a2a.1712813475.git.jpoimboe@kernel.org (cherry picked from commit 4f51173) Signed-off-by: Jonathan Maple <[email protected]> # Conflicts: # arch/x86/Kconfig # arch/x86/kernel/cpu/bugs.c
1 parent a99ddaf commit acce5ee

File tree

1 file changed

+143
-0
lines changed

1 file changed

+143
-0
lines changed
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI
2+
3+
jira LE-2015
4+
cve {CVE-2024-2201
5+
cve RHEL-28203]
6+
cve [RHEL-45492
7+
cve Long)
8+
cve (Waiman
9+
cve CONFIG_MITIGATION_SPECTRE_BHI
10+
cve with
11+
cve ON,OFF
12+
Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4
13+
commit-author Josh Poimboeuf <[email protected]>
14+
commit 4f511739c54b549061993b53fc0380f48dfca23b
15+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
16+
Will be included in final tarball splat. Ref for failed cherry-pick at:
17+
ciq/ciq_backports/kernel-5.14.0-427.42.1.el9_4/4f511739.failed
18+
19+
For consistency with the other CONFIG_MITIGATION_* options, replace the
20+
CONFIG_SPECTRE_BHI_{ON,OFF} options with a single
21+
CONFIG_MITIGATION_SPECTRE_BHI option.
22+
23+
[ mingo: Fix ]
24+
25+
Signed-off-by: Josh Poimboeuf <[email protected]>
26+
Signed-off-by: Ingo Molnar <[email protected]>
27+
Cc: Sean Christopherson <[email protected]>
28+
Cc: Linus Torvalds <[email protected]>
29+
Cc: Nikolay Borisov <[email protected]>
30+
Link: https://lore.kernel.org/r/3833812ea63e7fdbe36bf8b932e63f70d18e2a2a.1712813475.git.jpoimboe@kernel.org
31+
(cherry picked from commit 4f511739c54b549061993b53fc0380f48dfca23b)
32+
Signed-off-by: Jonathan Maple <[email protected]>
33+
34+
# Conflicts:
35+
# arch/x86/Kconfig
36+
# arch/x86/kernel/cpu/bugs.c
37+
diff --cc arch/x86/Kconfig
38+
index 2e3190218496,4474bf32d0a4..000000000000
39+
--- a/arch/x86/Kconfig
40+
+++ b/arch/x86/Kconfig
41+
@@@ -2641,6 -2633,16 +2641,19 @@@ config MITIGATION_RFD
42+
stored in floating point, vector and integer registers.
43+
See also <file:Documentation/admin-guide/hw-vuln/reg-file-data-sampling.rst>
44+
45+
++<<<<<<< HEAD
46+
++=======
47+
+ config MITIGATION_SPECTRE_BHI
48+
+ bool "Mitigate Spectre-BHB (Branch History Injection)"
49+
+ depends on CPU_SUP_INTEL
50+
+ default y
51+
+ help
52+
+ Enable BHI mitigations. BHI attacks are a form of Spectre V2 attacks
53+
+ where the branch history buffer is poisoned to speculatively steer
54+
+ indirect branches.
55+
+ See <file:Documentation/admin-guide/hw-vuln/spectre.rst>
56+
+
57+
++>>>>>>> 4f511739c54b (x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI)
58+
endif
59+
60+
config ARCH_HAS_ADD_PAGES
61+
diff --cc arch/x86/kernel/cpu/bugs.c
62+
index d1c0c8f6898b,ca295b0c1eee..000000000000
63+
--- a/arch/x86/kernel/cpu/bugs.c
64+
+++ b/arch/x86/kernel/cpu/bugs.c
65+
@@@ -1612,6 -1606,73 +1612,76 @@@ static void __init spectre_v2_determine
66+
dump_stack();
67+
}
68+
69+
++<<<<<<< HEAD
70+
++=======
71+
+ /*
72+
+ * Set BHI_DIS_S to prevent indirect branches in kernel to be influenced by
73+
+ * branch history in userspace. Not needed if BHI_NO is set.
74+
+ */
75+
+ static bool __init spec_ctrl_bhi_dis(void)
76+
+ {
77+
+ if (!boot_cpu_has(X86_FEATURE_BHI_CTRL))
78+
+ return false;
79+
+
80+
+ x86_spec_ctrl_base |= SPEC_CTRL_BHI_DIS_S;
81+
+ update_spec_ctrl(x86_spec_ctrl_base);
82+
+ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_HW);
83+
+
84+
+ return true;
85+
+ }
86+
+
87+
+ enum bhi_mitigations {
88+
+ BHI_MITIGATION_OFF,
89+
+ BHI_MITIGATION_ON,
90+
+ };
91+
+
92+
+ static enum bhi_mitigations bhi_mitigation __ro_after_init =
93+
+ IS_ENABLED(CONFIG_MITIGATION_SPECTRE_BHI) ? BHI_MITIGATION_ON : BHI_MITIGATION_OFF;
94+
+
95+
+ static int __init spectre_bhi_parse_cmdline(char *str)
96+
+ {
97+
+ if (!str)
98+
+ return -EINVAL;
99+
+
100+
+ if (!strcmp(str, "off"))
101+
+ bhi_mitigation = BHI_MITIGATION_OFF;
102+
+ else if (!strcmp(str, "on"))
103+
+ bhi_mitigation = BHI_MITIGATION_ON;
104+
+ else
105+
+ pr_err("Ignoring unknown spectre_bhi option (%s)", str);
106+
+
107+
+ return 0;
108+
+ }
109+
+ early_param("spectre_bhi", spectre_bhi_parse_cmdline);
110+
+
111+
+ static void __init bhi_select_mitigation(void)
112+
+ {
113+
+ if (bhi_mitigation == BHI_MITIGATION_OFF)
114+
+ return;
115+
+
116+
+ /* Retpoline mitigates against BHI unless the CPU has RRSBA behavior */
117+
+ if (cpu_feature_enabled(X86_FEATURE_RETPOLINE)) {
118+
+ spec_ctrl_disable_kernel_rrsba();
119+
+ if (rrsba_disabled)
120+
+ return;
121+
+ }
122+
+
123+
+ if (spec_ctrl_bhi_dis())
124+
+ return;
125+
+
126+
+ if (!IS_ENABLED(CONFIG_X86_64))
127+
+ return;
128+
+
129+
+ /* Mitigate KVM by default */
130+
+ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT);
131+
+ pr_info("Spectre BHI mitigation: SW BHB clearing on vm exit\n");
132+
+
133+
+ /* Mitigate syscalls when the mitigation is forced =on */
134+
+ setup_force_cpu_cap(X86_FEATURE_CLEAR_BHB_LOOP);
135+
+ pr_info("Spectre BHI mitigation: SW BHB clearing on syscall\n");
136+
+ }
137+
+
138+
++>>>>>>> 4f511739c54b (x86/bugs: Replace CONFIG_SPECTRE_BHI_{ON,OFF} with CONFIG_MITIGATION_SPECTRE_BHI)
139+
static void __init spectre_v2_select_mitigation(void)
140+
{
141+
enum spectre_v2_mitigation_cmd cmd = spectre_v2_parse_cmdline();
142+
* Unmerged path arch/x86/Kconfig
143+
* Unmerged path arch/x86/kernel/cpu/bugs.c

0 commit comments

Comments
 (0)