Skip to content

Commit 2e34909

Browse files
committed
x86/cpu: Add cpu_type to struct x86_cpu_id
JIRA: https://issues.redhat.com/browse/RHEL-93414 Conflicts: Context diff's in the 2 arch/x86/include/asm/cpu_device_id.h hunks due to missing the following upstream commits: - commit 5366d89 ("x86/cpu: Remove 'x86_cpu_desc' infrastructure"). - 13ad484 ("x86/cpu/vfm: Delete X86_MATCH_INTEL_FAM6_MODEL[_STEPPING]() macros") commit 00d7fc0 Author: Pawan Gupta <[email protected]> Date: Tue, 11 Mar 2025 08:02:36 -0700 x86/cpu: Add cpu_type to struct x86_cpu_id 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 <[email protected]> Signed-off-by: Borislav Petkov (AMD) <[email protected]> Signed-off-by: Ingo Molnar <[email protected]> Acked-by: Dave Hansen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Waiman Long <[email protected]>
1 parent b543404 commit 2e34909

File tree

2 files changed

+25
-9
lines changed

2 files changed

+25
-9
lines changed

arch/x86/include/asm/cpu_device_id.h

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,14 @@
7474
* into another macro at the usage site for good reasons, then please
7575
* start this local macro with X86_MATCH to allow easy grepping.
7676
*/
77-
#define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _data) { \
77+
#define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _type, _data) { \
7878
.vendor = _vendor, \
7979
.family = _family, \
8080
.model = _model, \
8181
.steppings = _steppings, \
8282
.feature = _feature, \
8383
.flags = X86_CPU_ID_FLAG_ENTRY_VALID, \
84+
.type = _type, \
8485
.driver_data = (unsigned long) _data \
8586
}
8687

@@ -96,7 +97,7 @@
9697
*/
9798
#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
9899
X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
99-
X86_STEPPING_ANY, feature, data)
100+
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
100101

101102
/**
102103
* X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
@@ -109,7 +110,7 @@
109110
*/
110111
#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \
111112
X86_MATCH_CPU(X86_VENDOR_##vendor, X86_FAMILY_ANY, X86_MODEL_ANY, \
112-
X86_STEPPING_ANY, feature, data)
113+
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
113114

114115
/**
115116
* X86_MATCH_FEATURE - Macro for matching a CPU feature
@@ -120,7 +121,7 @@
120121
*/
121122
#define X86_MATCH_FEATURE(feature, data) \
122123
X86_MATCH_CPU(X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, \
123-
X86_STEPPING_ANY, feature, data)
124+
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
124125

125126
/**
126127
* X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
@@ -134,7 +135,7 @@
134135
*/
135136
#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \
136137
X86_MATCH_CPU(X86_VENDOR_##vendor, family, model, X86_STEPPING_ANY, \
137-
X86_FEATURE_ANY, data)
138+
X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
138139

139140
/**
140141
* X86_MATCH_VENDOR_FAM - Match vendor and family
@@ -147,7 +148,7 @@
147148
*/
148149
#define X86_MATCH_VENDOR_FAM(vendor, family, data) \
149150
X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
150-
X86_STEPPING_ANY, X86_FEATURE_ANY, data)
151+
X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
151152

152153
/**
153154
* X86_MATCH_INTEL_FAM6_MODEL - Match vendor INTEL, family 6 and model
@@ -178,7 +179,7 @@
178179
*/
179180
#define X86_MATCH_VFM(vfm, data) \
180181
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
181-
X86_STEPPING_ANY, X86_FEATURE_ANY, data)
182+
X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
182183

183184
#define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
184185
/**
@@ -193,7 +194,8 @@
193194
*/
194195
#define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \
195196
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
196-
__X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, data)
197+
__X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, \
198+
X86_CPU_TYPE_ANY, data)
197199

198200
/**
199201
* X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature
@@ -205,7 +207,19 @@
205207
*/
206208
#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
207209
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
208-
X86_STEPPING_ANY, feature, data)
210+
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
211+
212+
/**
213+
* X86_MATCH_VFM_CPU_TYPE - Match encoded vendor/family/model/type
214+
* @vfm: Encoded 8-bits each for vendor, family, model
215+
* @type: CPU type e.g. P-core, E-core
216+
* @data: Driver specific data or NULL. The internal storage
217+
* format is unsigned long. The supplied value, pointer
218+
* etc. is cast to unsigned long internally.
219+
*/
220+
#define X86_MATCH_VFM_CPU_TYPE(vfm, type, data) \
221+
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
222+
X86_STEPPING_ANY, X86_FEATURE_ANY, type, data)
209223

210224
/*
211225
* Match specific microcode revisions.

include/linux/mod_devicetable.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,7 @@ struct x86_cpu_id {
679679
__u16 feature; /* bit index */
680680
/* Solely for kernel-internal use: DO NOT EXPORT to userspace! */
681681
__u16 flags;
682+
__u8 type;
682683
kernel_ulong_t driver_data;
683684
};
684685

@@ -690,6 +691,7 @@ struct x86_cpu_id {
690691
#define X86_STEP_MIN 0
691692
#define X86_STEP_MAX 0xf
692693
#define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */
694+
#define X86_CPU_TYPE_ANY 0
693695

694696
/*
695697
* Generic table type for matching CPU features.

0 commit comments

Comments
 (0)