From: Paolo Bonzini <pbonzini@redhat.com>
To: Leonardo Bras <leobras@redhat.com>,
Sean Christopherson <seanjc@google.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
Dave Hansen <dave.hansen@linux.intel.com>,
x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
"Chang S. Bae" <chang.seok.bae@intel.com>,
Andy Lutomirski <luto@kernel.org>,
David Gilbert <dgilbert@redhat.com>, Peter Xu <peterx@redhat.com>
Cc: kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 0/2] x86/kvm/fpu: Fix guest migration bugs that can crash guest
Date: Thu, 17 Feb 2022 15:52:28 +0100 [thread overview]
Message-ID: <087309d0-f39c-d5d0-2b6a-2dd8595b06ea@redhat.com> (raw)
In-Reply-To: <20220217053028.96432-1-leobras@redhat.com>
On 2/17/22 06:30, Leonardo Bras wrote:
> This patchset comes from a bug I found during qemu guest migration from a
> host with newer CPU to a host with an older version of this CPU, and thus
> having less FPU features.
>
> When the guests were created, the one with less features is used as
> config, so migration is possible.
>
> Patch 1 fix a bug that always happens during this migration, and is
> related to the fact that xsave saves all feature flags, but xrstor does
> not touch the PKRU flag. It also changes how fpstate->user_xfeatures
> is set, going from kvm_check_cpuid() to the later called
> kvm_vcpu_after_set_cpuid().
>
> Patch 2 removes kvm_vcpu_arch.guest_supported_xcr0 since it now
> duplicates guest_fpu.fpstate->user_xfeatures. Some wrappers were
> introduced in order to make it easier to read the replaced version.
>
> Patches were compile-tested, and could fix the bug found.
Queued, thanks (for 5.17 of course)! For patch 2, I renamed the
function to kvm_guest_supported_xcr0.
Paolo
> Please let me know of anything to improve!
>
> Best regards,
> Leo
>
> --
> Changes since v3:
> - Add new patch to remove the use of kvm_vcpu_arch.guest_supported_xcr0,
> since it is now duplicating guest_fpu.fpstate->user_xfeatures.
> - On patch 1, also avoid setting user_xfeatures on kvm_check_cpuid(),
> since it is already set in kvm_vcpu_after_set_cpuid() now.
> Changes since v2:
> - Fix building error because I forgot to EXPORT_SYMBOL(fpu_user_cfg)
> Changes since v1:
> - Instead of masking xfeatures, mask user_xfeatures instead. This will
> only change the value sent to user, instead of the one saved in buf.
> - Above change removed the need of the patch 2/2
> - Instead of masking the current value of user_xfeatures, save on it
> fpu_user_cfg.default_features & vcpu->arch.guest_supported_xcr0
>
> Leonardo Bras (2):
> x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0
> x86/kvm/fpu: Remove kvm_vcpu_arch.guest_supported_xcr0
>
> arch/x86/include/asm/kvm_host.h | 1 -
> arch/x86/kernel/fpu/xstate.c | 5 ++++-
> arch/x86/kvm/cpuid.c | 5 ++++-
> arch/x86/kvm/x86.c | 20 +++++++++++++++-----
> 4 files changed, 23 insertions(+), 8 deletions(-)
>
next prev parent reply other threads:[~2022-02-17 14:52 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-17 5:30 [PATCH v4 0/2] x86/kvm/fpu: Fix guest migration bugs that can crash guest Leonardo Bras
2022-02-17 5:30 ` [PATCH v4 1/2] x86/kvm/fpu: Mask guest fpstate->xfeatures with guest_supported_xcr0 Leonardo Bras
2022-02-17 12:07 ` David Edmondson
2022-02-17 15:07 ` Paolo Bonzini
2022-02-17 5:30 ` [PATCH v4 2/2] x86/kvm/fpu: Remove kvm_vcpu_arch.guest_supported_xcr0 Leonardo Bras
2022-02-17 12:03 ` David Edmondson
2022-02-17 14:52 ` Paolo Bonzini [this message]
2022-02-17 18:08 ` [PATCH v4 0/2] x86/kvm/fpu: Fix guest migration bugs that can crash guest Leonardo Bras Soares Passos
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=087309d0-f39c-d5d0-2b6a-2dd8595b06ea@redhat.com \
--to=pbonzini@redhat.com \
--cc=bp@alien8.de \
--cc=chang.seok.bae@intel.com \
--cc=dave.hansen@linux.intel.com \
--cc=dgilbert@redhat.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=leobras@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=peterx@redhat.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
--cc=x86@kernel.org \
/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).