mirror of
https://github.com/torvalds/linux.git
synced 2026-03-08 03:44:45 +01:00
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 <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
This commit is contained in:
parent
c3390406ad
commit
00d7fc04b7
2 changed files with 25 additions and 9 deletions
|
|
@ -74,13 +74,14 @@
|
|||
* into another macro at the usage site for good reasons, then please
|
||||
* start this local macro with X86_MATCH to allow easy grepping.
|
||||
*/
|
||||
#define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _data) { \
|
||||
#define X86_MATCH_CPU(_vendor, _family, _model, _steppings, _feature, _type, _data) { \
|
||||
.vendor = _vendor, \
|
||||
.family = _family, \
|
||||
.model = _model, \
|
||||
.steppings = _steppings, \
|
||||
.feature = _feature, \
|
||||
.flags = X86_CPU_ID_FLAG_ENTRY_VALID, \
|
||||
.type = _type, \
|
||||
.driver_data = (unsigned long) _data \
|
||||
}
|
||||
|
||||
|
|
@ -96,7 +97,7 @@
|
|||
*/
|
||||
#define X86_MATCH_VENDOR_FAM_FEATURE(vendor, family, feature, data) \
|
||||
X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
|
||||
X86_STEPPING_ANY, feature, data)
|
||||
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VENDOR_FEATURE - Macro for matching vendor and CPU feature
|
||||
|
|
@ -109,7 +110,7 @@
|
|||
*/
|
||||
#define X86_MATCH_VENDOR_FEATURE(vendor, feature, data) \
|
||||
X86_MATCH_CPU(X86_VENDOR_##vendor, X86_FAMILY_ANY, X86_MODEL_ANY, \
|
||||
X86_STEPPING_ANY, feature, data)
|
||||
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_FEATURE - Macro for matching a CPU feature
|
||||
|
|
@ -120,7 +121,7 @@
|
|||
*/
|
||||
#define X86_MATCH_FEATURE(feature, data) \
|
||||
X86_MATCH_CPU(X86_VENDOR_ANY, X86_FAMILY_ANY, X86_MODEL_ANY, \
|
||||
X86_STEPPING_ANY, feature, data)
|
||||
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VENDOR_FAM_MODEL - Match vendor, family and model
|
||||
|
|
@ -134,7 +135,7 @@
|
|||
*/
|
||||
#define X86_MATCH_VENDOR_FAM_MODEL(vendor, family, model, data) \
|
||||
X86_MATCH_CPU(X86_VENDOR_##vendor, family, model, X86_STEPPING_ANY, \
|
||||
X86_FEATURE_ANY, data)
|
||||
X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VENDOR_FAM - Match vendor and family
|
||||
|
|
@ -147,7 +148,7 @@
|
|||
*/
|
||||
#define X86_MATCH_VENDOR_FAM(vendor, family, data) \
|
||||
X86_MATCH_CPU(X86_VENDOR_##vendor, family, X86_MODEL_ANY, \
|
||||
X86_STEPPING_ANY, X86_FEATURE_ANY, data)
|
||||
X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VFM - Match encoded vendor/family/model
|
||||
|
|
@ -158,7 +159,7 @@
|
|||
*/
|
||||
#define X86_MATCH_VFM(vfm, data) \
|
||||
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
|
||||
X86_STEPPING_ANY, X86_FEATURE_ANY, data)
|
||||
X86_STEPPING_ANY, X86_FEATURE_ANY, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
#define __X86_STEPPINGS(mins, maxs) GENMASK(maxs, mins)
|
||||
/**
|
||||
|
|
@ -173,7 +174,8 @@
|
|||
*/
|
||||
#define X86_MATCH_VFM_STEPS(vfm, min_step, max_step, data) \
|
||||
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
|
||||
__X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, data)
|
||||
__X86_STEPPINGS(min_step, max_step), X86_FEATURE_ANY, \
|
||||
X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VFM_FEATURE - Match encoded vendor/family/model/feature
|
||||
|
|
@ -185,7 +187,19 @@
|
|||
*/
|
||||
#define X86_MATCH_VFM_FEATURE(vfm, feature, data) \
|
||||
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
|
||||
X86_STEPPING_ANY, feature, data)
|
||||
X86_STEPPING_ANY, feature, X86_CPU_TYPE_ANY, data)
|
||||
|
||||
/**
|
||||
* X86_MATCH_VFM_CPU_TYPE - Match encoded vendor/family/model/type
|
||||
* @vfm: Encoded 8-bits each for vendor, family, model
|
||||
* @type: CPU type e.g. P-core, E-core
|
||||
* @data: Driver specific data or NULL. The internal storage
|
||||
* format is unsigned long. The supplied value, pointer
|
||||
* etc. is cast to unsigned long internally.
|
||||
*/
|
||||
#define X86_MATCH_VFM_CPU_TYPE(vfm, type, data) \
|
||||
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), VFM_MODEL(vfm), \
|
||||
X86_STEPPING_ANY, X86_FEATURE_ANY, type, data)
|
||||
|
||||
extern const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id *match);
|
||||
extern bool x86_match_min_microcode_rev(const struct x86_cpu_id *table);
|
||||
|
|
|
|||
|
|
@ -692,6 +692,7 @@ struct x86_cpu_id {
|
|||
__u16 feature; /* bit index */
|
||||
/* Solely for kernel-internal use: DO NOT EXPORT to userspace! */
|
||||
__u16 flags;
|
||||
__u8 type;
|
||||
kernel_ulong_t driver_data;
|
||||
};
|
||||
|
||||
|
|
@ -703,6 +704,7 @@ struct x86_cpu_id {
|
|||
#define X86_STEP_MIN 0
|
||||
#define X86_STEP_MAX 0xf
|
||||
#define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */
|
||||
#define X86_CPU_TYPE_ANY 0
|
||||
|
||||
/*
|
||||
* Generic table type for matching CPU features.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue