aboutsummaryrefslogtreecommitdiff
path: root/include/qemu/cpuid.h
blob: 1451e8ef2fe7f38fac9fc13dc82ee4eb92f9190a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* cpuid.h: Macros to identify the properties of an x86 host.
 *
 * This work is licensed under the terms of the GNU GPL, version 2 or later.
 * See the COPYING file in the top-level directory.
 */

#ifndef QEMU_CPUID_H
#define QEMU_CPUID_H

#ifndef CONFIG_CPUID_H
# error "<cpuid.h> is unusable with this compiler"
#endif

#include <cpuid.h>

/* Cover the uses that we have within qemu.  */
/* ??? Irritating that we have the same information in target/i386/.  */

/* Leaf 1, %edx */
#ifndef bit_CMOV
#define bit_CMOV        (1 << 15)
#endif
#ifndef bit_SSE2
#define bit_SSE2        (1 << 26)
#endif

/* Leaf 1, %ecx */
#ifndef bit_SSE4_1
#define bit_SSE4_1      (1 << 19)
#endif
#ifndef bit_MOVBE
#define bit_MOVBE       (1 << 22)
#endif
#ifndef bit_OSXSAVE
#define bit_OSXSAVE     (1 << 27)
#endif
#ifndef bit_AVX
#define bit_AVX         (1 << 28)
#endif

/* Leaf 7, %ebx */
#ifndef bit_BMI
#define bit_BMI         (1 << 3)
#endif
#ifndef bit_AVX2
#define bit_AVX2        (1 << 5)
#endif
#ifndef bit_BMI2
#define bit_BMI2        (1 << 8)
#endif
#ifndef bit_AVX512F
#define bit_AVX512F     (1 << 16)
#endif
#ifndef bit_AVX512DQ
#define bit_AVX512DQ    (1 << 17)
#endif
#ifndef bit_AVX512BW
#define bit_AVX512BW    (1 << 30)
#endif
#ifndef bit_AVX512VL
#define bit_AVX512VL    (1u << 31)
#endif

/* Leaf 7, %ecx */
#ifndef bit_AVX512VBMI2
#define bit_AVX512VBMI2 (1 << 6)
#endif

/* Leaf 0x80000001, %ecx */
#ifndef bit_LZCNT
#define bit_LZCNT       (1 << 5)
#endif

static inline unsigned xgetbv_low(unsigned c)
{
    unsigned a, d;
    asm("xgetbv" : "=a"(a), "=d"(d) : "c"(c));
    return a;
}

#endif /* QEMU_CPUID_H */