Skip to contentSkip to conversation

x86: Convert remaining INTEL_FAM6_* users

PATCH In review Andrew Cooper 2 participants 6 messages Jul 18, 2025 – Jul 21, 2025

lore
Share & tools
lore
#0 lore raw

cover x86: Convert remaining INTEL_FAM6_* users

This is a mechanical change to use the VFM constants rather than the family-specific ones.

https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1934721940

Andrew Cooper (4):
x86/mwait-idle: Update vendor/family/model logic x86/cpu-policy: Update vendor/family/model logic x86/spec-ctrl: Update vendor/family/model logic x86/intel-family: Resync with Linux

 xen/arch/x86/cpu-policy.c               |  19 ++-
 xen/arch/x86/cpu/intel.c                |   3 +-
 xen/arch/x86/cpu/mwait-idle.c           |  30 +++--
 xen/arch/x86/include/asm/intel-family.h |  86 +------------
 xen/arch/x86/spec_ctrl.c                | 162 ++++++++++++------------
 5 files changed, 108 insertions(+), 192 deletions(-)
Signature · 1 line
2.39.5
#1 lore raw

PATCH 1/4 x86/mwait-idle: Update vendor/family/model logic

Switch to the new fields and constants.

In mwait_idle_probe(), exit early for non-Intel CPUs. intel_idle_ids[] is a large (and ever increasing) table and it's not reasonable to scan it for other vendors, nor is it ideal to be emitting an ambigous error(ish) message.

No practical change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

---
 xen/arch/x86/cpu/mwait-idle.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)
