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; there's no need for them to be uint16_t in Xen, and this
matches the size of the fields in cpuinfo_x86.
No functional change.
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
v2:
* Rebase over adjustments to x86_match_cpu().
* Switch name to X86_STEPPING_ANY, and use 0xffff to remove a conditional
from x86_match_cpu().
Combined with the previous patch, the code generation continues to be
reasonable despite the analysis tangent taken on the v1 thread.
---
xen/arch/x86/cpu/common.c | 2 ++
xen/arch/x86/include/asm/match-cpu.h | 12 ++++++++----
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/xen/arch/x86/cpu/common.c b/xen/arch/x86/cpu/common.c
index a659ea7bf604..7851142b737d 100644
--- a/xen/arch/x86/cpu/common.c
+++ b/xen/arch/x86/cpu/common.c
@@ -1022,6 +1022,8 @@ const struct x86_cpu_id *x86_match_cpu(const struct x86_cpu_id table[])
continue;
if ( c->model != m->model )
continue;
+ if ( !((1U << c->stepping) & m->steppings) )
+ continue;
if ( !cpu_has(c, m->feature) )
continue;
diff --git a/xen/arch/x86/include/asm/match-cpu.h b/xen/arch/x86/include/asm/match-cpu.h
index f8e4e37d9972..e25f414ea1b4 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_STEPPING_ANY 0xffff
#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_STEPPING_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_STEPPING_ANY, \
+ X86_FEATURE_ANY, data)
/*
* x86_match_cpu() - match the CPU against an array of x86_cpu_ids[]
--
2.39.5
On 18.07.2025 16:20, Andrew Cooper wrote: > 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; there's no need for them to be uint16_t in Xen, and this > matches the size of the fields in cpuinfo_x86. > > No functional change. > > Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Reviewed-by: Jan Beulich <jbeulich@suse.com>
© 2016 - 2025 Red Hat, Inc.