|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 5/6] x86/match-cpu: Support matching on steppings
Architecturally, stepping is a 4-bit field, so a uint16_t suffices for a
bitmap of steppings.
In order to keep the size of struct x86_cpu_id the same, shrink the vendor and
family fields, neither of which need to be uint16_t in Xen.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
CC: Jan Beulich <JBeulich@xxxxxxxx>
CC: Roger Pau Monné <roger.pau@xxxxxxxxxx>
Linux supports all fields being optional. This has lead to using
X86_MATCH_CPU(ANY, ANY, ANY, ANY, FEATURE_FOO, NULL) in place of
boot_cpu_has(), and is not a construct I think we want to encorage.
---
xen/arch/x86/cpu/common.c | 4 +++-
xen/arch/x86/include/asm/match-cpu.h | 12 ++++++++----
2 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index cc004fc976f5..fc25935d3109 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -1003,13 +1003,15 @@ const struct x86_cpu_id *x86_match_cpu(const struct
x86_cpu_id table[])
const struct x86_cpu_id *m;
const struct cpuinfo_x86 *c = &boot_cpu_data;
- for (m = table; m->vendor | m->family | m->model | m->feature; m++) {
+ for (m = table; m->vendor | m->family | m->model | m->steppings |
m->feature; m++) {
if (c->x86_vendor != m->vendor)
continue;
if (c->x86 != m->family)
continue;
if (c->x86_model != m->model)
continue;
+ if (m->steppings && !(m->steppings & (1U << c->stepping)))
+ continue;
if (!cpu_has(c, m->feature))
continue;
return m;
diff --git a/xen/arch/x86/include/asm/match-cpu.h
b/xen/arch/x86/include/asm/match-cpu.h
index dcdc50a70d14..3862e766ccfc 100644
--- a/xen/arch/x86/include/asm/match-cpu.h
+++ b/xen/arch/x86/include/asm/match-cpu.h
@@ -8,28 +8,32 @@
#include <asm/intel-family.h>
#include <asm/x86-vendors.h>
+#define X86_STEPPINGS_ANY 0
#define X86_FEATURE_ANY X86_FEATURE_LM
struct x86_cpu_id {
- uint16_t vendor;
- uint16_t family;
+ uint8_t vendor;
+ uint8_t family;
uint16_t model;
+ uint16_t steppings; /* Stepping bitmap, or X86_STEPPINGS_ANY */
uint16_t feature; /* X86_FEATURE_*, or X86_FEATURE_ANY */
const void *driver_data;
};
-#define X86_MATCH_CPU(v, f, m, feat, data) \
+#define X86_MATCH_CPU(v, f, m, steps, feat, data) \
{ \
.vendor = (v), \
.family = (f), \
.model = (m), \
+ .steppings = (steps), \
.feature = (feat), \
.driver_data = (const void *)(unsigned long)(data), \
}
#define X86_MATCH_VFM(vfm, data) \
X86_MATCH_CPU(VFM_VENDOR(vfm), VFM_FAMILY(vfm), \
- VFM_MODEL(vfm), X86_FEATURE_ANY, data)
+ VFM_MODEL(vfm), X86_STEPPINGS_ANY, \
+ X86_FEATURE_ANY, data)
/*
* x86_match_cpu() - match the CPU against an array of x86_cpu_ids[]
--
2.39.5
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |