mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-11 03:24:58 -06:00

The call to xgetbv() is passing the ecx value for cpuid function 0xD, index 0. The xgetbv call thus returns false (OSXSAVE is bit 27, which is well out of the range of CPUID[0xD,0].ECX) and eax is not modified. While fixing it, cache the whole computation of supported XCR0 bits since it will be used for more than just CPUID leaf 0xD. Furthermore, unsupported subleafs of CPUID 0xD (including all those corresponding to zero bits in host's XCR0) must be hidden; if OSXSAVE is not set at all, the whole of CPUID leaf 0xD plus the XSAVE bit must be hidden. Finally, unconditionally drop XSTATE_BNDREGS_MASK and XSTATE_BNDCSR_MASK; real hardware will only show them if the MPX bit is set in CPUID; this is never the case for hvf_get_supported_cpuid() because QEMU's Hypervisor.framework support does not handle the VMX fields related to MPX (even in the unlikely possibility that the host has MPX enabled). So hide those bits in the new cache_host_xcr0(). Cc: Phil Dennis-Jordan <lists@philjordan.eu> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
40 lines
1.3 KiB
C
40 lines
1.3 KiB
C
/*
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
* Host specific cpu identification for x86.
|
|
*/
|
|
|
|
#ifndef HOST_CPUINFO_H
|
|
#define HOST_CPUINFO_H
|
|
|
|
/* Digested version of <cpuid.h> */
|
|
|
|
#define CPUINFO_ALWAYS (1u << 0) /* so cpuinfo is nonzero */
|
|
#define CPUINFO_OSXSAVE (1u << 1)
|
|
#define CPUINFO_MOVBE (1u << 2)
|
|
#define CPUINFO_LZCNT (1u << 3)
|
|
#define CPUINFO_POPCNT (1u << 4)
|
|
#define CPUINFO_BMI1 (1u << 5)
|
|
#define CPUINFO_BMI2 (1u << 6)
|
|
#define CPUINFO_SSE2 (1u << 7)
|
|
#define CPUINFO_AVX1 (1u << 9)
|
|
#define CPUINFO_AVX2 (1u << 10)
|
|
#define CPUINFO_AVX512F (1u << 11)
|
|
#define CPUINFO_AVX512VL (1u << 12)
|
|
#define CPUINFO_AVX512BW (1u << 13)
|
|
#define CPUINFO_AVX512DQ (1u << 14)
|
|
#define CPUINFO_AVX512VBMI2 (1u << 15)
|
|
#define CPUINFO_ATOMIC_VMOVDQA (1u << 16)
|
|
#define CPUINFO_ATOMIC_VMOVDQU (1u << 17)
|
|
#define CPUINFO_AES (1u << 18)
|
|
#define CPUINFO_PCLMUL (1u << 19)
|
|
|
|
/* Initialized with a constructor. */
|
|
extern unsigned cpuinfo;
|
|
|
|
/*
|
|
* We cannot rely on constructor ordering, so other constructors must
|
|
* use the function interface rather than the variable above.
|
|
*/
|
|
unsigned cpuinfo_init(void);
|
|
|
|
#endif /* HOST_CPUINFO_H */
|