xen/arch/x86/cpu/mwait-idle.c +17 -13
index e837cbf50eb3..f47fdfb569d4 100644
@@ -1566,27 +1566,27 @@ static void __init spr_idle_state_table_update(void)
  */
 static void __init mwait_idle_state_table_update(void)
 {
-	switch (boot_cpu_data.x86_model) {
-	case INTEL_FAM6_IVYBRIDGE_X:
+	switch (boot_cpu_data.vfm) {
+	case INTEL_IVYBRIDGE_X:
 		ivt_idle_state_table_update();
 		break;
-	case INTEL_FAM6_ATOM_GOLDMONT:
-	case INTEL_FAM6_ATOM_GOLDMONT_PLUS:
+	case INTEL_ATOM_GOLDMONT:
+	case INTEL_ATOM_GOLDMONT_PLUS:
 		bxt_idle_state_table_update();
 		break;
-	case INTEL_FAM6_SKYLAKE:
+	case INTEL_SKYLAKE:
 		sklh_idle_state_table_update();
 		break;
-	case INTEL_FAM6_SKYLAKE_X:
+	case INTEL_SKYLAKE_X:
 		skx_idle_state_table_update();
 		break;
-	case INTEL_FAM6_SAPPHIRERAPIDS_X:
-	case INTEL_FAM6_EMERALDRAPIDS_X:
+	case INTEL_SAPPHIRERAPIDS_X:
+	case INTEL_EMERALDRAPIDS_X:
 		spr_idle_state_table_update();
 		break;
-	case INTEL_FAM6_ALDERLAKE:
-	case INTEL_FAM6_ALDERLAKE_L:
-	case INTEL_FAM6_ATOM_GRACEMONT:
+	case INTEL_ALDERLAKE:
+	case INTEL_ALDERLAKE_L:
+	case INTEL_ATOM_GRACEMONT:
 		adl_idle_state_table_update();
 		break;
 	}
@@ -1595,12 +1595,16 @@ static void __init mwait_idle_state_table_update(void)
 static int __init mwait_idle_probe(void)
 {
 	unsigned int eax, ebx, ecx;
-	const struct x86_cpu_id *id = x86_match_cpu(intel_idle_ids);
+	const struct x86_cpu_id *id;
 	const char *str;
 
+	if (boot_cpu_data.vendor != X86_VENDOR_INTEL)
+		return -ENODEV;
+
+	id = x86_match_cpu(intel_idle_ids);
 	if (!id) {
 		pr_debug(PREFIX "does not run on family %d model %d\n",
-			 boot_cpu_data.x86, boot_cpu_data.x86_model);
+			 boot_cpu_data.family, boot_cpu_data.model);
 		return -ENODEV;
 	}
 
Signature · 1 line
2.39.5
#2 lore raw

PATCH 2/4 x86/cpu-policy: Update vendor/family/model logic

In reply to Andrew Cooper

Switch to the new fields and constants.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

This updates one related part in intel.c for ease of ordering subseuqent work.

---
 xen/arch/x86/cpu-policy.c | 19 ++++++++-----------
 xen/arch/x86/cpu/intel.c  |  3 +--
 2 files changed, 9 insertions(+), 13 deletions(-)
xen/arch/x86/cpu-policy.c +8 -11
index 3e628e008e92..5ee8ce1ef7bb 100644
@@ -342,7 +342,7 @@ void calculate_raw_cpu_policy(void)
     x86_cpu_policy_fill_native(p);
 
     /* Nothing good will come from Xen and libx86 disagreeing on vendor. */
-    ASSERT(p->x86_vendor == boot_cpu_data.x86_vendor);
+    ASSERT(p->x86_vendor == boot_cpu_data.vendor);
 
     /*
      * Clear the truly dynamic fields.  These vary with the in-context XCR0
@@ -417,7 +417,7 @@ static void __init guest_common_default_leaves(struct cpu_policy *p)
 
 static void __init guest_common_max_feature_adjustments(uint32_t *fs)
 {
-    switch ( boot_cpu_data.x86_vendor )
+    switch ( boot_cpu_data.vendor )
     {
     case X86_VENDOR_INTEL:
         /*
@@ -460,8 +460,7 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
          * We hid CLWB in the host policy to stop Xen using it, but VMs which
          * have previously seen the CLWB feature can safely run on this CPU.
          */
-        if ( boot_cpu_data.x86 == 6 &&
-             boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X &&
+        if ( boot_cpu_data.vfm == INTEL_SKYLAKE_X &&
              raw_cpu_policy.feat.clwb )
             __set_bit(X86_FEATURE_CLWB, fs);
 
@@ -506,7 +505,7 @@ static void __init guest_common_max_feature_adjustments(uint32_t *fs)
 
 static void __init guest_common_default_feature_adjustments(uint32_t *fs)
 {
-    switch ( boot_cpu_data.x86_vendor )
+    switch ( boot_cpu_data.vendor )
     {
     case X86_VENDOR_INTEL:
         /*
@@ -520,8 +519,7 @@ static void __init guest_common_default_feature_adjustments(uint32_t *fs)
          * (cpuid="host,rdrand=1") in the VM's config file, and VMs which were
          * previously using RDRAND can migrate in.
          */
-        if ( boot_cpu_data.x86 == 6 &&
-             boot_cpu_data.x86_model == INTEL_FAM6_IVYBRIDGE &&
+        if ( boot_cpu_data.vfm == INTEL_IVYBRIDGE &&
              cpu_has_rdrand && !is_forced_cpu_cap(X86_FEATURE_RDRAND) )
             __clear_bit(X86_FEATURE_RDRAND, fs);
 
@@ -548,8 +546,7 @@ static void __init guest_common_default_feature_adjustments(uint32_t *fs)
          * it to the max policy to let VMs migrate in.  Re-hide it in the
          * default policy to disuade VMs from using it in the common case.
          */
-        if ( boot_cpu_data.x86 == 6 &&
-             boot_cpu_data.x86_model == INTEL_FAM6_SKYLAKE_X &&
+        if ( boot_cpu_data.vfm == INTEL_SKYLAKE_X &&
              raw_cpu_policy.feat.clwb )
             __clear_bit(X86_FEATURE_CLWB, fs);
 
@@ -755,7 +752,7 @@ static void __init calculate_hvm_max_policy(void)
      * long mode (and init_amd() has cleared it out of host capabilities), but
      * HVM guests are able if running in protected mode.
      */
-    if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&
+    if ( (boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) &&
          raw_cpu_policy.basic.sep )
         __set_bit(X86_FEATURE_SEP, fs);
 
@@ -983,7 +980,7 @@ void recalculate_cpuid_policy(struct domain *d)
     if ( is_pv_32bit_domain(d) )
     {
         __clear_bit(X86_FEATURE_LM, max_fs);
-        if ( !(boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+        if ( !(boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
             __clear_bit(X86_FEATURE_SYSCALL, max_fs);
     }
 
xen/arch/x86/cpu/intel.c +1 -2
index 05f78fa5bb30..faace882f1c4 100644
@@ -672,8 +672,7 @@ static void cf_check init_intel(struct cpuinfo_x86 *c)
 	 * latter is not impacted.  Hide CLWB to cause Xen to fall back to
 	 * using CLFLUSHOPT instead.
 	 */
-	if (c == &boot_cpu_data &&
-	    c->x86 == 6 && c->x86_model == INTEL_FAM6_SKYLAKE_X)
+	if (c == &boot_cpu_data && c->vfm == INTEL_SKYLAKE_X)
 		setup_clear_cpu_cap(X86_FEATURE_CLWB);
 }
 
Signature · 1 line
2.39.5
#3 lore raw

PATCH 3/4 x86/spec-ctrl: Update vendor/family/model logic

In reply to Andrew Cooper

Switch to the new fields and constants.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

I've intentionally not converted the tables with raw numbers yet. That's not a mechanical change, and requires more care.

---
 xen/arch/x86/spec_ctrl.c | 162 +++++++++++++++++++--------------------
 1 file changed, 80 insertions(+), 82 deletions(-)
xen/arch/x86/spec_ctrl.c +80 -82
index bcdae1ed2377..c5bc2eef9572 100644
@@ -388,7 +388,7 @@ int8_t __ro_after_init opt_xpti_domu = -1;
 
 static __init void xpti_init_default(void)
 {
-    if ( (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ||
+    if ( (boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) ||
          cpu_has_rdcl_no )
     {
         if ( opt_xpti_hwdom < 0 )
@@ -712,8 +712,8 @@ static bool __init check_smt_enabled(void)
      * At the time of writing, it is almost completely undocumented, so isn't
      * virtualised reliably.
      */
-    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-         boot_cpu_data.x86 != 0xf && !cpu_has_hypervisor &&
+    if ( boot_cpu_data.vendor == X86_VENDOR_INTEL &&
+         boot_cpu_data.family != 0xf && !cpu_has_hypervisor &&
          !rdmsr_safe(MSR_INTEL_CORE_THREAD_COUNT, val) )
         return (MASK_EXTR(val, MSR_CTC_CORE_MASK) !=
                 MASK_EXTR(val, MSR_CTC_THREAD_MASK));
@@ -738,11 +738,11 @@ static bool __init retpoline_calculations(void)
     unsigned int ucode_rev = this_cpu(cpu_sig).rev;
     bool safe = false;
 
-    if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
+    if ( boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
         return true;
 
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return false;
 
     /*
@@ -793,8 +793,8 @@ static bool __init retpoline_calculations(void)
     {
         printk(XENLOG_ERR
                "FIRMWARE BUG: CPU %02x-%02x-%02x, ucode 0x%08x: RSBA %u, EIBRS %u, RRSBA %u\n",
-               boot_cpu_data.x86, boot_cpu_data.x86_model,
-               boot_cpu_data.x86_mask, ucode_rev,
+               boot_cpu_data.family, boot_cpu_data.model,
+               boot_cpu_data.stepping, ucode_rev,
                cpu_has_rsba, cpu_has_eibrs, cpu_has_rrsba);
         add_taint(TAINT_CPU_OUT_OF_SPEC);
     }
@@ -833,7 +833,7 @@ static bool __init retpoline_calculations(void)
     if ( cpu_has_arch_caps )
         return true;
 
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.model )
     {
     case 0x17: /* Penryn */
     case 0x1d: /* Dunnington */
@@ -866,7 +866,7 @@ static bool __init retpoline_calculations(void)
     case 0x4f: /* Broadwell EP/EX */
         safe = ucode_rev >= 0xb000021; break;
     case 0x56: /* Broadwell D */
-        switch ( boot_cpu_data.x86_mask )
+        switch ( boot_cpu_data.stepping )
         {
         case 2:  safe = ucode_rev >= 0x15;      break;
         case 3:  safe = ucode_rev >= 0x7000012; break;
@@ -874,7 +874,7 @@ static bool __init retpoline_calculations(void)
         case 5:  safe = ucode_rev >= 0xe000009; break;
         default:
             printk("Unrecognised CPU stepping %#x - assuming not reptpoline safe\n",
-                   boot_cpu_data.x86_mask);
+                   boot_cpu_data.stepping);
             safe = false;
             break;
         }
@@ -913,7 +913,7 @@ static bool __init retpoline_calculations(void)
 
     default:
         printk("Unrecognised CPU model %#x - assuming not reptpoline safe\n",
-               boot_cpu_data.x86_model);
+               boot_cpu_data.model);
         safe = false;
         break;
     }
@@ -938,11 +938,11 @@ static bool __init retpoline_calculations(void)
  */
 static bool __init rsb_is_full_width(void)
 {
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return true;
 
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.model )
     {
     case 0x37: /* Baytrail / Valleyview (Silvermont) */
     case 0x4a: /* Merrifield */
@@ -966,11 +966,11 @@ static bool __init should_use_eager_fpu(void)
      * Assume all unrecognised processors are ok.  This is only known to
      * affect Intel Family 6 processors.
      */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return false;
 
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.model )
     {
         /*
          * Core processors since at least Nehalem are vulnerable.
@@ -1023,7 +1023,7 @@ static bool __init should_use_eager_fpu(void)
 
     default:
         printk("Unrecognised CPU model %#x - assuming vulnerable to LazyFPU\n",
-               boot_cpu_data.x86_model);
+               boot_cpu_data.model);
         return true;
     }
 }
@@ -1033,8 +1033,7 @@ static bool __init should_use_eager_fpu(void)
  */
 static void __init srso_calculations(bool hw_smt_enabled)
 {
-    if ( !(boot_cpu_data.x86_vendor &
-           (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+    if ( !(boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
         return;
 
     /*
@@ -1044,7 +1043,7 @@ static void __init srso_calculations(bool hw_smt_enabled)
     if ( cpu_has_hypervisor )
         return;
 
-    if ( boot_cpu_data.x86 == 0x19 )
+    if ( boot_cpu_data.family == 0x19 )
     {
         /*
          * We could have a table of models/microcode revisions.  ...or we
@@ -1059,7 +1058,7 @@ static void __init srso_calculations(bool hw_smt_enabled)
             printk(XENLOG_WARNING
                    "Vulnerable to SRSO, without suitable microcode to mitigate\n");
     }
-    else if ( boot_cpu_data.x86 < 0x19 )
+    else if ( boot_cpu_data.family < 0x19 )
     {
         /*
          * Zen1/2 (which have the IBPB microcode) have IBPB_BRTYPE behaviour
@@ -1084,7 +1083,7 @@ static void __init srso_calculations(bool hw_smt_enabled)
      * they can be altered at runtime so it's not safe to presume SRSO_NO.
      */
     if ( !hw_smt_enabled &&
-         (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) )
+         (boot_cpu_data.family == 0x17 || boot_cpu_data.family == 0x18) )
         setup_force_cpu_cap(X86_FEATURE_SRSO_NO);
 }
 
@@ -1100,11 +1099,10 @@ static void __init srso_calculations(bool hw_smt_enabled)
  */
 static bool __init has_div_vuln(void)
 {
-    if ( !(boot_cpu_data.x86_vendor &
-           (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
+    if ( !(boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON)) )
         return false;
 
-    if ( boot_cpu_data.x86 != 0x17 && boot_cpu_data.x86 != 0x18 )
+    if ( boot_cpu_data.family != 0x17 && boot_cpu_data.family != 0x18 )
         return false;
 
     return is_zen1_uarch();
@@ -1139,7 +1137,7 @@ static void __init ibpb_calculations(void)
         return;
     }
 
-    if ( boot_cpu_data.x86_vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
+    if ( boot_cpu_data.vendor & (X86_VENDOR_AMD | X86_VENDOR_HYGON) )
     {
         /*
          * AMD/Hygon CPUs to date (June 2022) don't flush the RAS.  Future
@@ -1224,10 +1222,10 @@ static __init void l1tf_calculations(void)
     l1d_maxphysaddr = paddr_bits;
 
     /* L1TF is only known to affect Intel Family 6 processors at this time. */
-    if ( boot_cpu_data.x86_vendor == X86_VENDOR_INTEL &&
-         boot_cpu_data.x86 == 6 )
+    if ( boot_cpu_data.vendor == X86_VENDOR_INTEL &&
+         boot_cpu_data.family == 6 )
     {
-        switch ( boot_cpu_data.x86_model )
+        switch ( boot_cpu_data.model )
         {
             /*
              * Core processors since at least Penryn are vulnerable.
@@ -1303,7 +1301,7 @@ static __init void l1tf_calculations(void)
 
     if ( cpu_has_bug_l1tf && hit_default )
         printk("Unrecognised CPU model %#x - assuming vulnerable to L1TF\n",
-               boot_cpu_data.x86_model);
+               boot_cpu_data.model);
 
     /*
      * L1TF safe address heuristics.  These apply to the real hardware we are
@@ -1360,15 +1358,15 @@ static __init void l1tf_calculations(void)
 static __init void mds_calculations(void)
 {
     /* MDS is only known to affect Intel Family 6 processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return;
 
     /* Any processor advertising MDS_NO should be not vulnerable to MDS. */
     if ( cpu_has_mds_no )
         return;
 
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.model )
     {
         /*
          * Core processors since at least Nehalem are vulnerable.
@@ -1401,17 +1399,17 @@ static __init void mds_calculations(void)
          * Some Core processors have per-stepping vulnerability.
          */
     case 0x55: /* Skylake-X / Cascade Lake */
-        if ( boot_cpu_data.x86_mask <= 5 )
+        if ( boot_cpu_data.stepping <= 5 )
             cpu_has_bug_mds = true;
         break;
 
     case 0x8e: /* Kaby / Coffee / Whiskey Lake M */
-        if ( boot_cpu_data.x86_mask <= 0xb )
+        if ( boot_cpu_data.stepping <= 0xb )
             cpu_has_bug_mds = true;
         break;
 
     case 0x9e: /* Kaby / Coffee / Whiskey Lake D */
-        if ( boot_cpu_data.x86_mask <= 0xc )
+        if ( boot_cpu_data.stepping <= 0xc )
             cpu_has_bug_mds = true;
         break;
 
@@ -1444,7 +1442,7 @@ static __init void mds_calculations(void)
 
     default:
         printk("Unrecognised CPU model %#x - assuming vulnerable to MDS\n",
-               boot_cpu_data.x86_model);
+               boot_cpu_data.model);
         cpu_has_bug_mds = true;
         break;
     }
@@ -1471,8 +1469,8 @@ static __init void mds_calculations(void)
 static void __init rfds_calculations(void)
 {
     /* RFDS is only known to affect Intel Family 6 processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return;
 
     /*
@@ -1490,10 +1488,10 @@ static void __init rfds_calculations(void)
      * Not all CPUs are expected to get a microcode update enumerating one of
      * RFDS_{NO,CLEAR}, or we might have out-of-date microcode.
      */
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.vfm )
     {
-    case INTEL_FAM6_ALDERLAKE:
-    case INTEL_FAM6_RAPTORLAKE:
+    case INTEL_ALDERLAKE:
+    case INTEL_RAPTORLAKE:
         /*
          * Alder Lake and Raptor Lake might be a client SKU (with the
          * Gracemont cores active, and therefore vulnerable) or might be a
@@ -1505,17 +1503,17 @@ static void __init rfds_calculations(void)
         if ( !cpu_has_hybrid )
             break;
         fallthrough;
-    case INTEL_FAM6_ALDERLAKE_L:
-    case INTEL_FAM6_RAPTORLAKE_P:
-    case INTEL_FAM6_RAPTORLAKE_S:
-
-    case INTEL_FAM6_ATOM_GOLDMONT:      /* Apollo Lake */
-    case INTEL_FAM6_ATOM_GOLDMONT_D:    /* Denverton */
-    case INTEL_FAM6_ATOM_GOLDMONT_PLUS: /* Gemini Lake */
-    case INTEL_FAM6_ATOM_TREMONT_D:     /* Snow Ridge / Parker Ridge */
-    case INTEL_FAM6_ATOM_TREMONT:       /* Elkhart Lake */
-    case INTEL_FAM6_ATOM_TREMONT_L:     /* Jasper Lake */
-    case INTEL_FAM6_ATOM_GRACEMONT:     /* Alder Lake N */
+    case INTEL_ALDERLAKE_L:
+    case INTEL_RAPTORLAKE_P:
+    case INTEL_RAPTORLAKE_S:
+
+    case INTEL_ATOM_GOLDMONT:      /* Apollo Lake */
+    case INTEL_ATOM_GOLDMONT_D:    /* Denverton */
+    case INTEL_ATOM_GOLDMONT_PLUS: /* Gemini Lake */
+    case INTEL_ATOM_TREMONT_D:     /* Snow Ridge / Parker Ridge */
+    case INTEL_ATOM_TREMONT:       /* Elkhart Lake */
+    case INTEL_ATOM_TREMONT_L:     /* Jasper Lake */
+    case INTEL_ATOM_GRACEMONT:     /* Alder Lake N */
         return;
     }
 
@@ -1537,7 +1535,7 @@ static void __init tsa_calculations(void)
     unsigned int curr_rev, min_rev;
 
     /* TSA is only known to affect AMD processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_AMD )
+    if ( boot_cpu_data.vendor != X86_VENDOR_AMD )
         return;
 
     /* If we're virtualised, don't attempt to synthesise anything. */
@@ -1556,7 +1554,7 @@ static void __init tsa_calculations(void)
      * ... otherwise, synthesise them.  CPUs other than Fam19 (Zen3/4) are
      * stated to be not vulnerable.
      */
-    if ( boot_cpu_data.x86 != 0x19 )
+    if ( boot_cpu_data.family != 0x19 )
     {
         setup_force_cpu_cap(X86_FEATURE_TSA_SQ_NO);
         setup_force_cpu_cap(X86_FEATURE_TSA_L1_NO);
@@ -1589,8 +1587,8 @@ static void __init tsa_calculations(void)
     default:
         printk(XENLOG_WARNING
                "Unrecognised CPU %02x-%02x-%02x, ucode 0x%08x for TSA mitigation\n",
-               boot_cpu_data.x86, boot_cpu_data.x86_model,
-               boot_cpu_data.x86_mask, curr_rev);
+               boot_cpu_data.family, boot_cpu_data.model,
+               boot_cpu_data.stepping, curr_rev);
         return;
     }
 
@@ -1631,7 +1629,7 @@ static bool __init cpu_has_gds(void)
      * Cove (Alder Lake, Sapphire Rapids).  Broadwell and older, and the Atom
      * line, and all hybrid parts are unaffected.
      */
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.model )
     {
     case 0x55: /* Skylake/Cascade Lake/Cooper Lake SP */
     case 0x6a: /* Ice Lake SP */
@@ -1661,8 +1659,8 @@ static void __init gds_calculations(void)
     bool cpu_has_bug_gds, mitigated = false;
 
     /* GDS is only known to affect Intel Family 6 processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return;
 
     cpu_has_bug_gds = cpu_has_gds();
@@ -1684,8 +1682,8 @@ static void __init gds_calculations(void)
              */
             printk(XENLOG_ERR
                    "FIRMWARE BUG: CPU %02x-%02x-%02x, ucode 0x%08x: GDS_CTRL && GDS_NO\n",
-                   boot_cpu_data.x86, boot_cpu_data.x86_model,
-                   boot_cpu_data.x86_mask, this_cpu(cpu_sig).rev);
+                   boot_cpu_data.family, boot_cpu_data.model,
+                   boot_cpu_data.stepping, this_cpu(cpu_sig).rev);
             return add_taint(TAINT_CPU_OUT_OF_SPEC);
         }
 
@@ -1756,8 +1754,8 @@ static void __init gds_calculations(void)
 static bool __init cpu_has_bug_bhi(void)
 {
     /* BHI is only known to affect Intel Family 6 processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL ||
-         boot_cpu_data.x86 != 6 )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL ||
+         boot_cpu_data.family != 6 )
         return false;
 
     if ( boot_cpu_has(X86_FEATURE_BHI_NO) )
@@ -1880,7 +1878,7 @@ static void __init its_calculations(void)
         return;
 
     /* ITS is only known to affect Intel processors at this time. */
-    if ( boot_cpu_data.x86_vendor != X86_VENDOR_INTEL )
+    if ( boot_cpu_data.vendor != X86_VENDOR_INTEL )
         return;
 
     /*
@@ -1890,27 +1888,27 @@ static void __init its_calculations(void)
      *  - those with BHI_CTRL
      * but we still need to synthesise ITS_NO.
      */
-    if ( boot_cpu_data.x86 != 6 || !cpu_has_eibrs ||
+    if ( boot_cpu_data.family != 6 || !cpu_has_eibrs ||
          boot_cpu_has(X86_FEATURE_BHI_CTRL) )
         goto synthesise;
 
-    switch ( boot_cpu_data.x86_model )
+    switch ( boot_cpu_data.vfm )
     {
         /* These Skylake-uarch cores suffer cases #2 and #3. */
-    case INTEL_FAM6_SKYLAKE_X:
-    case INTEL_FAM6_KABYLAKE_L:
-    case INTEL_FAM6_KABYLAKE:
-    case INTEL_FAM6_COMETLAKE:
-    case INTEL_FAM6_COMETLAKE_L:
+    case INTEL_SKYLAKE_X:
+    case INTEL_KABYLAKE_L:
+    case INTEL_KABYLAKE:
+    case INTEL_COMETLAKE:
+    case INTEL_COMETLAKE_L:
         return;
 
         /* These Sunny/Willow/Cypress Cove cores suffer case #3. */
-    case INTEL_FAM6_ICELAKE_X:
-    case INTEL_FAM6_ICELAKE_D:
-    case INTEL_FAM6_ICELAKE_L:
-    case INTEL_FAM6_TIGERLAKE_L:
-    case INTEL_FAM6_TIGERLAKE:
-    case INTEL_FAM6_ROCKETLAKE:
+    case INTEL_ICELAKE_X:
+    case INTEL_ICELAKE_D:
+    case INTEL_ICELAKE_L:
+    case INTEL_TIGERLAKE_L:
+    case INTEL_TIGERLAKE:
+    case INTEL_ROCKETLAKE:
         return;
 
     default:
@@ -2183,8 +2181,8 @@ void __init init_speculation_mitigations(void)
          * before going idle is less overhead than flushing on PV entry.
          */
         if ( !opt_rsb_pv && hw_smt_enabled &&
-             (boot_cpu_data.x86_vendor & (X86_VENDOR_AMD|X86_VENDOR_HYGON)) &&
-             (boot_cpu_data.x86 == 0x17 || boot_cpu_data.x86 == 0x18) )
+             (boot_cpu_data.vendor & (X86_VENDOR_AMD|X86_VENDOR_HYGON)) &&
+             (boot_cpu_data.family == 0x17 || boot_cpu_data.family == 0x18) )
             setup_force_cpu_cap(X86_FEATURE_SC_RSB_IDLE);
     }
 
Signature · 1 line
2.39.5
#4 lore raw

PATCH 4/4 x86/intel-family: Resync with Linux

In reply to Andrew Cooper

This snapshot is Linux commit db4001f9cc32 ("x86/cpu/vfm: Delete all the *_FAM6_ CPU #defines"), now that Xen has switched off the old constant names.

Leave a comment identifying the exact revision Xen is using.

No functional change.

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>

INTEL_FAM5_QUARK_X1000 ought to have been deleted in this commit in Linux. It has been removed since.

---
 xen/arch/x86/include/asm/intel-family.h | 90 ++-----------------------
 1 file changed, 7 insertions(+), 83 deletions(-)
xen/arch/x86/include/asm/intel-family.h +7 -83
index 5858e7398570..d8c0bcc406de 100644
@@ -1,4 +1,9 @@
 /* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * Snapshot from Linux:
+ *   db4001f9cc32e3ef105a4e4f492d7d813b28292a
+ *   x86/cpu/vfm: Delete all the *_FAM6_ CPU #defines
+ */
 #ifndef _ASM_X86_INTEL_FAMILY_H
 #define _ASM_X86_INTEL_FAMILY_H
 
@@ -10,7 +15,7 @@
  * that group keep the CPUID for the variants sorted by model number.
  *
  * The defined symbol names have the following form:
- *	INTEL_FAM6{OPTFAMILY}_{MICROARCH}{OPTDIFF}
+ *	INTEL_{OPTFAMILY}_{MICROARCH}{OPTDIFF}
  * where:
  * OPTFAMILY	Describes the family of CPUs that this belongs to. Default
  *		is assumed to be "_CORE" (and should be omitted). Other values
@@ -42,217 +47,136 @@
 
 #define IFM(_fam, _model)	VFM_MAKE(X86_VENDOR_INTEL, _fam, _model)
 
-/* Wildcard match for FAM6 so X86_MATCH_INTEL_FAM6_MODEL(ANY) works */
-#define INTEL_FAM6_ANY			X86_MODEL_ANY
-/* Wildcard match for FAM6 so X86_MATCH_VFM(ANY) works */
+/* Wildcard match so X86_MATCH_VFM(ANY) works */
 #define INTEL_ANY			IFM(X86_FAMILY_ANY, X86_MODEL_ANY)
 
 #define INTEL_PENTIUM_PRO		IFM(6, 0x01)
 
-#define INTEL_FAM6_CORE_YONAH		0x0E
 #define INTEL_CORE_YONAH		IFM(6, 0x0E)
 
-#define INTEL_FAM6_CORE2_MEROM		0x0F
 #define INTEL_CORE2_MEROM		IFM(6, 0x0F)
-#define INTEL_FAM6_CORE2_MEROM_L	0x16
 #define INTEL_CORE2_MEROM_L		IFM(6, 0x16)
-#define INTEL_FAM6_CORE2_PENRYN		0x17
 #define INTEL_CORE2_PENRYN		IFM(6, 0x17)
-#define INTEL_FAM6_CORE2_DUNNINGTON	0x1D
 #define INTEL_CORE2_DUNNINGTON		IFM(6, 0x1D)
 
-#define INTEL_FAM6_NEHALEM		0x1E
 #define INTEL_NEHALEM			IFM(6, 0x1E)
-#define INTEL_FAM6_NEHALEM_G		0x1F /* Auburndale / Havendale */
 #define INTEL_NEHALEM_G			IFM(6, 0x1F) /* Auburndale / Havendale */
-#define INTEL_FAM6_NEHALEM_EP		0x1A
 #define INTEL_NEHALEM_EP		IFM(6, 0x1A)
-#define INTEL_FAM6_NEHALEM_EX		0x2E
 #define INTEL_NEHALEM_EX		IFM(6, 0x2E)
 
-#define INTEL_FAM6_WESTMERE		0x25
 #define INTEL_WESTMERE			IFM(6, 0x25)
-#define INTEL_FAM6_WESTMERE_EP		0x2C
 #define INTEL_WESTMERE_EP		IFM(6, 0x2C)
-#define INTEL_FAM6_WESTMERE_EX		0x2F
 #define INTEL_WESTMERE_EX		IFM(6, 0x2F)
 
-#define INTEL_FAM6_SANDYBRIDGE		0x2A
 #define INTEL_SANDYBRIDGE		IFM(6, 0x2A)
-#define INTEL_FAM6_SANDYBRIDGE_X	0x2D
 #define INTEL_SANDYBRIDGE_X		IFM(6, 0x2D)
-#define INTEL_FAM6_IVYBRIDGE		0x3A
 #define INTEL_IVYBRIDGE			IFM(6, 0x3A)
-#define INTEL_FAM6_IVYBRIDGE_X		0x3E
 #define INTEL_IVYBRIDGE_X		IFM(6, 0x3E)
 
-#define INTEL_FAM6_HASWELL		0x3C
 #define INTEL_HASWELL			IFM(6, 0x3C)
-#define INTEL_FAM6_HASWELL_X		0x3F
 #define INTEL_HASWELL_X			IFM(6, 0x3F)
-#define INTEL_FAM6_HASWELL_L		0x45
 #define INTEL_HASWELL_L			IFM(6, 0x45)
-#define INTEL_FAM6_HASWELL_G		0x46
 #define INTEL_HASWELL_G			IFM(6, 0x46)
 
-#define INTEL_FAM6_BROADWELL		0x3D
 #define INTEL_BROADWELL			IFM(6, 0x3D)
-#define INTEL_FAM6_BROADWELL_G		0x47
 #define INTEL_BROADWELL_G		IFM(6, 0x47)
-#define INTEL_FAM6_BROADWELL_X		0x4F
 #define INTEL_BROADWELL_X		IFM(6, 0x4F)
-#define INTEL_FAM6_BROADWELL_D		0x56
 #define INTEL_BROADWELL_D		IFM(6, 0x56)
 
-#define INTEL_FAM6_SKYLAKE_L		0x4E	/* Sky Lake             */
 #define INTEL_SKYLAKE_L			IFM(6, 0x4E) /* Sky Lake */
-#define INTEL_FAM6_SKYLAKE		0x5E	/* Sky Lake             */
 #define INTEL_SKYLAKE			IFM(6, 0x5E) /* Sky Lake */
-#define INTEL_FAM6_SKYLAKE_X		0x55	/* Sky Lake             */
 #define INTEL_SKYLAKE_X			IFM(6, 0x55) /* Sky Lake */
 /*                 CASCADELAKE_X	0x55	   Sky Lake -- s: 7     */
 /*                 COOPERLAKE_X		0x55	   Sky Lake -- s: 11    */
 
-#define INTEL_FAM6_KABYLAKE_L		0x8E	/* Sky Lake             */
 #define INTEL_KABYLAKE_L		IFM(6, 0x8E) /* Sky Lake */
 /*                 AMBERLAKE_L		0x8E	   Sky Lake -- s: 9     */
 /*                 COFFEELAKE_L		0x8E	   Sky Lake -- s: 10    */
 /*                 WHISKEYLAKE_L	0x8E       Sky Lake -- s: 11,12 */
 
-#define INTEL_FAM6_KABYLAKE		0x9E	/* Sky Lake             */
 #define INTEL_KABYLAKE			IFM(6, 0x9E) /* Sky Lake */
 /*                 COFFEELAKE		0x9E	   Sky Lake -- s: 10-13 */
 
-#define INTEL_FAM6_COMETLAKE		0xA5	/* Sky Lake             */
 #define INTEL_COMETLAKE			IFM(6, 0xA5) /* Sky Lake */
-#define INTEL_FAM6_COMETLAKE_L		0xA6	/* Sky Lake             */
 #define INTEL_COMETLAKE_L		IFM(6, 0xA6) /* Sky Lake */
 
-#define INTEL_FAM6_CANNONLAKE_L		0x66	/* Palm Cove */
 #define INTEL_CANNONLAKE_L		IFM(6, 0x66) /* Palm Cove */
 
-#define INTEL_FAM6_ICELAKE_X		0x6A	/* Sunny Cove */
 #define INTEL_ICELAKE_X			IFM(6, 0x6A) /* Sunny Cove */
-#define INTEL_FAM6_ICELAKE_D		0x6C	/* Sunny Cove */
 #define INTEL_ICELAKE_D			IFM(6, 0x6C) /* Sunny Cove */
-#define INTEL_FAM6_ICELAKE		0x7D	/* Sunny Cove */
 #define INTEL_ICELAKE			IFM(6, 0x7D) /* Sunny Cove */
-#define INTEL_FAM6_ICELAKE_L		0x7E	/* Sunny Cove */
 #define INTEL_ICELAKE_L			IFM(6, 0x7E) /* Sunny Cove */
-#define INTEL_FAM6_ICELAKE_NNPI		0x9D	/* Sunny Cove */
 #define INTEL_ICELAKE_NNPI		IFM(6, 0x9D) /* Sunny Cove */
 
-#define INTEL_FAM6_ROCKETLAKE		0xA7	/* Cypress Cove */
 #define INTEL_ROCKETLAKE		IFM(6, 0xA7) /* Cypress Cove */
 
-#define INTEL_FAM6_TIGERLAKE_L		0x8C	/* Willow Cove */
 #define INTEL_TIGERLAKE_L		IFM(6, 0x8C) /* Willow Cove */
-#define INTEL_FAM6_TIGERLAKE		0x8D	/* Willow Cove */
 #define INTEL_TIGERLAKE			IFM(6, 0x8D) /* Willow Cove */
 
-#define INTEL_FAM6_SAPPHIRERAPIDS_X	0x8F	/* Golden Cove */
 #define INTEL_SAPPHIRERAPIDS_X		IFM(6, 0x8F) /* Golden Cove */
 
-#define INTEL_FAM6_EMERALDRAPIDS_X	0xCF
 #define INTEL_EMERALDRAPIDS_X		IFM(6, 0xCF)
 
-#define INTEL_FAM6_GRANITERAPIDS_X	0xAD
 #define INTEL_GRANITERAPIDS_X		IFM(6, 0xAD)
-#define INTEL_FAM6_GRANITERAPIDS_D	0xAE
 #define INTEL_GRANITERAPIDS_D		IFM(6, 0xAE)
 
 /* "Hybrid" Processors (P-Core/E-Core) */
 
-#define INTEL_FAM6_LAKEFIELD		0x8A	/* Sunny Cove / Tremont */
 #define INTEL_LAKEFIELD			IFM(6, 0x8A) /* Sunny Cove / Tremont */
 
-#define INTEL_FAM6_ALDERLAKE		0x97	/* Golden Cove / Gracemont */
 #define INTEL_ALDERLAKE			IFM(6, 0x97) /* Golden Cove / Gracemont */
-#define INTEL_FAM6_ALDERLAKE_L		0x9A	/* Golden Cove / Gracemont */
 #define INTEL_ALDERLAKE_L		IFM(6, 0x9A) /* Golden Cove / Gracemont */
 
-#define INTEL_FAM6_RAPTORLAKE		0xB7	/* Raptor Cove / Enhanced Gracemont */
 #define INTEL_RAPTORLAKE		IFM(6, 0xB7) /* Raptor Cove / Enhanced Gracemont */
-#define INTEL_FAM6_RAPTORLAKE_P		0xBA
 #define INTEL_RAPTORLAKE_P		IFM(6, 0xBA)
-#define INTEL_FAM6_RAPTORLAKE_S		0xBF
 #define INTEL_RAPTORLAKE_S		IFM(6, 0xBF)
 
-#define INTEL_FAM6_METEORLAKE		0xAC
 #define INTEL_METEORLAKE		IFM(6, 0xAC)
-#define INTEL_FAM6_METEORLAKE_L		0xAA
 #define INTEL_METEORLAKE_L		IFM(6, 0xAA)
 
-#define INTEL_FAM6_ARROWLAKE_H		0xC5
 #define INTEL_ARROWLAKE_H		IFM(6, 0xC5)
-#define INTEL_FAM6_ARROWLAKE		0xC6
 #define INTEL_ARROWLAKE			IFM(6, 0xC6)
-#define INTEL_FAM6_ARROWLAKE_U		0xB5
 #define INTEL_ARROWLAKE_U		IFM(6, 0xB5)
 
-#define INTEL_FAM6_LUNARLAKE_M		0xBD
 #define INTEL_LUNARLAKE_M		IFM(6, 0xBD)
 
 /* "Small Core" Processors (Atom/E-Core) */
 
-#define INTEL_FAM6_ATOM_BONNELL		0x1C /* Diamondville, Pineview */
 #define INTEL_ATOM_BONNELL		IFM(6, 0x1C) /* Diamondville, Pineview */
-#define INTEL_FAM6_ATOM_BONNELL_MID	0x26 /* Silverthorne, Lincroft */
 #define INTEL_ATOM_BONNELL_MID		IFM(6, 0x26) /* Silverthorne, Lincroft */
 
-#define INTEL_FAM6_ATOM_SALTWELL	0x36 /* Cedarview */
 #define INTEL_ATOM_SALTWELL		IFM(6, 0x36) /* Cedarview */
-#define INTEL_FAM6_ATOM_SALTWELL_MID	0x27 /* Penwell */
 #define INTEL_ATOM_SALTWELL_MID		IFM(6, 0x27) /* Penwell */
-#define INTEL_FAM6_ATOM_SALTWELL_TABLET	0x35 /* Cloverview */
 #define INTEL_ATOM_SALTWELL_TABLET	IFM(6, 0x35) /* Cloverview */
 
-#define INTEL_FAM6_ATOM_SILVERMONT	0x37 /* Bay Trail, Valleyview */
 #define INTEL_ATOM_SILVERMONT		IFM(6, 0x37) /* Bay Trail, Valleyview */
-#define INTEL_FAM6_ATOM_SILVERMONT_D	0x4D /* Avaton, Rangely */
 #define INTEL_ATOM_SILVERMONT_D		IFM(6, 0x4D) /* Avaton, Rangely */
-#define INTEL_FAM6_ATOM_SILVERMONT_MID	0x4A /* Merriefield */
 #define INTEL_ATOM_SILVERMONT_MID	IFM(6, 0x4A) /* Merriefield */
 
-#define INTEL_FAM6_ATOM_AIRMONT		0x4C /* Cherry Trail, Braswell */
 #define INTEL_ATOM_AIRMONT		IFM(6, 0x4C) /* Cherry Trail, Braswell */
-#define INTEL_FAM6_ATOM_AIRMONT_MID	0x5A /* Moorefield */
 #define INTEL_ATOM_AIRMONT_MID		IFM(6, 0x5A) /* Moorefield */
-#define INTEL_FAM6_ATOM_AIRMONT_NP	0x75 /* Lightning Mountain */
 #define INTEL_ATOM_AIRMONT_NP		IFM(6, 0x75) /* Lightning Mountain */
 
-#define INTEL_FAM6_ATOM_GOLDMONT	0x5C /* Apollo Lake */
 #define INTEL_ATOM_GOLDMONT		IFM(6, 0x5C) /* Apollo Lake */
-#define INTEL_FAM6_ATOM_GOLDMONT_D	0x5F /* Denverton */
 #define INTEL_ATOM_GOLDMONT_D		IFM(6, 0x5F) /* Denverton */
 
 /* Note: the micro-architecture is "Goldmont Plus" */
-#define INTEL_FAM6_ATOM_GOLDMONT_PLUS	0x7A /* Gemini Lake */
 #define INTEL_ATOM_GOLDMONT_PLUS	IFM(6, 0x7A) /* Gemini Lake */
 
-#define INTEL_FAM6_ATOM_TREMONT_D	0x86 /* Jacobsville */
 #define INTEL_ATOM_TREMONT_D		IFM(6, 0x86) /* Jacobsville */
-#define INTEL_FAM6_ATOM_TREMONT		0x96 /* Elkhart Lake */
 #define INTEL_ATOM_TREMONT		IFM(6, 0x96) /* Elkhart Lake */
-#define INTEL_FAM6_ATOM_TREMONT_L	0x9C /* Jasper Lake */
 #define INTEL_ATOM_TREMONT_L		IFM(6, 0x9C) /* Jasper Lake */
 
-#define INTEL_FAM6_ATOM_GRACEMONT	0xBE /* Alderlake N */
 #define INTEL_ATOM_GRACEMONT		IFM(6, 0xBE) /* Alderlake N */
 
-#define INTEL_FAM6_ATOM_CRESTMONT_X	0xAF /* Sierra Forest */
 #define INTEL_ATOM_CRESTMONT_X		IFM(6, 0xAF) /* Sierra Forest */
-#define INTEL_FAM6_ATOM_CRESTMONT	0xB6 /* Grand Ridge */
 #define INTEL_ATOM_CRESTMONT		IFM(6, 0xB6) /* Grand Ridge */
 
-#define INTEL_FAM6_ATOM_DARKMONT_X	0xDD /* Clearwater Forest */
 #define INTEL_ATOM_DARKMONT_X		IFM(6, 0xDD) /* Clearwater Forest */
 
 /* Xeon Phi */
 
-#define INTEL_FAM6_XEON_PHI_KNL		0x57 /* Knights Landing */
 #define INTEL_XEON_PHI_KNL		IFM(6, 0x57) /* Knights Landing */
-#define INTEL_FAM6_XEON_PHI_KNM		0x85 /* Knights Mill */
 #define INTEL_XEON_PHI_KNM		IFM(6, 0x85) /* Knights Mill */
 
 /* Family 5 */
Signature · 1 line
2.39.5
Acked-by on the v1 series
#5 lore raw
In reply to Andrew Cooper
Quoted 10 lines · Andrew Cooper

This is a mechanical change to use the VFM constants rather than the family-specific ones.

https://gitlab.com/xen-project/hardware/xen-staging/-/pipelines/1934721940

Andrew Cooper (4):
x86/mwait-idle: Update vendor/family/model logic x86/cpu-policy: Update vendor/family/model logic x86/spec-ctrl: Update vendor/family/model logic x86/intel-family: Resync with Linux