1 #include "kvm/kvm-cpu.h"
10 #define CPUID_FUNC_PERFMON 0x0A
12 #define MAX_KVM_CPUID_ENTRIES 100
14 static void filter_cpuid(struct kvm_cpuid2
*kvm_cpuid
)
19 * Filter CPUID functions that are not supported by the hypervisor.
21 for (i
= 0; i
< kvm_cpuid
->nent
; i
++) {
22 struct kvm_cpuid_entry2
*entry
= &kvm_cpuid
->entries
[i
];
24 switch (entry
->function
) {
25 case CPUID_FUNC_PERFMON
:
26 entry
->eax
= 0x00; /* disable it */
29 /* Keep the CPUID function as -is */
35 void kvm_cpu__setup_cpuid(struct kvm_cpu
*vcpu
)
37 struct kvm_cpuid2
*kvm_cpuid
;
39 kvm_cpuid
= calloc(1, sizeof(*kvm_cpuid
) + MAX_KVM_CPUID_ENTRIES
* sizeof(*kvm_cpuid
->entries
));
41 kvm_cpuid
->nent
= MAX_KVM_CPUID_ENTRIES
;
42 if (ioctl(vcpu
->kvm
->sys_fd
, KVM_GET_SUPPORTED_CPUID
, kvm_cpuid
) < 0)
43 die_perror("KVM_GET_SUPPORTED_CPUID failed");
45 filter_cpuid(kvm_cpuid
);
47 if (ioctl(vcpu
->vcpu_fd
, KVM_SET_CPUID2
, kvm_cpuid
) < 0)
48 die_perror("KVM_SET_CPUID2 failed");