All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Daniel P. Berrangé" <berrange@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>
Cc: Yang Zhong <yang.zhong@intel.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] KVM: x86: workaround invalid CPUID[0xD,9] info on some AMD processors
Date: Wed, 23 Mar 2022 11:51:22 +0000	[thread overview]
Message-ID: <YjsJuuGPMMFvuz+6@redhat.com> (raw)
In-Reply-To: <20220323114315.22594-1-pbonzini@redhat.com>

On Wed, Mar 23, 2022 at 12:43:15PM +0100, Paolo Bonzini wrote:
> Some AMD processors expose the PKRU extended save state even if they do not have
> the related PKU feature in CPUID.  Worse, when they do they report a size of
> 64, whereas the expected size of the PKRU extended save state is 8, therefore
> the esa->size == eax assertion does not hold.
> 
> The state is already ignored by KVM_GET_SUPPORTED_CPUID because it
> was not enabled in the host XCR0.  However, QEMU kvm_cpu_xsave_init()
> runs before QEMU invokes arch_prctl() to enable dynamically-enabled
> save states such as XTILEDATA, and KVM_GET_SUPPORTED_CPUID hides save
> states that have yet to be enabled.  Therefore, kvm_cpu_xsave_init()
> needs to consult the host CPUID instead of KVM_GET_SUPPORTED_CPUID,
> and dies with an assertion failure.
> 
> When setting up the ExtSaveArea array to match the host, ignore features that
> KVM does not report as supported.  This will cause QEMU to skip the incorrect
> CPUID leaf instead of tripping the assertion.

  Closes: https://gitlab.com/qemu-project/qemu/-/issues/916

> 
> Reported-by: Daniel P. Berrangé <berrange@redhat.com>

Also credit

  Reported-by: Peter Krempa <pkrempa@redhat.com>

> Analyzed-by: Yang Zhong <yang.zhong@intel.com>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  target/i386/cpu.c         |  4 ++--
>  target/i386/cpu.h         |  2 ++
>  target/i386/kvm/kvm-cpu.c | 19 ++++++++++++-------
>  3 files changed, 16 insertions(+), 9 deletions(-)

  Tested-by: Daniel P. Berrangé <berrange@redhat.com>

no longer crashes on the AMD machine I have to hand.


With regards,
Daniel
-- 
|: https://berrange.com      -o-    https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org         -o-            https://fstop138.berrange.com :|
|: https://entangle-photo.org    -o-    https://www.instagram.com/dberrange :|



  reply	other threads:[~2022-03-23 12:49 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-23 11:43 [PATCH] KVM: x86: workaround invalid CPUID[0xD, 9] info on some AMD processors Paolo Bonzini
2022-03-23 11:51 ` Daniel P. Berrangé [this message]
2022-03-23 13:36 ` [PATCH] KVM: x86: workaround invalid CPUID[0xD,9] " Yang Zhong
2022-03-23 14:41 ` [PATCH] KVM: x86: workaround invalid CPUID[0xD, 9] " Peter Krempa

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=YjsJuuGPMMFvuz+6@redhat.com \
    --to=berrange@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yang.zhong@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.