Skip to content

Commit 61134e5

Browse files
committed
x86/cpu: Shorten CPU matching macro
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 c339040 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/c3390406.failed To add cpu-type to the existing CPU matching infrastructure, the base macro X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE need to append _CPU_TYPE. This makes an already long name longer, and somewhat incomprehensible. To avoid this, rename the base macro to X86_MATCH_CPU. The macro name doesn't need to explicitly tell everything that it matches. The arguments to the macro already hint at that. For consistency, use this base macro to define X86_MATCH_VFM and friends. Remove unused X86_MATCH_VENDOR_FAM_MODEL_FEATURE while at it. [ 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-2-e8514dcaaff2@linux.intel.com (cherry picked from commit c339040) Signed-off-by: Jonathan Maple <jmaple@ciq.com> # Conflicts: # arch/x86/include/asm/cpu_device_id.h
1 parent 7ec0ca6 commit 61134e5

File tree

1 file changed

+177
-0
lines changed

1 file changed

+177
-0
lines changed
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
x86/cpu: Shorten CPU matching macro
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 c3390406adc62dd2d42eb522e1ce124fa43c5dec
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/c3390406.failed
10+
11+
To add cpu-type to the existing CPU matching infrastructure, the base macro
12+
X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE need to append _CPU_TYPE. This
13+
makes an already long name longer, and somewhat incomprehensible.
14+
15+
To avoid this, rename the base macro to X86_MATCH_CPU. The macro name
16+
doesn't need to explicitly tell everything that it matches. The arguments
17+
to the macro already hint at that.
18+
19+
For consistency, use this base macro to define X86_MATCH_VFM and friends.
20+
21+
Remove unused X86_MATCH_VENDOR_FAM_MODEL_FEATURE while at it.
22+
23+
[ bp: Massage commit message. ]
24+
25+
Signed-off-by: Pawan Gupta <pawan.kumar.gupta@linux.intel.com>
26+
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
27+
Signed-off-by: Ingo Molnar <mingo@kernel.org>
28+
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
29+
Link: https://lore.kernel.org/r/20250311-add-cpu-type-v8-2-e8514dcaaff2@linux.intel.com
30+
(cherry picked from commit c3390406adc62dd2d42eb522e1ce124fa43c5dec)
31+
Signed-off-by: Jonathan Maple <jmaple@ciq.com>
32+
33+
# Conflicts:
34+
# arch/x86/include/asm/cpu_device_id.h
35+
diff --cc arch/x86/include/asm/cpu_device_id.h
36+
index f794121850a7,45489b034cd6..000000000000
37+
--- a/arch/x86/include/asm/cpu_device_id.h
38+
+++ b/arch/x86/include/asm/cpu_device_id.h
39+
@@@ -56,9 -56,8 +56,9 @@@
40+
/* x86_cpu_id::flags */
41+
#define X86_CPU_ID_FLAG_ENTRY_VALID BIT(0)
42+
43+
+#define X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
44+
/**
45+
- * X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE - Base macro for CPU matching
46+
+ * X86_MATCH_CPU - Base macro for CPU matching
47+
* @_vendor: The vendor name, e.g. INTEL, AMD, HYGON, ..., ANY
48+
* The name is expanded to X86_VENDOR_@_vendor
49+
* @_family: The family number or X86_FAMILY_ANY
50+
@@@ -185,49 -144,23 +145,42 @@@
51+
* @data: Driver specific data or NULL. The internal storage
52+
* format is unsigned long. The supplied value, pointer
53+
* etc. is casted to unsigned long internally.
54+
- *
55+
- * All other missing arguments to X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are
56+
- * set of wildcards.
57+
*/
58+
- #define X86_MATCH_VENDOR_FAM(vendor, family, data) \
59+
- X86_MATCH_VENDOR_FAM_MODEL(vendor, family, X86_MODEL_ANY, data)
60+
+ #define X86_MATCH_VENDOR_FAM(vendor, family, data) \
61+
+ X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
62+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, data)
63+
64+
+/**
65+
+ * X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
66+
+ * @model: The model name without the INTEL_FAM6_ prefix or ANY
67+
+ * The model name is expanded to INTEL_FAM6_@model internally
68+
+ * @data: Driver specific data or NULL. The internal storage
69+
+ * format is unsigned long. The supplied value, pointer
70+
+ * etc. is casted to unsigned long internally.
71+
+ *
72+
+ * The vendor is set to INTEL, the family to 6 and all other missing
73+
+ * arguments of X86_MATCH_VENDOR_FAM_MODEL_FEATURE() are set to wildcards.
74+
+ *
75+
+ * See X86_MATCH_VENDOR_FAM_MODEL_FEATURE() for further information.
76+
+ */
77+
+#define X86_MATCH_INTEL_FAM6_MODEL(model, data) \
78+
+ X86_MATCH_VENDOR_FAM_MODEL(INTEL, 6, INTEL_FAM6_##model, data)
79+
+
80+
+#define X86_MATCH_INTEL_FAM6_MODEL_STEPPINGS(model, steppings, data) \
81+
+ X86_MATCH_VENDOR_FAM_MODEL_STEPPINGS_FEATURE(INTEL, 6, INTEL_FAM6_##model, \
82+
+ steppings, X86_FEATURE_ANY, data)
83+
+
84+
/**
85+
* X86_MATCH_VFM - Match encoded vendor/family/model
86+
* @vfm: Encoded 8-bits each for vendor, family, model
87+
* @data: Driver specific data or NULL. The internal storage
88+
* format is unsigned long. The supplied value, pointer
89+
* etc. is cast to unsigned long internally.
90+
- *
91+
- * Stepping and feature are set to wildcards
92+
*/
93+
- #define X86_MATCH_VFM(vfm, data) \
94+
- X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
95+
- VFM_VENDOR(vfm), \
96+
- VFM_FAMILY(vfm), \
97+
- VFM_MODEL(vfm), \
98+
- X86_STEPPING_ANY, X86_FEATURE_ANY, data)
99+
+ #define X86_MATCH_VFM(vfm, data) \
100+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
101+
+ X86_STEPPING_ANY, X86_FEATURE_ANY, data)
102+
103+
-#define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
104+
/**
105+
* X86_MATCH_VFM_STEPS - Match encoded vendor/family/model and steppings
106+
* range.
107+
@@@ -237,15 -170,10 +190,19 @@@
108+
* @data: Driver specific data or NULL. The internal storage
109+
* format is unsigned long. The supplied value, pointer
110+
* etc. is cast to unsigned long internally.
111+
- *
112+
- * feature is set to wildcard
113+
*/
114+
++<<<<<<< HEAD
115+
+#define X86_MATCH_VFM_STEPPINGS(vfm, steppings, data) \
116+
+ X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
117+
+ VFM_VENDOR(vfm), \
118+
+ VFM_FAMILY(vfm), \
119+
+ VFM_MODEL(vfm), \
120+
+ steppings, X86_FEATURE_ANY, data)
121+
++=======
122+
+ #define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \
123+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
124+
+ __X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, data)
125+
++>>>>>>> c3390406adc6 (x86/cpu: Shorten CPU matching macro)
126+
127+
/**
128+
* X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature
129+
@@@ -254,43 -182,12 +211,38 @@@
130+
* @data: Driver specific data or NULL. The internal storage
131+
* format is unsigned long. The supplied value, pointer
132+
* etc. is cast to unsigned long internally.
133+
- *
134+
- * Steppings is set to wildcard
135+
*/
136+
- #define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
137+
- X86_MATCH_VENDORID_FAM_MODEL_STEPPINGS_FEATURE( \
138+
- VFM_VENDOR(vfm), \
139+
- VFM_FAMILY(vfm), \
140+
- VFM_MODEL(vfm), \
141+
- X86_STEPPING_ANY, feature, data)
142+
+ #define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
143+
+ X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
144+
+ X86_STEPPING_ANY, feature, data)
145+
146+
+/*
147+
+ * Match specific microcode revisions.
148+
+ *
149+
+ * vendor/family/model/stepping must be all set.
150+
+ *
151+
+ * Only checks against the boot CPU. When mixed-stepping configs are
152+
+ * valid for a CPU model, add a quirk for every valid stepping and
153+
+ * do the fine-tuning in the quirk handler.
154+
+ */
155+
+
156+
+struct x86_cpu_desc {
157+
+ u8 x86_family;
158+
+ u8 x86_vendor;
159+
+ u8 x86_model;
160+
+ u8 x86_stepping;
161+
+ u32 x86_microcode_rev;
162+
+};
163+
+
164+
+#define INTEL_CPU_DESC(vfm, stepping, revision) { \
165+
+ .x86_family = VFM_FAMILY(vfm), \
166+
+ .x86_vendor = VFM_VENDOR(vfm), \
167+
+ .x86_model = VFM_MODEL(vfm), \
168+
+ .x86_stepping = (stepping), \
169+
+ .x86_microcode_rev = (revision), \
170+
+}
171+
+
172+
extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
173+
-extern bool x86_match_min_microcode_rev(const struct x86_cpu_id *table);
174+
+extern bool x86_cpu_has_min_microcode_rev(const struct x86_cpu_desc *table);
175+
176+
#endif /* _ASM_X86_CPU_DEVICE_ID */
177+
* Unmerged path arch/x86/include/asm/cpu_device_id.h

0 commit comments

Comments
 (0)