]> xenbits.xensource.com Git - people/sstabellini/xen-unstable.git/.git/commitdiff
x86/CPUID: support leaf 7 subleaf 1 / AVX512_BF16
authorJan Beulich <jbeulich@suse.com>
Tue, 21 May 2019 13:43:00 +0000 (15:43 +0200)
committerJan Beulich <jbeulich@suse.com>
Tue, 21 May 2019 13:43:00 +0000 (15:43 +0200)
The AVX512_BF16 feature flag resides in this so far blank sub-leaf.
Expand infrastructure accordingly.

Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
tools/libxl/libxl_cpuid.c
tools/misc/xen-cpuid.c
xen/arch/x86/cpu/common.c
xen/include/public/arch-x86/cpufeatureset.h
xen/include/xen/lib/x86/cpuid.h
xen/tools/gen-cpuid.py

index 4e3656fa35986c98b2de3da3aa0c9861a33aa002..a8d07fac50c6fcfefd0b5ede60b84a635f78cc12 100644 (file)
@@ -218,6 +218,8 @@ int libxl_cpuid_parse_config(libxl_cpuid_policy_list *cpuid, const char* str)
         {"arch-caps",    0x00000007,  0, CPUID_REG_EDX, 29,  1},
         {"ssbd",         0x00000007,  0, CPUID_REG_EDX, 31,  1},
 
+        {"avx512-bf16",  0x00000007,  1, CPUID_REG_EAX,  5,  1},
+
         {"lahfsahf",     0x80000001, NA, CPUID_REG_ECX,  0,  1},
         {"cmplegacy",    0x80000001, NA, CPUID_REG_ECX,  1,  1},
         {"svm",          0x80000001, NA, CPUID_REG_ECX,  2,  1},
index 9d93eeed24e0b662ab43e6f565c34925d5cfcfd4..b0db0525a9d001d472917a80e1bf62e745ca9291 100644 (file)
@@ -164,6 +164,11 @@ static const char *const str_7d0[32] =
     /* 30 */                [31] = "ssbd",
 };
 
