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 */ 16*ae87afbfSCyrill Gorcunov #define KVM__X86_FEATURE_SVM 2 /* Secure virtual machine */ 17d8457847SCyrill Gorcunov #define KVM__X86_FEATURE_XSAVE 26 /* XSAVE/XRSTOR/XSETBV/XGETBV */ 18d8457847SCyrill Gorcunov 19d8457847SCyrill Gorcunov #define cpu_feature_disable(reg, feature) \ 20d8457847SCyrill Gorcunov ((reg) & ~(1 << (feature))) 21d8457847SCyrill Gorcunov #define cpu_feature_enable(reg, feature) \ 22d8457847SCyrill Gorcunov ((reg) | (1 << (feature))) 23d8457847SCyrill Gorcunov 24c78b8713SAsias He struct cpuid_regs { 25c78b8713SAsias He uint32_t eax; 26c78b8713SAsias He uint32_t ebx; 27c78b8713SAsias He uint32_t ecx; 28c78b8713SAsias He uint32_t edx; 29c78b8713SAsias He }; 30c78b8713SAsias He 31c78b8713SAsias He static inline void host_cpuid(struct cpuid_regs *regs) 32c78b8713SAsias He { 33c78b8713SAsias He asm volatile("cpuid" 34c78b8713SAsias He : "=a" (regs->eax), 35c78b8713SAsias He "=b" (regs->ebx), 36c78b8713SAsias He "=c" (regs->ecx), 37c78b8713SAsias He "=d" (regs->edx) 38c78b8713SAsias He : "0" (regs->eax), "2" (regs->ecx)); 39c78b8713SAsias He } 40c78b8713SAsias He 41d8457847SCyrill Gorcunov #endif /* KVM__CPUFEATURE_H */ 42