[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86/match-cpu: Introduce X86_MATCH_VFM() and convert intel_idle_ids[]



commit db482b3a7b7b181b0f464b6beccba1a82c307350
Author:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
AuthorDate: Wed Jul 16 15:11:43 2025 +0100
Commit:     Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
CommitDate: Fri Jul 18 13:40:12 2025 +0100

    x86/match-cpu: Introduce X86_MATCH_VFM() and convert intel_idle_ids[]
    
    mwait-idle's ICPU() is the most convenient place to get started.  Introduce
    X86_MATCH_CPU() and X86_MATCH_VFM() following their Linux counterparts.
    
    This involves match-cpu.h including more headers, which in turn allows us to
    drop a few.
    
    No functional change.
    
    Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/x86/cpu/intel.c             |  1 -
 xen/arch/x86/cpu/mwait-idle.c        |  4 +---
 xen/arch/x86/include/asm/match-cpu.h | 21 ++++++++++++++++++++-
 3 files changed, 21 insertions(+), 5 deletions(-)

diff --git a/xen/arch/x86/cpu/intel.c b/xen/arch/x86/cpu/intel.c
index ee1ae92cd7..26a171aa36 100644
--- a/xen/arch/x86/cpu/intel.c
+++ b/xen/arch/x86/cpu/intel.c
@@ -7,7 +7,6 @@
 
 #include <asm/apic.h>
 #include <asm/i387.h>
-#include <asm/intel-family.h>
 #include <asm/match-cpu.h>
 #include <asm/mpspec.h>
 #include <asm/msr.h>
diff --git a/xen/arch/x86/cpu/mwait-idle.c b/xen/arch/x86/cpu/mwait-idle.c
index eec2823cba..e837cbf50e 100644
--- a/xen/arch/x86/cpu/mwait-idle.c
+++ b/xen/arch/x86/cpu/mwait-idle.c
@@ -51,7 +51,6 @@
 
 #include <asm/cpuidle.h>
 #include <asm/hpet.h>
-#include <asm/intel-family.h>
 #include <asm/match-cpu.h>
 #include <asm/msr.h>
 #include <asm/mwait.h>
@@ -1302,8 +1301,7 @@ static const struct idle_cpu idle_cpu_srf = {
 };
 
 #define ICPU(model, cpu) \
-       { X86_VENDOR_INTEL, 6, INTEL_FAM6_ ## model, X86_FEATURE_ALWAYS, \
-         &idle_cpu_ ## cpu}
+       X86_MATCH_VFM(INTEL_ ## model, &idle_cpu_ ## cpu)
 
 static const struct x86_cpu_id intel_idle_ids[] __initconstrel = {
        ICPU(NEHALEM_EP,                nehalem),
diff --git a/xen/arch/x86/include/asm/match-cpu.h 
b/xen/arch/x86/include/asm/match-cpu.h
index 4521bbddc6..f8e4e37d99 100644
--- a/xen/arch/x86/include/asm/match-cpu.h
+++ b/xen/arch/x86/include/asm/match-cpu.h
@@ -4,14 +4,33 @@
 
 #include <xen/stdint.h>
 
+#include <asm/cpufeature.h>
+#include <asm/intel-family.h>
+#include <asm/x86-vendors.h>
+
+#define X86_FEATURE_ANY X86_FEATURE_LM
+
 struct x86_cpu_id {
     uint16_t vendor;
     uint16_t family;
     uint16_t model;
-    uint16_t feature;
+    uint16_t feature;   /* X86_FEATURE_*, or X86_FEATURE_ANY */
     const void *driver_data;
 };
 
+#define X86_MATCH_CPU(v, f, m, feat, data)                      \
+    {                                                           \
+        .vendor       = (v),                                    \
+        .family       = (f),                                    \
+        .model        = (m),                                    \
+        .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)
+
 /*
  * x86_match_cpu() - match the CPU against an array of x86_cpu_ids[]
  *
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.