+static const char *const str_7a1[32] =
+{
+    /* 4 */                 [ 5] = "avx512_bf16",
+};
+
 static const struct {
     const char *name;
     const char *abbr;
@@ -180,6 +185,7 @@ static const struct {
     { "0x80000007.edx",   "e7d", str_e7d },
     { "0x80000008.ebx",   "e8b", str_e8b },
     { "0x00000007:0.edx", "7d0", str_7d0 },
+    { "0x00000007:1.eax", "7a1", str_7a1 },
 };
 
 #define COL_ALIGN "18"
index 43cfdc81557b609af3d6cc34dea262e749ea930d..33f5d3255793488bd176a77f18fba590ca713e5f 100644 (file)
@@ -391,11 +391,17 @@ static void generic_identify(struct cpuinfo_x86 *c)
                        = cpuid_ebx(0x80000008);
 
        /* Intel-defined flags: level 0x00000007 */
-       if ( c->cpuid_level >= 0x00000007 )
-               cpuid_count(0x00000007, 0, &tmp,
+       if ( c->cpuid_level >= 0x00000007 ) {
+               cpuid_count(0x00000007, 0, &eax,
                            &c->x86_capability[cpufeat_word(X86_FEATURE_FSGSBASE)],
                            &c->x86_capability[cpufeat_word(X86_FEATURE_PKU)],
                            &c->x86_capability[cpufeat_word(X86_FEATURE_AVX512_4VNNIW)]);
+               if (eax > 0)
+                       cpuid_count(0x00000007, 1,
+                                   &c->x86_capability[cpufeat_word(X86_FEATURE_AVX512_BF16)],
+                                   &tmp, &tmp, &tmp);
+       }
+
        if (c->cpuid_level >= 0xd)
                cpuid_count(0xd, 1,
                            &c->x86_capability[cpufeat_word(X86_FEATURE_XSAVEOPT)],
index e4651b4434447705e4a29b201b3758424c1060f9..54ff82146d29596ed3a2ed772ead86353b1a4444 100644 (file)
@@ -250,6 +250,9 @@ XEN_CPUFEATURE(L1D_FLUSH,     9*32+28) /*S  MSR_FLUSH_CMD and L1D flush. */
 XEN_CPUFEATURE(ARCH_CAPS,     9*32+29) /*   IA32_ARCH_CAPABILITIES MSR */
 XEN_CPUFEATURE(SSBD,          9*32+31) /*A  MSR_SPEC_CTRL.SSBD available */
 
+/* Intel-defined CPU features, CPUID level 0x00000007:1.eax, word 10 */
+XEN_CPUFEATURE(AVX512_BF16,  10*32+ 5) /*   AVX512 BFloat16 Instructions */
+
 #endif /* XEN_CPUFEATURE */
 
 /* Clean up from a default include.  Close the enum (for C). */
index 022757f99579a804445c8db6db4a14d8a7f2b8a6..252d2c978d958c6354519400f827e95430be4f95 100644 (file)
@@ -14,6 +14,7 @@
 #define FEATURESET_e7d    7 /* 0x80000007.edx      */
 #define FEATURESET_e8b    8 /* 0x80000008.ebx      */
 #define FEATURESET_7d0    9 /* 0x00000007:0.edx    */
+#define FEATURESET_7a1   10 /* 0x00000007:1.eax    */
 
 struct cpuid_leaf
 {
@@ -79,7 +80,7 @@ const char *x86_cpuid_vendor_to_str(unsigned int vendor);
 
 #define CPUID_GUEST_NR_BASIC      (0xdu + 1)
 #define CPUID_GUEST_NR_CACHE      (5u + 1)
-#define CPUID_GUEST_NR_FEAT       (0u + 1)
+#define CPUID_GUEST_NR_FEAT       (1u + 1)
 #define CPUID_GUEST_NR_TOPO       (1u + 1)
 #define CPUID_GUEST_NR_XSTATE     (62u + 1)
 #define CPUID_GUEST_NR_EXTD_INTEL (0x8u + 1)
@@ -177,6 +178,13 @@ struct cpuid_policy
                 struct { DECL_BITFIELD(7d0); };
             };
         };
+        struct {
+            /* Subleaf 1. */
+            union {
+                uint32_t _7a1;
+                struct { DECL_BITFIELD(7a1); };
+            };
+        };
     } feat;
 
     /* Extended topology enumeration: 0x0000000B[xx] */
@@ -280,6 +288,7 @@ static inline void cpuid_policy_to_featureset(
     fs[FEATURESET_e7d] = p->extd.e7d;
     fs[FEATURESET_e8b] = p->extd.e8b;
     fs[FEATURESET_7d0] = p->feat._7d0;
+    fs[FEATURESET_7a1] = p->feat._7a1;
 }
 
 /* Fill in a CPUID policy from a featureset bitmap. */
@@ -296,6 +305,7 @@ static inline void cpuid_featureset_to_policy(
     p->extd.e7d   = fs[FEATURESET_e7d];
     p->extd.e8b   = fs[FEATURESET_e8b];
     p->feat._7d0  = fs[FEATURESET_7d0];
+    p->feat._7a1  = fs[FEATURESET_7a1];
 }
 
 const uint32_t *x86_cpuid_lookup_deep_deps(uint32_t feature);
index 67ec54b18379551412d8ed62371a66367c59e0d0..8f6b977df0ef617863fd26285d9e5b27d91f035b 100755 (executable)
@@ -270,7 +270,7 @@ def crunch_numbers(state):
         # AVX512 extensions acting solely on vectors of bytes/words are made
         # dependents of AVX512BW (as to requiring wider than 16-bit mask
         # registers), despite the SDM not formally making this connection.
-        AVX512BW: [AVX512_VBMI],
+        AVX512BW: [AVX512_BF16, AVX512_VBMI],
 
         # The features:
         #   * Single Thread Indirect Branch Predictors