x86/Intel: use CPUID bit to determine PPIN availability
authorJan Beulich <jbeulich@suse.com>
Thu, 27 Jan 2022 12:54:42 +0000 (13:54 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 27 Jan 2022 17:38:15 +0000 (17:38 +0000)
As of SDM revision 076 there is a CPUID bit for this functionality. Use
it to amend the existing model-based logic.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Acked-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/misc/xen-cpuid.c
xen/arch/x86/cpu/mcheck/mce_intel.c
xen/include/public/arch-x86/cpufeatureset.h

index 17e67e379fa4c728f26564b223a64744eb30235d..3c8f3ed1bad1d25b45548889e1612c3b84272018 100644 (file)
@@ -197,6 +197,7 @@ static const char *const str_e21a[32] =
 
 static const char *const str_7b1[32] =
 {
+    [ 0] = "ppin",
 };
 
 static const struct {
index d0161e9d4daa51569da337a717a9f8c725c05a46..d63d6083d3a79f76bb36d9d4febc299787433471 100644 (file)
@@ -859,12 +859,20 @@ static void intel_init_ppin(const struct cpuinfo_x86 *c)
     /*
      * Even if testing the presence of the MSR would be enough, we don't
      * want to risk the situation where other models reuse this MSR for
-     * other purposes.
+     * other purposes.  Despite the late addition of a CPUID bit (rendering
+     * the MSR architectural), keep using the same detection logic there.
      */
     switch ( c->x86_model )
     {
         uint64_t val;
 
+    default:
+        if ( !cpu_has(c, X86_FEATURE_INTEL_PPIN) )
+        {
+            ppin_msr = 0;
+            return;
+        }
+        fallthrough;
     case 0x3e: /* IvyBridge X */
     case 0x3f: /* Haswell X */
     case 0x4f: /* Broadwell X */
index 588f924de59e566b78dd246f5fd4d27bfb3ea745..6e44148a09019ca610316cf97733207d821cef1b 100644 (file)
@@ -300,6 +300,7 @@ XEN_CPUFEATURE(LFENCE_DISPATCH,    11*32+ 2) /*A  LFENCE always serializing */
 XEN_CPUFEATURE(NSCB,               11*32+ 6) /*A  Null Selector Clears Base (and limit too) */
 
 /* Intel-defined CPU features, CPUID level 0x00000007:1.ebx, word 12 */
+XEN_CPUFEATURE(INTEL_PPIN,         12*32+ 0) /*   Protected Processor Inventory Number */
 
 #endif /* XEN_CPUFEATURE */