From: Paolo Bonzini <pbonzini@redhat.com>
To: Eduardo Habkost <ehabkost@redhat.com>, qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, Marcelo Tosatti <mtosatti@redhat.com>,
Igor Mammedov <imammedo@redhat.com>,
Richard Henderson <rth@twiddle.net>,
Yumei Huang <yuhuang@redhat.com>
Subject: Re: [PATCH] i386: Omit all-zeroes entries from KVM CPUID table
Date: Fri, 23 Aug 2019 01:02:41 +0200 [thread overview]
Message-ID: <6e22e468-2f28-efdf-bb77-f4dae3d20f4f@redhat.com> (raw)
In-Reply-To: <20190822225210.32541-1-ehabkost@redhat.com>
On 23/08/19 00:52, Eduardo Habkost wrote:
> 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 <yuhuang@redhat.com>
> Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1741508
> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
> ---
> target/i386/kvm.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> diff --git a/target/i386/kvm.c b/target/i386/kvm.c
> index 8023c679ea..4e3df2867d 100644
> --- a/target/i386/kvm.c
> +++ b/target/i386/kvm.c
> @@ -1529,6 +1529,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;
> }
> }
> @@ -1593,6 +1600,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;
> }
> }
>
prev parent reply other threads:[~2019-08-22 23:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-22 22:52 [PATCH] i386: Omit all-zeroes entries from KVM CPUID table Eduardo Habkost
2019-08-22 23:02 ` Paolo Bonzini [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=6e22e468-2f28-efdf-bb77-f4dae3d20f4f@redhat.com \
--to=pbonzini@redhat.com \
--cc=ehabkost@redhat.com \
--cc=imammedo@redhat.com \
--cc=kvm@vger.kernel.org \
--cc=mtosatti@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=yuhuang@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).