2011-11-23 14:30:32 +00:00
|
|
|
#ifndef ARCH_X86_KVM_CPUID_H
|
|
|
|
#define ARCH_X86_KVM_CPUID_H
|
|
|
|
|
|
|
|
#include "x86.h"
|
|
|
|
|
2014-09-16 12:10:03 +00:00
|
|
|
int kvm_update_cpuid(struct kvm_vcpu *vcpu);
|
2011-11-23 14:30:32 +00:00
|
|
|
struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
|
|
|
|
u32 function, u32 index);
|
2013-09-22 14:44:50 +00:00
|
|
|
int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid,
|
|
|
|
struct kvm_cpuid_entry2 __user *entries,
|
|
|
|
unsigned int type);
|
2011-11-23 14:30:32 +00:00
|
|
|
int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_cpuid *cpuid,
|
|
|
|
struct kvm_cpuid_entry __user *entries);
|
|
|
|
int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_cpuid2 *cpuid,
|
|
|
|
struct kvm_cpuid_entry2 __user *entries);
|
|
|
|
int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
|
|
|
|
struct kvm_cpuid2 *cpuid,
|
|
|
|
struct kvm_cpuid_entry2 __user *entries);
|
2012-06-07 11:07:48 +00:00
|
|
|
void kvm_cpuid(struct kvm_vcpu *vcpu, u32 *eax, u32 *ebx, u32 *ecx, u32 *edx);
|
2011-11-23 14:30:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
2012-11-06 18:24:07 +00:00
|
|
|
if (!static_cpu_has(X86_FEATURE_XSAVE))
|
|
|
|
return 0;
|
|
|
|
|
2011-11-23 14:30:32 +00:00
|
|
|
best = kvm_find_cpuid_entry(vcpu, 1, 0);
|
|
|
|
return best && (best->ecx & bit(X86_FEATURE_XSAVE));
|
|
|
|
}
|
|
|
|
|
2012-11-29 20:42:50 +00:00
|
|
|
static inline bool guest_cpuid_has_tsc_adjust(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 7, 0);
|
|
|
|
return best && (best->ebx & bit(X86_FEATURE_TSC_ADJUST));
|
|
|
|
}
|
|
|
|
|
2011-11-23 14:30:32 +00:00
|
|
|
static inline bool guest_cpuid_has_smep(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 7, 0);
|
|
|
|
return best && (best->ebx & bit(X86_FEATURE_SMEP));
|
|
|
|
}
|
|
|
|
|
2014-04-01 09:46:34 +00:00
|
|
|
static inline bool guest_cpuid_has_smap(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 7, 0);
|
|
|
|
return best && (best->ebx & bit(X86_FEATURE_SMAP));
|
|
|
|
}
|
|
|
|
|
2011-11-23 14:30:32 +00:00
|
|
|
static inline bool guest_cpuid_has_fsgsbase(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 7, 0);
|
|
|
|
return best && (best->ebx & bit(X86_FEATURE_FSGSBASE));
|
|
|
|
}
|
|
|
|
|
2012-01-09 19:00:35 +00:00
|
|
|
static inline bool guest_cpuid_has_osvw(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 0x80000001, 0);
|
|
|
|
return best && (best->ecx & bit(X86_FEATURE_OSVW));
|
|
|
|
}
|
|
|
|
|
2012-07-02 01:18:48 +00:00
|
|
|
static inline bool guest_cpuid_has_pcid(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 1, 0);
|
|
|
|
return best && (best->ecx & bit(X86_FEATURE_PCID));
|
|
|
|
}
|
|
|
|
|
2014-01-24 15:48:44 +00:00
|
|
|
static inline bool guest_cpuid_has_x2apic(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 1, 0);
|
|
|
|
return best && (best->ecx & bit(X86_FEATURE_X2APIC));
|
|
|
|
}
|
|
|
|
|
2014-09-02 11:24:12 +00:00
|
|
|
static inline bool guest_cpuid_is_amd(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 0, 0);
|
|
|
|
return best && best->ebx == X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx;
|
|
|
|
}
|
|
|
|
|
2014-05-07 12:32:50 +00:00
|
|
|
static inline bool guest_cpuid_has_gbpages(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 0x80000001, 0);
|
|
|
|
return best && (best->edx & bit(X86_FEATURE_GBPAGES));
|
|
|
|
}
|
2014-07-15 14:37:46 +00:00
|
|
|
|
|
|
|
static inline bool guest_cpuid_has_rtm(struct kvm_vcpu *vcpu)
|
|
|
|
{
|
|
|
|
struct kvm_cpuid_entry2 *best;
|
|
|
|
|
|
|
|
best = kvm_find_cpuid_entry(vcpu, 7, 0);
|
|
|
|
return best && (best->ebx & bit(X86_FEATURE_RTM));
|
|
|
|
}
|
2011-11-23 14:30:32 +00:00
|
|
|
#endif
|