1 #ifndef ARCH_X86_KVM_CPUID_H
2 #define ARCH_X86_KVM_CPUID_H
6 void kvm_update_cpuid(struct kvm_vcpu
*vcpu
);
7 struct kvm_cpuid_entry2
*kvm_find_cpuid_entry(struct kvm_vcpu
*vcpu
,
8 u32 function
, u32 index
);
9 int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2
*cpuid
,
10 struct kvm_cpuid_entry2 __user
*entries
,
12 int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu
*vcpu
,
13 struct kvm_cpuid
*cpuid
,
14 struct kvm_cpuid_entry __user
*entries
);
15 int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu
*vcpu
,
16 struct kvm_cpuid2
*cpuid
,
17 struct kvm_cpuid_entry2 __user
*entries
);
18 int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu
*vcpu
,
19 struct kvm_cpuid2
*cpuid
,
20 struct kvm_cpuid_entry2 __user
*entries
);
21 void kvm_cpuid(struct kvm_vcpu
*vcpu
, u32
*eax
, u32
*ebx
, u32
*ecx
, u32
*edx
);
24 static inline bool guest_cpuid_has_xsave(struct kvm_vcpu
*vcpu
)
26 struct kvm_cpuid_entry2
*best
;
28 if (!static_cpu_has(X86_FEATURE_XSAVE
))
31 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
32 return best
&& (best
->ecx
& bit(X86_FEATURE_XSAVE
));
35 static inline bool guest_cpuid_has_tsc_adjust(struct kvm_vcpu
*vcpu
)
37 struct kvm_cpuid_entry2
*best
;
39 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
40 return best
&& (best
->ebx
& bit(X86_FEATURE_TSC_ADJUST
));
43 static inline bool guest_cpuid_has_smep(struct kvm_vcpu
*vcpu
)
45 struct kvm_cpuid_entry2
*best
;
47 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
48 return best
&& (best
->ebx
& bit(X86_FEATURE_SMEP
));
51 static inline bool guest_cpuid_has_fsgsbase(struct kvm_vcpu
*vcpu
)
53 struct kvm_cpuid_entry2
*best
;
55 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
56 return best
&& (best
->ebx
& bit(X86_FEATURE_FSGSBASE
));
59 static inline bool guest_cpuid_has_osvw(struct kvm_vcpu
*vcpu
)
61 struct kvm_cpuid_entry2
*best
;
63 best
= kvm_find_cpuid_entry(vcpu
, 0x80000001, 0);
64 return best
&& (best
->ecx
& bit(X86_FEATURE_OSVW
));
67 static inline bool guest_cpuid_has_pcid(struct kvm_vcpu
*vcpu
)
69 struct kvm_cpuid_entry2
*best
;
71 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
72 return best
&& (best
->ecx
& bit(X86_FEATURE_PCID
));
75 static inline bool guest_cpuid_has_x2apic(struct kvm_vcpu
*vcpu
)
77 struct kvm_cpuid_entry2
*best
;
79 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
80 return best
&& (best
->ecx
& bit(X86_FEATURE_X2APIC
));