1d8457847SCyrill Gorcunov #ifndef KVM__CPUFEATURE_H 2d8457847SCyrill Gorcunov #define KVM__CPUFEATURE_H 3d8457847SCyrill Gorcunov 444677817SCyrill Gorcunov #define CPUID_VENDOR_INTEL_1 0x756e6547 /* "Genu" */ 544677817SCyrill Gorcunov #define CPUID_VENDOR_INTEL_2 0x49656e69 /* "ineI" */ 644677817SCyrill Gorcunov #define CPUID_VENDOR_INTEL_3 0x6c65746e /* "ntel" */ 744677817SCyrill Gorcunov 844677817SCyrill Gorcunov #define CPUID_VENDOR_AMD_1 0x68747541 /* "Auth" */ 944677817SCyrill Gorcunov #define CPUID_VENDOR_AMD_2 0x69746e65 /* "enti" */ 1044677817SCyrill Gorcunov #define CPUID_VENDOR_AMD_3 0x444d4163 /* "cAMD" */ 1144677817SCyrill Gorcunov 12d8457847SCyrill Gorcunov /* 13d8457847SCyrill Gorcunov * CPUID flags we need to deal with 14d8457847SCyrill Gorcunov */ 15d8457847SCyrill Gorcunov #define KVM__X86_FEATURE_VMX 5 /* Hardware virtualization */ 16d8457847SCyrill Gorcunov #define KVM__X86_FEATURE_XSAVE 26 /* XSAVE/XRSTOR/XSETBV/XGETBV */ 17d8457847SCyrill Gorcunov 18d8457847SCyrill Gorcunov #define cpu_feature_disable(reg, feature) \ 19d8457847SCyrill Gorcunov ((reg) & ~(1 << (feature))) 20d8457847SCyrill Gorcunov #define cpu_feature_enable(reg, feature) \ 21d8457847SCyrill Gorcunov ((reg) | (1 << (feature))) 22d8457847SCyrill Gorcunov 23*c78b8713SAsias He struct cpuid_regs { 24*c78b8713SAsias He uint32_t eax; 25*c78b8713SAsias He uint32_t ebx; 26*c78b8713SAsias He uint32_t ecx; 27*c78b8713SAsias He uint32_t edx; 28*c78b8713SAsias He }; 29*c78b8713SAsias He 30*c78b8713SAsias He static inline void host_cpuid(struct cpuid_regs *regs) 31*c78b8713SAsias He { 32*c78b8713SAsias He asm volatile("cpuid" 33*c78b8713SAsias He : "=a" (regs->eax), 34*c78b8713SAsias He "=b" (regs->ebx), 35*c78b8713SAsias He "=c" (regs->ecx), 36*c78b8713SAsias He "=d" (regs->edx) 37*c78b8713SAsias He : "0" (regs->eax), "2" (regs->ecx)); 38*c78b8713SAsias He } 39*c78b8713SAsias He 40d8457847SCyrill Gorcunov #endif /* KVM__CPUFEATURE_H */ 41