cpuid.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef ARCH_X86_KVM_CPUID_H
  2. #define ARCH_X86_KVM_CPUID_H
  3. #include "x86.h"
  4. void kvm_update_cpuid(struct kvm_vcpu *vcpu);
  5. struct kvm_cpuid_entry2 *kvm_find_cpuid_entry(struct kvm_vcpu *vcpu,
  6. u32 function, u32 index);
  7. int kvm_dev_ioctl_get_supported_cpuid(struct kvm_cpuid2 *cpuid,
  8. struct kvm_cpuid_entry2 __user *entries);
  9. int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
  10. struct kvm_cpuid *cpuid,
  11. struct kvm_cpuid_entry __user *entries);
  12. int kvm_vcpu_ioctl_set_cpuid2(struct kvm_vcpu *vcpu,
  13. struct kvm_cpuid2 *cpuid,
  14. struct kvm_cpuid_entry2 __user *entries);
  15. int kvm_vcpu_ioctl_get_cpuid2(struct kvm_vcpu *vcpu,
  16. struct kvm_cpuid2 *cpuid,
  17. struct kvm_cpuid_entry2 __user *entries);
  18. static inline bool guest_cpuid_has_xsave(struct kvm_vcpu *vcpu)
  19. {
  20. struct kvm_cpuid_entry2 *best;
  21. if (!static_cpu_has(X86_FEATURE_XSAVE))
  22. return 0;
  23. best = kvm_find_cpuid_entry(vcpu, 1, 0);
  24. return best && (best->ecx & bit(X86_FEATURE_XSAVE));
  25. }
  26. static inline bool guest_cpuid_has_smep(struct kvm_vcpu *vcpu)
  27. {
  28. struct kvm_cpuid_entry2 *best;
  29. best = kvm_find_cpuid_entry(vcpu, 7, 0);
  30. return best && (best->ebx & bit(X86_FEATURE_SMEP));
  31. }
  32. static inline bool guest_cpuid_has_fsgsbase(struct kvm_vcpu *vcpu)
  33. {
  34. struct kvm_cpuid_entry2 *best;
  35. best = kvm_find_cpuid_entry(vcpu, 7, 0);
  36. return best && (best->ebx & bit(X86_FEATURE_FSGSBASE));
  37. }
  38. static inline bool guest_cpuid_has_osvw(struct kvm_vcpu *vcpu)
  39. {
  40. struct kvm_cpuid_entry2 *best;
  41. best = kvm_find_cpuid_entry(vcpu, 0x80000001, 0);
  42. return best && (best->ecx & bit(X86_FEATURE_OSVW));
  43. }
  44. #endif