| 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_PCLMUL |
| 29 | #define bit_PCLMUL (1 << 1) |
| 30 | #endif |
| 31 | #ifndef bit_SSE4_1 |
| 32 | #define bit_SSE4_1 (1 << 19) |
| 33 | #endif |
| 34 | #ifndef bit_MOVBE |
| 35 | #define bit_MOVBE (1 << 22) |
| 36 | #endif |
| 37 | #ifndef bit_OSXSAVE |
| 38 | #define bit_OSXSAVE (1 << 27) |
| 39 | #endif |
| 40 | #ifndef bit_AVX |
| 41 | #define bit_AVX (1 << 28) |
| 42 | #endif |
| 43 | |
| 44 | /* Leaf 7, %ebx */ |
| 45 | #ifndef bit_BMI |
| 46 | #define bit_BMI (1 << 3) |
| 47 | #endif |
| 48 | #ifndef bit_AVX2 |
| 49 | #define bit_AVX2 (1 << 5) |
| 50 | #endif |
| 51 | #ifndef bit_BMI2 |
| 52 | #define bit_BMI2 (1 << 8) |
| 53 | #endif |
| 54 | #ifndef bit_AVX512F |
| 55 | #define bit_AVX512F (1 << 16) |
| 56 | #endif |
| 57 | #ifndef bit_AVX512DQ |
| 58 | #define bit_AVX512DQ (1 << 17) |
| 59 | #endif |
| 60 | #ifndef bit_AVX512BW |
| 61 | #define bit_AVX512BW (1 << 30) |
| 62 | #endif |
| 63 | #ifndef bit_AVX512VL |
| 64 | #define bit_AVX512VL (1u << 31) |
| 65 | #endif |
| 66 | |
| 67 | /* Leaf 7, %ecx */ |
| 68 | #ifndef bit_AVX512VBMI2 |
| 69 | #define bit_AVX512VBMI2 (1 << 6) |
| 70 | #endif |
| 71 | #ifndef bit_GFNI |
| 72 | #define bit_GFNI (1 << 8) |
| 73 | #endif |
| 74 | |
| 75 | /* Leaf 0x80000001, %ecx */ |
| 76 | #ifndef bit_LZCNT |
| 77 | #define bit_LZCNT (1 << 5) |
| 78 | #endif |
| 79 | |
| 80 | /* |
| 81 | * Signatures for different CPU implementations as returned from Leaf 0. |
| 82 | */ |
| 83 | |
| 84 | #ifndef signature_INTEL_ecx |
| 85 | /* "Genu" "ineI" "ntel" */ |
| 86 | #define signature_INTEL_ebx 0x756e6547 |
| 87 | #define signature_INTEL_edx 0x49656e69 |
| 88 | #define signature_INTEL_ecx 0x6c65746e |
| 89 | #endif |
| 90 | |
| 91 | #ifndef signature_AMD_ecx |
| 92 | /* "Auth" "enti" "cAMD" */ |
| 93 | #define signature_AMD_ebx 0x68747541 |
| 94 | #define signature_AMD_edx 0x69746e65 |
| 95 | #define signature_AMD_ecx 0x444d4163 |
| 96 | #endif |
| 97 | |
| 98 | static inline unsigned xgetbv_low(unsigned c) |
| 99 | { |
| 100 | unsigned a, d; |
| 101 | asm("xgetbv" : "=a"(a), "=d"(d) : "c"(c)); |
| 102 | return a; |
| 103 | } |
| 104 | |
| 105 | #endif /* QEMU_CPUID_H */ |