Skip to content

Commit 4b579a4

Browse files
committed
x86/cpu: Add cpu_type to struct x86_cpu_id
jira LE-4018 Rebuild_History Non-Buildable kernel-5.14.0-570.37.1.el9_6 commit-author Pawan Gupta <pawan.kumar.gupta@linux.intel.com> commit 00d7fc0 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-570.37.1.el9_6/00d7fc04.failed In addition to matching vendor/family/model/feature, for hybrid variants it is required to also match cpu-type. For example, some CPU vulnerabilities like RFDS only affect a specific cpu-type. To be able to also match CPUs based on their type, add a new field "type" to struct x86_cpu_id which is used by the CPU-matching tables. Introduce X86_CPU_TYPE_ANY for the cases that don't care about the cpu-type. [ bp: Massage commit message. ] Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com> Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de> Signed-off-by: Ingo Molnar <mingo@kernel.org> Acked-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/r/20250311-add-cpu-type-v8-3-e8514dcaaff2@linux.intel.com (cherry picked from commit 00d7fc0) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # arch/x86/include/asm/cpu_device_id.h
1 parent 61134e5 commit 4b579a4

File tree

1 file changed

+306
-0
lines changed

1 file changed

+306
-0
lines changed
Lines changed: 306 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,306 @@
1+
x86/cpu: Add cpu_type to struct x86_cpu_id
2+
3+
jira LE-4018
4+
Rebuild_History Non-Buildable kernel-5.14.0-570.37.1.el9_6
5+
commit-author Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
6+
commit 00d7fc04b703eb3e9d61dd3eac02a34c466e9f12
7+
Empty-Commit: Cherry-Pick Conflicts during history rebuild.
8+
Will be included in final tarball splat. Ref for failed cherry-pick at:
9+
ciq/ciq_backports/kernel-5.14.0-570.37.1.el9_6/00d7fc04.failed
10+
11+
In addition to matching vendor/family/model/feature, for hybrid variants it is
12+
required to also match cpu-type. For example, some CPU vulnerabilities like
13+
RFDS only affect a specific cpu-type.
14+
15+
To be able to also match CPUs based on their type, add a new field "type" to
16+
struct x86_cpu_id which is used by the CPU-matching tables. Introduce
17+
X86_CPU_TYPE_ANY for the cases that don't care about the cpu-type.
18+
19+
[ bp: Massage commit message. ]
20+
21+
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
22+
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
23+
Signed-off-by: Ingo Molnar <mingo@kernel.org>
24+
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
25+
Link: https://lore.kernel.org/r/20250311-add-cpu-type-v8-3-e8514dcaaff2@linux.intel.com
26+
(cherry picked from commit 00d7fc04b703eb3e9d61dd3eac02a34c466e9f12)
27+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
28+
29+
# Conflicts:
30+
# arch/x86/include/asm/cpu_device_id.h
31+
diff --cc arch/x86/include/asm/cpu_device_id.h
32+
index f794121850a7,6be777a06944..000000000000
33+
--- a/arch/x86/include/asm/cpu_device_id.h
34+
+++ b/arch/x86/include/asm/cpu_device_id.h
35+
@@@ -75,19 -74,7 +75,23 @@@
36+
* into another macro at the usage site for good reasons, then please
37+
* start this local macro with X86_MATCH to allow easy grepping.
38+
*/
39+
++<<<<<<< HEAD
40+
+#define X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
41+
+ _steppings, _feature, _data) { \
42+
+ .vendor = X86_VENDOR_##_vendor, \
43+
+ .family = _family, \
44+
+ .model = _model, \
45+
+ .steppings = _steppings, \
46+
+ .feature = _feature, \
47+
+ .flags = X86_CPU_ID_FLAG_ENTRY_VALID, \
48+
+ .driver_data = (unsigned long) _data \
49+
+}
50+
+
51+
+#define X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE(_vendor, _family, _model, \
52+
+ _steppings, _feature, _data) { \
53+
++=======
54+
+ #define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _type, _data) { \
55+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
56+
.vendor = _vendor, \
57+
.family = _family, \
58+
.model = _model, \
59+
@@@ -124,13 -94,10 +129,19 @@@
60+
* @data: Driver specific data or NULL. The internal storage
61+
* format is unsigned long. The supplied value, pointer
62+
* etc. is casted to unsigned long internally.
63+
+ *
64+
+ * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
65+
+ * set to wildcards.
66+
*/
67+
++<<<<<<< HEAD
68+
+#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
69+
+ X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, \
70+
+ X86_MODEL_ANY, feature, data)
71+
++=======
72+
+ #define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
73+
+ X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
74+
+ X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
75+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
76+
77+
/**
78+
* X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
79+
@@@ -140,12 -107,10 +151,18 @@@
80+
* @data: Driver specific data or NULL. The internal storage
81+
* format is unsigned long. The supplied value, pointer
82+
* etc. is casted to unsigned long internally.
83+
+ *
84+
+ * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
85+
+ * set to wildcards.
86+
*/
87+
++<<<<<<< HEAD
88+
+#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \
89+
+ X86_MATCH_VENDOR_FAM_FEATURE(vendor, X86_FAMILY_ANY, feature, data)
90+
++=======
91+
+ #define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \
92+
+ X86_MATCH_CPU(X86_VENDOR_##vendor, X86_FAMILY_ANY, X86_MODEL_ANY, \
93+
+ X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
94+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
95+
96+
/**
97+
* X86_MATCH_FEATURE - Macro for matching a CPU feature
98+
@@@ -153,12 -118,10 +170,18 @@@
99+
* @data: Driver specific data or NULL. The internal storage
100+
* format is unsigned long. The supplied value, pointer
101+
* etc. is casted to unsigned long internally.
102+
+ *
103+
+ * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
104+
+ * set to wildcards.
105+
*/
106+
++<<<<<<< HEAD
107+
+#define X86_MATCH_FEATURE(feature, data) \
108+
+ X86_MATCH_VENDOR_FEATURE(ANY, feature, data)
109+
++=======
110+
+ #define X86_MATCH_FEATURE(feature, data) \
111+
+ X86_MATCH_CPU(X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, \
112+
+ X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
113+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
114+
115+
/**
116+
* X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
117+
@@@ -169,13 -132,10 +192,19 @@@
118+
* @data: Driver specific data or NULL. The internal storage
119+
* format is unsigned long. The supplied value, pointer
120+
* etc. is casted to unsigned long internally.
121+
+ *
122+
+ * All other missing arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
123+
+ * set to wildcards.
124+
*/
125+
++<<<<<<< HEAD
126+
+#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \
127+
+ X86_MATCH_VENDOR_FAM_MODEL_FEATURE(vendor, family, model, \
128+
+ X86_FEATURE_ANY, data)
129+
++=======
130+
+ #define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \
131+
+ X86_MATCH_CPU(X86_VENDOR_##vendor, family, model, X86_STEPPING_ANY, \
132+
+ X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
133+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
134+
135+
/**
136+
* X86_MATCH_VENDOR_FAM - Match vendor and family
137+
@@@ -185,32 -145,10 +214,38 @@@
138+
* @data: Driver specific data or NULL. The internal storage
139+
* format is unsigned long. The supplied value, pointer
140+
* etc. is casted to unsigned long internally.
141+
+ *
142+
+ * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
143+
+ * set of wildcards.
144+
*/
145+
++<<<<<<< HEAD
146+
+#define X86_MATCH_VENDOR_FAM(vendor, family, data) \
147+
+ X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
148+
+
149+
+/**
150+
+ * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
151+
+ * @model: The model name without the INTEL_FAM6_ prefix or ANY
152+
+ * The model name is expanded to INTEL_FAM6_@model internally
153+
+ * @data: Driver specific data or NULL. The internal storage
154+
+ * format is unsigned long. The supplied value, pointer
155+
+ * etc. is casted to unsigned long internally.
156+
+ *
157+
+ * The vendor is set to INTEL, the family to 6 and all other missing
158+
+ * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
159+
+ *
160+
+ * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
161+
+ */
162+
+#define X86_MATCH_INTEL_FAM6_MODEL(model, data) \
163+
+ X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
164+
+
165+
+#define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data) \
166+
+ X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
167+
+ steppings, X86_FEATURE_ANY, data)
168+
++=======
169+
+ #define X86_MATCH_VENDOR_FAM(vendor, family, data) \
170+
+ X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
171+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
172+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
173+
174+
/**
175+
* X86_MATCH_VFM - Match encoded vendor/family/model
176+
@@@ -218,16 -156,12 +253,22 @@@
177+
* @data: Driver specific data or NULL. The internal storage
178+
* format is unsigned long. The supplied value, pointer
179+
* etc. is cast to unsigned long internally.
180+
+ *
181+
+ * Stepping and feature are set to wildcards
182+
*/
183+
++<<<<<<< HEAD
184+
+#define X86_MATCH_VFM(vfm, data) \
185+
+ X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
186+
+ VFM_VENDOR(vfm), \
187+
+ VFM_FAMILY(vfm), \
188+
+ VFM_MODEL(vfm), \
189+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, data)
190+
++=======
191+
+ #define X86_MATCH_VFM(vfm, data) \
192+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
193+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
194+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
195+
196+
-#define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
197+
/**
198+
* X86_MATCH_VFM_STEPS - Match encoded vendor/family/model and steppings
199+
* range.
200+
@@@ -237,15 -171,11 +278,22 @@@
201+
* @data: Driver specific data or NULL. The internal storage
202+
* format is unsigned long. The supplied value, pointer
203+
* etc. is cast to unsigned long internally.
204+
+ *
205+
+ * feature is set to wildcard
206+
*/
207+
++<<<<<<< HEAD
208+
+#define X86_MATCH_VFM_STEPPINGS(vfm, steppings, data) \
209+
+ X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
210+
+ VFM_VENDOR(vfm), \
211+
+ VFM_FAMILY(vfm), \
212+
+ VFM_MODEL(vfm), \
213+
+ steppings, X86_FEATURE_ANY, data)
214+
++=======
215+
+ #define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \
216+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
217+
+ __X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, \
218+
+ X86_CPU_TYPE_ANY, data)
219+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
220+
221+
/**
222+
* X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature
223+
@@@ -254,43 -184,24 +302,61 @@@
224+
* @data: Driver specific data or NULL. The internal storage
225+
* format is unsigned long. The supplied value, pointer
226+
* etc. is cast to unsigned long internally.
227+
+ *
228+
+ * Steppings is set to wildcard
229+
*/
230+
++<<<<<<< HEAD
231+
+#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
232+
+ X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
233+
+ VFM_VENDOR(vfm), \
234+
+ VFM_FAMILY(vfm), \
235+
+ VFM_MODEL(vfm), \
236+
+ X86_STEPPING_ANY, feature, data)
237+
+
238+
+/*
239+
+ * Match specific microcode revisions.
240+
+ *
241+
+ * vendor/family/model/stepping must be all set.
242+
+ *
243+
+ * Only checks against the boot CPU. When mixed-stepping configs are
244+
+ * valid for a CPU model, add a quirk for every valid stepping and
245+
+ * do the fine-tuning in the quirk handler.
246+
+ */
247+
+
248+
+struct x86_cpu_desc {
249+
+ u8 x86_family;
250+
+ u8 x86_vendor;
251+
+ u8 x86_model;
252+
+ u8 x86_stepping;
253+
+ u32 x86_microcode_rev;
254+
+};
255+
+
256+
+#define INTEL_CPU_DESC(vfm, stepping, revision) { \
257+
+ .x86_family = VFM_FAMILY(vfm), \
258+
+ .x86_vendor = VFM_VENDOR(vfm), \
259+
+ .x86_model = VFM_MODEL(vfm), \
260+
+ .x86_stepping = (stepping), \
261+
+ .x86_microcode_rev = (revision), \
262+
+}
263+
++=======
264+
+ #define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
265+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
266+
+ X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
267+
+
268+
+ /**
269+
+ * X86_MATCH_VFM_CPU_TYPE - Match encoded vendor/family/model/type
270+
+ * @vfm: Encoded 8-bits each for vendor, family, model
271+
+ * @type: CPU type e.g. P-core, E-core
272+
+ * @data: Driver specific data or NULL. The internal storage
273+
+ * format is unsigned long. The supplied value, pointer
274+
+ * etc. is cast to unsigned long internally.
275+
+ */
276+
+ #define X86_MATCH_VFM_CPU_TYPE(vfm, type, data) \
277+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
278+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, type, data)
279+
++>>>>>>> 00d7fc04b703 (x86/cpu: Add cpu_type to struct x86_cpu_id)
280+
281+
extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
282+
-extern bool x86_match_min_microcode_rev(const struct x86_cpu_id *table);
283+
+extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
284+
285+
#endif /* _ASM_X86_CPU_DEVICE_ID */
286+
* Unmerged path arch/x86/include/asm/cpu_device_id.h
287+
diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h
288+
index fd6bf714b9c8..0e4e0ee31d14 100644
289+
--- a/include/linux/mod_devicetable.h
290+
+++ b/include/linux/mod_devicetable.h
291+
@@ -679,6 +679,7 @@ struct x86_cpu_id {
292+
__u16 feature; /* bit index */
293+
/* Solely for kernel-internal use: DO NOT EXPORT to userspace! */
294+
__u16 flags;
295+
+ __u8 type;
296+
kernel_ulong_t driver_data;
297+
};
298+
299+
@@ -688,6 +689,7 @@ struct x86_cpu_id {
300+
#define X86_MODEL_ANY 0
301+
#define X86_STEPPING_ANY 0
302+
#define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */
303+
+#define X86_CPU_TYPE_ANY 0
304+
305+
/*
306+
* Generic table type for matching CPU features.

0 commit comments

Comments
 (0)