Change ports hyperthreading reporting to kvmtool from qemu
It improves speed of kernel compile from 8min to 6min:30sec.
Change-Id: I917d7aa1de29f55b4494639bbefaba7a73b517cc
BUG=None
TEST=kernel compile in VM on hyperthreaded x86 notebook
Reviewed-on: https://chromium-review.googlesource.com/439386
Commit-Ready: Slava Malyugin <slavamn@chromium.org>
Tested-by: Slava Malyugin <slavamn@chromium.org>
Reviewed-by: Dylan Reid <dgreid@chromium.org>
Reviewed-by: Zach Reizner <zachr@chromium.org>
diff --git a/x86/cpuid.c b/x86/cpuid.c
index c3b67d9..d9f4fc3 100644
--- a/x86/cpuid.c
+++ b/x86/cpuid.c
@@ -8,7 +8,7 @@
#define MAX_KVM_CPUID_ENTRIES 100
-static void filter_cpuid(struct kvm_cpuid2 *kvm_cpuid)
+static void filter_cpuid(struct kvm_cpu *vcpu, struct kvm_cpuid2 *kvm_cpuid)
{
unsigned int signature[3];
unsigned int i;
@@ -31,6 +31,11 @@
/* Set X86_FEATURE_HYPERVISOR */
if (entry->index == 0)
entry->ecx |= (1 << 31);
+ entry->ebx = (vcpu->cpu_id << 24) | (8 << 8);
+ if (vcpu->kvm->nrcpus > 1) {
+ entry->ebx |= vcpu->kvm->nrcpus << 16;
+ entry->edx |= (1 << 28);
+ }
break;
case 6:
/* Clear X86_FEATURE_EPB */
@@ -80,7 +85,7 @@
if (ioctl(vcpu->kvm->sys_fd, KVM_GET_SUPPORTED_CPUID, kvm_cpuid) < 0)
die_perror("KVM_GET_SUPPORTED_CPUID failed");
- filter_cpuid(kvm_cpuid);
+ filter_cpuid(vcpu, kvm_cpuid);
if (ioctl(vcpu->vcpu_fd, KVM_SET_CPUID2, kvm_cpuid) < 0)
die_perror("KVM_SET_CPUID2 failed");