From: Dave Hansen <dave.hansen@intel.com>
To: Sean Christopherson <seanjc@google.com>,
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, Paolo Bonzini <pbonzini@redhat.com>,
Shuah Khan <shuah@kernel.org>,
Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-kernel@vger.kernel.org, kvm@vger.kernel.org,
linux-kselftest@vger.kernel.org, llvm@lists.linux.dev,
Tyler Stachecki <stachecki.tyler@gmail.com>,
Leonardo Bras <leobras@redhat.com>
Subject: Re: [PATCH 2/5] KVM: x86: Constrain guest-supported xfeatures only at KVM_GET_XSAVE{2}
Date: Thu, 28 Sep 2023 07:09:52 -0700 [thread overview]
Message-ID: <b22a3863-cf11-14b7-23f3-4b8971f44580@intel.com> (raw)
In-Reply-To: <20230928001956.924301-3-seanjc@google.com>
On 9/27/23 17:19, Sean Christopherson wrote:
> Mask off xfeatures that aren't exposed to the guest only when saving guest
> state via KVM_GET_XSAVE{2} instead of modifying user_xfeatures directly.
> Preserving the maximal set of xfeatures in user_xfeatures restores KVM's
> ABI for KVM_SET_XSAVE, which prior to commit ad856280ddea ("x86/kvm/fpu:
> Limit guest user_xfeatures to supported bits of XCR0") allowed userspace
> to load xfeatures that are supported by the host, irrespective of what
> xfeatures are exposed to the guest.
>
> There is no known use case where userspace *intentionally* loads xfeatures
> that aren't exposed to the guest, but the bug fixed by commit ad856280ddea
> was specifically that KVM_GET_SAVE{2} would save xfeatures that weren't
> exposed to the guest, e.g. would lead to userspace unintentionally loading
> guest-unsupported xfeatures when live migrating a VM.
>
> Restricting KVM_SET_XSAVE to guest-supported xfeatures is especially
> problematic for QEMU-based setups, as QEMU has a bug where instead of
> terminating the VM if KVM_SET_XSAVE fails, QEMU instead simply stops
> loading guest state, i.e. resumes the guest after live migration with
> incomplete guest state, and ultimately results in guest data corruption.
>
> Note, letting userspace restore all host-supported xfeatures does not fix
> setups where a VM is migrated from a host *without* commit ad856280ddea,
> to a target with a subset of host-supported xfeatures. However there is
> no way to safely address that scenario, e.g. KVM could silently drop the
> unsupported features, but that would be a clear violation of KVM's ABI and
> so would require userspace to opt-in, at which point userspace could
> simply be updated to sanitize the to-be-loaded XSAVE state.
Acked-by: Dave Hansen <dave.hansen@linux.intel.com>
It's surprising (and nice) that this takes eliminates the !guest check
in fpstate_realloc().
next prev parent reply other threads:[~2023-09-28 14:09 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-28 0:19 [PATCH 0/5] KVM: x86: Fix breakage in KVM_SET_XSAVE's ABI Sean Christopherson
2023-09-28 0:19 ` [PATCH 1/5] x86/fpu: Allow caller to constrain xfeatures when copying to uabi buffer Sean Christopherson
2023-09-28 0:19 ` [PATCH 2/5] KVM: x86: Constrain guest-supported xfeatures only at KVM_GET_XSAVE{2} Sean Christopherson
2023-09-28 14:09 ` Dave Hansen [this message]
2023-09-28 0:19 ` [PATCH 3/5] KVM: selftests: Touch relevant XSAVE state in guest for state test Sean Christopherson
2023-09-28 0:19 ` [PATCH 4/5] KVM: selftests: Load XSAVE state into untouched vCPU during " Sean Christopherson
2023-09-28 0:19 ` [PATCH 5/5] KVM: selftests: Force load all supported XSAVE state in " Sean Christopherson
2023-10-04 7:11 ` [PATCH 0/5] KVM: x86: Fix breakage in KVM_SET_XSAVE's ABI Leonardo Bras
2023-10-04 12:21 ` Tyler Stachecki
2023-10-04 14:51 ` Sean Christopherson
2023-10-04 15:29 ` Tyler Stachecki
2023-10-04 16:54 ` Sean Christopherson
2023-10-05 1:29 ` Sean Christopherson
2023-10-12 14:45 ` Paolo Bonzini
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=b22a3863-cf11-14b7-23f3-4b8971f44580@intel.com \
--to=dave.hansen@intel.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=kvm@vger.kernel.org \
--cc=leobras@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mingo@redhat.com \
--cc=nathan@kernel.org \
--cc=ndesaulniers@google.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=shuah@kernel.org \
--cc=stachecki.tyler@gmail.com \
--cc=tglx@linutronix.de \
--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
all inboxes | Powered by JetHome®