1 #ifndef ARCH_X86_KVM_CPUID_H
2 #define ARCH_X86_KVM_CPUID_H
6 int 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
);
23 int cpuid_query_maxphyaddr(struct kvm_vcpu
*vcpu
);
25 static inline int cpuid_maxphyaddr(struct kvm_vcpu
*vcpu
)
27 return vcpu
->arch
.maxphyaddr
;
30 static inline bool guest_cpuid_has_xsave(struct kvm_vcpu
*vcpu
)
32 struct kvm_cpuid_entry2
*best
;
34 if (!static_cpu_has(X86_FEATURE_XSAVE
))
37 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
38 return best
&& (best
->ecx
& bit(X86_FEATURE_XSAVE
));
41 static inline bool guest_cpuid_has_tsc_adjust(struct kvm_vcpu
*vcpu
)
43 struct kvm_cpuid_entry2
*best
;
45 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
46 return best
&& (best
->ebx
& bit(X86_FEATURE_TSC_ADJUST
));
49 static inline bool guest_cpuid_has_smep(struct kvm_vcpu
*vcpu
)
51 struct kvm_cpuid_entry2
*best
;
53 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
54 return best
&& (best
->ebx
& bit(X86_FEATURE_SMEP
));
57 static inline bool guest_cpuid_has_smap(struct kvm_vcpu
*vcpu
)
59 struct kvm_cpuid_entry2
*best
;
61 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
62 return best
&& (best
->ebx
& bit(X86_FEATURE_SMAP
));
65 static inline bool guest_cpuid_has_fsgsbase(struct kvm_vcpu
*vcpu
)
67 struct kvm_cpuid_entry2
*best
;
69 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
70 return best
&& (best
->ebx
& bit(X86_FEATURE_FSGSBASE
));
73 static inline bool guest_cpuid_has_osvw(struct kvm_vcpu
*vcpu
)
75 struct kvm_cpuid_entry2
*best
;
77 best
= kvm_find_cpuid_entry(vcpu
, 0x80000001, 0);
78 return best
&& (best
->ecx
& bit(X86_FEATURE_OSVW
));
81 static inline bool guest_cpuid_has_pcid(struct kvm_vcpu
*vcpu
)
83 struct kvm_cpuid_entry2
*best
;
85 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
86 return best
&& (best
->ecx
& bit(X86_FEATURE_PCID
));
89 static inline bool guest_cpuid_has_x2apic(struct kvm_vcpu
*vcpu
)
91 struct kvm_cpuid_entry2
*best
;
93 best
= kvm_find_cpuid_entry(vcpu
, 1, 0);
94 return best
&& (best
->ecx
& bit(X86_FEATURE_X2APIC
));
97 static inline bool guest_cpuid_is_amd(struct kvm_vcpu
*vcpu
)
99 struct kvm_cpuid_entry2
*best
;
101 best
= kvm_find_cpuid_entry(vcpu
, 0, 0);
102 return best
&& best
->ebx
== X86EMUL_CPUID_VENDOR_AuthenticAMD_ebx
;
105 static inline bool guest_cpuid_has_gbpages(struct kvm_vcpu
*vcpu
)
107 struct kvm_cpuid_entry2
*best
;
109 best
= kvm_find_cpuid_entry(vcpu
, 0x80000001, 0);
110 return best
&& (best
->edx
& bit(X86_FEATURE_GBPAGES
));
113 static inline bool guest_cpuid_has_rtm(struct kvm_vcpu
*vcpu
)
115 struct kvm_cpuid_entry2
*best
;
117 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
118 return best
&& (best
->ebx
& bit(X86_FEATURE_RTM
));
121 static inline bool guest_cpuid_has_mpx(struct kvm_vcpu
*vcpu
)
123 struct kvm_cpuid_entry2
*best
;
125 best
= kvm_find_cpuid_entry(vcpu
, 7, 0);
126 return best
&& (best
->ebx
& bit(X86_FEATURE_MPX
));