Skip to content

Commit 49cca5b

Browse files
committed
x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr'
jira LE-2015 cve CVE-2024-2201 Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4 commit-author Ingo Molnar <mingo@kernel.org> commit d048573 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/d0485730.failed So we are using the 'ia32_cap' value in a number of places, which got its name from MSR_IA32_ARCH_CAPABILITIES MSR register. But there's very little 'IA32' about it - this isn't 32-bit only code, nor does it originate from there, it's just a historic quirk that many Intel MSR names are prefixed with IA32_. This is already clear from the helper method around the MSR: x86_read_arch_cap_msr(), which doesn't have the IA32 prefix. So rename 'ia32_cap' to 'x86_arch_cap_msr' to be consistent with its role and with the naming of the helper function. Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Nikolay Borisov <nik.borisov@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Sean Christopherson <seanjc@google.com> Link: https://lore.kernel.org/r/9592a18a814368e75f8f4b9d74d3883aa4fd1eaf.1712813475.git.jpoimboe@kernel.org (cherry picked from commit d048573) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # arch/x86/kernel/apic/apic.c # arch/x86/kernel/cpu/bugs.c # arch/x86/kernel/cpu/common.c
1 parent 27aa4d5 commit 49cca5b

File tree

1 file changed

+213
-0
lines changed

1 file changed

