xref: /qemu/include/qemu/cpuid.h (revision 78f314cf)
1 /* cpuid.h: Macros to identify the properties of an x86 host.
2  *
3  * This work is licensed under the terms of the GNU GPL, version 2 or later.
4  * See the COPYING file in the top-level directory.
5  */
6 
7 #ifndef QEMU_CPUID_H
8 #define QEMU_CPUID_H
9 
10 #ifndef CONFIG_CPUID_H
11 # error "<cpuid.h> is unusable with this compiler"
12 #endif
13 
14 #include <cpuid.h>
15 
16 /* Cover the uses that we have within qemu.  */
17 /* ??? Irritating that we have the same information in target/i386/.  */
18 
19 /* Leaf 1, %edx */
20 #ifndef bit_CMOV
21 #define bit_CMOV        (1 << 15)
22 #endif
23 #ifndef bit_SSE2
24 #define bit_SSE2        (1 << 26)
25 #endif
26 
27 /* Leaf 1, %ecx */
28 #ifndef bit_SSE4_1
29 #define bit_SSE4_1      (1 << 19)
30 #endif
31 #ifndef bit_MOVBE
32 #define bit_MOVBE       (1 << 22)
33 #endif
34 #ifndef bit_OSXSAVE
35 #define bit_OSXSAVE     (1 << 27)
36 #endif
37 #ifndef bit_AVX
38 #define bit_AVX         (1 << 28)
39 #endif
40 
41 /* Leaf 7, %ebx */
42 #ifndef bit_BMI
43 #define bit_BMI         (1 << 3)
44 #endif
45 #ifndef bit_AVX2
46 #define bit_AVX2        (1 << 5)
47 #endif
48 #ifndef bit_BMI2
49 #define bit_BMI2        (1 << 8)
50 #endif
51 #ifndef bit_AVX512F
52 #define bit_AVX512F     (1 << 16)
53 #endif
54 #ifndef bit_AVX512DQ
55 #define bit_AVX512DQ    (1 << 17)
56 #endif
57 #ifndef bit_AVX512BW
58 #define bit_AVX512BW    (1 << 30)
59 #endif
60 #ifndef bit_AVX512VL
61 #define bit_AVX512VL    (1u << 31)
62 #endif
63 
64 /* Leaf 7, %ecx */
65 #ifndef bit_AVX512VBMI2
66 #define bit_AVX512VBMI2 (1 << 6)
67 #endif
68 
69 /* Leaf 0x80000001, %ecx */
70 #ifndef bit_LZCNT
71 #define bit_LZCNT       (1 << 5)
72 #endif
73 
74 /*
75  * Signatures for different CPU implementations as returned from Leaf 0.
76  */
77 
78 #ifndef signature_INTEL_ecx
79 /* "Genu" "ineI" "ntel" */
80 #define signature_INTEL_ebx     0x756e6547
81 #define signature_INTEL_edx     0x49656e69
82 #define signature_INTEL_ecx     0x6c65746e
83 #endif
84 
85 #ifndef signature_AMD_ecx
86 /* "Auth" "enti" "cAMD" */
87 #define signature_AMD_ebx       0x68747541
88 #define signature_AMD_edx       0x69746e65
89 #define signature_AMD_ecx       0x444d4163
90 #endif
91 
92 static inline unsigned xgetbv_low(unsigned c)
93 {
94     unsigned a, d;
95     asm("xgetbv" : "=a"(a), "=d"(d) : "c"(c));
96     return a;
97 }
98 
99 #endif /* QEMU_CPUID_H */
100