[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 17/18] i386: Omit all-zeroes entries from KVM CPUID table
From: |
Eduardo Habkost |
Subject: |
[PULL 17/18] i386: Omit all-zeroes entries from KVM CPUID table |
Date: |
Tue, 15 Oct 2019 18:37:44 -0300 |
KVM has a 80-entry limit at KVM_SET_CPUID2. With the
introduction of CPUID[0x1F], it is now possible to hit this limit
with unusual CPU configurations, e.g.:
$ ./x86_64-softmmu/qemu-system-x86_64 \
-smp 1,dies=2,maxcpus=2 \
-cpu EPYC,check=off,enforce=off \
-machine accel=kvm
qemu-system-x86_64: kvm_init_vcpu failed: Argument list too long
This happens because QEMU adds a lot of all-zeroes CPUID entries
for unused CPUID leaves. In the example above, we end up
creating 48 all-zeroes CPUID entries.
KVM already returns all-zeroes when emulating the CPUID
instruction if an entry is missing, so the all-zeroes entries are
redundant. Skip those entries. This reduces the CPUID table
size by half while keeping CPUID output unchanged.
Reported-by: Yumei Huang <address@hidden>
Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1741508
Signed-off-by: Eduardo Habkost <address@hidden>
Message-Id: <address@hidden>
Acked-by: Paolo Bonzini <address@hidden>
Signed-off-by: Eduardo Habkost <address@hidden>
---
target/i386/kvm.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/target/i386/kvm.c b/target/i386/kvm.c
index 11b9c854b5..8c73438c67 100644
--- a/target/i386/kvm.c
+++ b/target/i386/kvm.c
@@ -1567,6 +1567,13 @@ int kvm_arch_init_vcpu(CPUState *cs)
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+ if (!c->eax && !c->ebx && !c->ecx && !c->edx) {
+ /*
+ * KVM already returns all zeroes if a CPUID entry is missing,
+ * so we can omit it and avoid hitting KVM's 80-entry limit.
+ */
+ cpuid_i--;
+ }
break;
}
}
@@ -1631,6 +1638,13 @@ int kvm_arch_init_vcpu(CPUState *cs)
c->function = i;
c->flags = 0;
cpu_x86_cpuid(env, i, 0, &c->eax, &c->ebx, &c->ecx, &c->edx);
+ if (!c->eax && !c->ebx && !c->ecx && !c->edx) {
+ /*
+ * KVM already returns all zeroes if a CPUID entry is missing,
+ * so we can omit it and avoid hitting KVM's 80-entry limit.
+ */
+ cpuid_i--;
+ }
break;
}
}
--
2.21.0
- [PULL 07/18] hw/ide/sii3112: Convert reset handler to DeviceReset, (continued)
- [PULL 07/18] hw/ide/sii3112: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 08/18] hw/ide/via82c: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 09/18] hw/isa/vt82c686: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 10/18] hw/input/lm832x: Convert reset handler to DeviceReset, Eduardo Habkost, 2019/10/15
- [PULL 11/18] hw/misc/vmcoreinfo: Add comment about reset handler, Eduardo Habkost, 2019/10/15
- [PULL 12/18] memory-device: not necessary to use goto for the last check, Eduardo Habkost, 2019/10/15
- [PULL 13/18] memory-device: break the loop if tmp exceed the hinted range, Eduardo Habkost, 2019/10/15
- [PULL 14/18] target/i386: clean up comments over 80 chars per line, Eduardo Habkost, 2019/10/15
- [PULL 15/18] target/i386: drop the duplicated definition of cpuid AVX512_VBMI macro, Eduardo Habkost, 2019/10/15
- [PULL 16/18] i386: Fix legacy guest with xsave panic on host kvm without update cpuid., Eduardo Habkost, 2019/10/15
- [PULL 17/18] i386: Omit all-zeroes entries from KVM CPUID table,
Eduardo Habkost <=
- [PULL 18/18] target/i386: Add Snowridge-v2 (no MPX) CPU model, Eduardo Habkost, 2019/10/15
- Re: [PULL 00/18] x86 and machine queue, 2019-10-15, Peter Maydell, 2019/10/18