+213
-0
lines changed
Lines changed: 213 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,213 @@
1+
x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr'
2+
3+
jira LE-2015
4+
cve CVE-2024-2201
5+
Rebuild_History Non-Buildable kernel-5.14.0-427.42.1.el9_4
6+
commit-author Ingo Molnar <mingo@kernel.org>
7+
commit d0485730d2189ffe5d986d4e9e191f1e4d5ffd24
8+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
9+
Will be included in final tarball splat. Ref for failed cherry-pick at:
10+
ciq/ciq_backports/kernel-5.14.0-427.42.1.el9_4/d0485730.failed
11+
12+
So we are using the 'ia32_cap' value in a number of places,
13+
which got its name from MSR_IA32_ARCH_CAPABILITIES MSR register.
14+
15+
But there's very little 'IA32' about it - this isn't 32-bit only
16+
code, nor does it originate from there, it's just a historic
17+
quirk that many Intel MSR names are prefixed with IA32_.
18+
19+
This is already clear from the helper method around the MSR:
20+
x86_read_arch_cap_msr(), which doesn't have the IA32 prefix.
21+
22+
So rename 'ia32_cap' to 'x86_arch_cap_msr' to be consistent with
23+
its role and with the naming of the helper function.
24+
25+
Signed-off-by: Ingo Molnar <mingo@kernel.org>
26+
Cc: Josh Poimboeuf <jpoimboe@redhat.com>
27+
Cc: Nikolay Borisov <nik.borisov@suse.com>
28+
Cc: Linus Torvalds <torvalds@linux-foundation.org>
29+
Cc: Sean Christopherson <seanjc@google.com>
30+
Link: https://lore.kernel.org/r/9592a18a814368e75f8f4b9d74d3883aa4fd1eaf.1712813475.git.jpoimboe@kernel.org
31+
(cherry picked from commit d0485730d2189ffe5d986d4e9e191f1e4d5ffd24)
32+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
33+
34+
# Conflicts:
35+
# arch/x86/kernel/apic/apic.c
36+
# arch/x86/kernel/cpu/bugs.c
37+
# arch/x86/kernel/cpu/common.c
38+
diff --cc arch/x86/kernel/apic/apic.c
39+
index 2dc0943c5bd4,c342c4aa9c68..000000000000
40+
--- a/arch/x86/kernel/apic/apic.c
41+
+++ b/arch/x86/kernel/apic/apic.c
42+
@@@ -1752,6 -1685,19 +1752,22 @@@ enum
43+
};
44+
static int x2apic_state;
45+
46+
++<<<<<<< HEAD
47+
++=======
48+
+ static bool x2apic_hw_locked(void)
49+
+ {
50+
+ u64 x86_arch_cap_msr;
51+
+ u64 msr;
52+
+
53+
+ x86_arch_cap_msr = x86_read_arch_cap_msr();
54+
+ if (x86_arch_cap_msr & ARCH_CAP_XAPIC_DISABLE) {
55+
+ rdmsrl(MSR_IA32_XAPIC_DISABLE_STATUS, msr);
56+
+ return (msr & LEGACY_XAPIC_DISABLED);
57+
+ }
58+
+ return false;
59+
+ }
60+
+
61+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
62+
static void __x2apic_disable(void)
63+
{
64+
u64 msr;
65+
diff --cc arch/x86/kernel/cpu/bugs.c
66+
index d1c0c8f6898b,1b0cfc136432..000000000000
67+
--- a/arch/x86/kernel/cpu/bugs.c
68+
+++ b/arch/x86/kernel/cpu/bugs.c
69+
@@@ -61,6 -61,8 +61,11 @@@ EXPORT_SYMBOL_GPL(x86_spec_ctrl_current
70+
u64 x86_pred_cmd __ro_after_init = PRED_CMD_IBPB;
71+
EXPORT_SYMBOL_GPL(x86_pred_cmd);
72+
73+
++<<<<<<< HEAD
74+
++=======
75+
+ static u64 __ro_after_init x86_arch_cap_msr;
76+
+
77+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
78+
static DEFINE_MUTEX(spec_ctrl_mutex);
79+
80+
void (*x86_return_thunk)(void) __ro_after_init = __x86_return_thunk;
81+
@@@ -144,6 -146,8 +149,11 @@@ void __init cpu_select_mitigations(void
82+
x86_spec_ctrl_base &= ~SPEC_CTRL_MITIGATIONS_MASK;
83+
}
84+
85+
++<<<<<<< HEAD
86+
++=======
87+
+ x86_arch_cap_msr = x86_read_arch_cap_msr();
88+
+
89+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
90+
/* Select the proper CPU mitigations before patching alternatives: */
91+
spectre_v1_select_mitigation();
92+
spectre_v2_select_mitigation();
93+
@@@ -341,9 -343,8 +351,14 @@@ static void __init taa_select_mitigatio
94+
* On MDS_NO=1 CPUs if ARCH_CAP_TSX_CTRL_MSR is not set, microcode
95+
* update is required.
96+
*/
97+
++<<<<<<< HEAD
98+
+ ia32_cap = x86_read_arch_cap_msr();
99+
+ if ( (ia32_cap & ARCH_CAP_MDS_NO) &&
100+
+ !(ia32_cap & ARCH_CAP_TSX_CTRL_MSR))
101+
++=======
102+
+ if ( (x86_arch_cap_msr & ARCH_CAP_MDS_NO) &&
103+
+ !(x86_arch_cap_msr & ARCH_CAP_TSX_CTRL_MSR))
104+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
105+
taa_mitigation = TAA_MITIGATION_UCODE_NEEDED;
106+
107+
/*
108+
@@@ -508,7 -505,7 +523,11 @@@ static void __init rfds_select_mitigati
109+
if (rfds_mitigation == RFDS_MITIGATION_OFF)
110+
return;
111+
112+
++<<<<<<< HEAD
113+
+ if (x86_read_arch_cap_msr() & ARCH_CAP_RFDS_CLEAR)
114+
++=======
115+
+ if (x86_arch_cap_msr & ARCH_CAP_RFDS_CLEAR)
116+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
117+
setup_force_cpu_cap(X86_FEATURE_CLEAR_CPU_BUF);
118+
else
119+
rfds_mitigation = RFDS_MITIGATION_UCODE_NEEDED;
120+
@@@ -669,8 -664,7 +688,12 @@@ static void __init srbds_select_mitigat
121+
* are only exposed to SRBDS when TSX is enabled or when CPU is affected
122+
* by Processor MMIO Stale Data vulnerability.
123+
*/
124+
++<<<<<<< HEAD
125+
+ ia32_cap = x86_read_arch_cap_msr();
126+
+ if ((ia32_cap & ARCH_CAP_MDS_NO) && !boot_cpu_has(X86_FEATURE_RTM) &&
127+
++=======
128+
+ if ((x86_arch_cap_msr & ARCH_CAP_MDS_NO) && !boot_cpu_has(X86_FEATURE_RTM) &&
129+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
130+
!boot_cpu_has_bug(X86_BUG_MMIO_STALE_DATA))
131+
srbds_mitigation = SRBDS_MITIGATION_TSX_OFF;
132+
else if (boot_cpu_has(X86_FEATURE_HYPERVISOR))
133+
@@@ -813,7 -807,7 +836,11 @@@ static void __init gds_select_mitigatio
134+
/* Will verify below that mitigation _can_ be disabled */
135+
136+
/* No microcode */
137+
++<<<<<<< HEAD
138+
+ if (!(x86_read_arch_cap_msr() & ARCH_CAP_GDS_CTRL)) {
139+
++=======
140+
+ if (!(x86_arch_cap_msr & ARCH_CAP_GDS_CTRL)) {
141+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
142+
if (gds_mitigation == GDS_MITIGATION_FORCE) {
143+
/*
144+
* This only needs to be done on the boot CPU so do it
145+
@@@ -2814,6 -2801,23 +2841,26 @@@ static char *pbrsb_eibrs_state(void
146+
}
147+
}
148+
149+
++<<<<<<< HEAD
150+
++=======
151+
+ static const char *spectre_bhi_state(void)
152+
+ {
153+
+ if (!boot_cpu_has_bug(X86_BUG_BHI))
154+
+ return "; BHI: Not affected";
155+
+ else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_HW))
156+
+ return "; BHI: BHI_DIS_S";
157+
+ else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP))
158+
+ return "; BHI: SW loop, KVM: SW loop";
159+
+ else if (boot_cpu_has(X86_FEATURE_RETPOLINE) &&
160+
+ !(x86_arch_cap_msr & ARCH_CAP_RRSBA))
161+
+ return "; BHI: Retpoline";
162+
+ else if (boot_cpu_has(X86_FEATURE_CLEAR_BHB_LOOP_ON_VMEXIT))
163+
+ return "; BHI: Syscall hardening, KVM: SW loop";
164+
+
165+
+ return "; BHI: Vulnerable (Syscall hardening enabled)";
166+
+ }
167+
+
168+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
169+
static ssize_t spectre_v2_show_state(char *buf)
170+
{
171+
if (spectre_v2_enabled == SPECTRE_V2_LFENCE)
172+
diff --cc arch/x86/kernel/cpu/common.c
173+
index d70234c30213,605c26c009c8..000000000000
174+
--- a/arch/x86/kernel/cpu/common.c
175+
+++ b/arch/x86/kernel/cpu/common.c
176+
@@@ -1461,11 -1342,16 +1461,17 @@@ static void __init cpu_set_bug_bits(str
177+
/*
178+
* AMD's AutoIBRS is equivalent to Intel's eIBRS - use the Intel feature
179+
* flag and protect from vendor-specific bugs via the whitelist.
180+
- *
181+
- * Don't use AutoIBRS when SNP is enabled because it degrades host
182+
- * userspace indirect branch performance.
183+
*/
184+
++<<<<<<< HEAD
185+
+ if ((ia32_cap & ARCH_CAP_IBRS_ALL) || cpu_has(c, X86_FEATURE_AUTOIBRS)) {
186+
++=======
187+
+ if ((x86_arch_cap_msr & ARCH_CAP_IBRS_ALL) ||
188+
+ (cpu_has(c, X86_FEATURE_AUTOIBRS) &&
189+
+ !cpu_feature_enabled(X86_FEATURE_SEV_SNP))) {
190+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
191+
setup_force_cpu_cap(X86_FEATURE_IBRS_ENHANCED);
192+
if (!cpu_matches(cpu_vuln_whitelist, NO_EIBRS_PBRSB) &&
193+
- !(ia32_cap & ARCH_CAP_PBRSB_NO))
194+
+ !(x86_arch_cap_msr & ARCH_CAP_PBRSB_NO))
195+
setup_force_cpu_bug(X86_BUG_EIBRS_PBRSB);
196+
}
197+
198+
@@@ -1525,8 -1411,7 +1531,12 @@@
199+
}
200+
201+
if (!cpu_has(c, X86_FEATURE_BTC_NO)) {
202+
++<<<<<<< HEAD
203+
+ if (cpu_matches(cpu_vuln_blacklist, RETBLEED) ||
204+
+ ((ia32_cap & ARCH_CAP_RSBA) && !cpu_in_retbleed_whitelist(c)))
205+
++=======
206+
+ if (cpu_matches(cpu_vuln_blacklist, RETBLEED) || (x86_arch_cap_msr & ARCH_CAP_RSBA))
207+
++>>>>>>> d0485730d218 (x86/bugs: Rename various 'ia32_cap' variables to 'x86_arch_cap_msr')
208+
setup_force_cpu_bug(X86_BUG_RETBLEED);
209+
}
210+
211+
* Unmerged path arch/x86/kernel/apic/apic.c
212+
* Unmerged path arch/x86/kernel/cpu/bugs.c
213+
* Unmerged path arch/x86/kernel/cpu/common.c

0 commit comments

Comments
 (0)