From: Thomas Gleixner <tglx@linutronix.de>
To: Paolo Bonzini <pbonzini@redhat.com>, LKML <linux-kernel@vger.kernel.org>
Cc: Jing Liu <jing2.liu@linux.intel.com>,
Yang Zhong <yang.zhong@intel.com>,
x86@kernel.org, kvm@vger.kernel.org,
Sean Christoperson <seanjc@google.com>,
Jin Nakajima <jun.nakajima@intel.com>,
Kevin Tian <kevin.tian@intel.com>
Subject: Re: [patch 0/6] x86/fpu: Preparatory changes for guest AMX support
Date: Tue, 14 Dec 2021 14:24:51 +0100 [thread overview]
Message-ID: <877dc7tj30.ffs@tglx> (raw)
In-Reply-To: <09e06d62-33f5-b41f-e913-a8c5e43ba881@redhat.com>
On Tue, Dec 14 2021 at 11:42, Paolo Bonzini wrote:
> On 12/14/21 03:50, Thomas Gleixner wrote:
>> The only remaining issue is the KVM XSTATE save/restore size checking which
>> probably requires some FPU core assistance. But that requires some more
>> thoughts vs. the IOCTL interface extension and once that is settled it
>> needs to be solved in one go. But that's an orthogonal issue to the above.
>
> That's not a big deal because KVM uses the uncompacted format. So
> KVM_CHECK_EXTENSION and KVM_GET_XSAVE can just use CPUID to retrieve the
> size and uncompacted offset of the largest bit that is set in
> kvm_supported_xcr0, while KVM_SET_XSAVE can do the same with the largest
> bit that is set in the xstate_bv.
For simplicity you can just get that information from guest_fpu. See
below.
Thanks,
tglx
---
--- a/arch/x86/include/asm/fpu/types.h
+++ b/arch/x86/include/asm/fpu/types.h
@@ -518,6 +518,11 @@ struct fpu_guest {
u64 perm;
/*
+ * @uabi_size: Size required for save/restore
+ */
+ unsigned int uabi_size;
+
+ /*
* @fpstate: Pointer to the allocated guest fpstate
*/
struct fpstate *fpstate;
--- a/arch/x86/kernel/fpu/core.c
+++ b/arch/x86/kernel/fpu/core.c
@@ -240,6 +240,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_
gfpu->fpstate = fpstate;
gfpu->xfeatures = fpu_user_cfg.default_features;
gfpu->perm = fpu_user_cfg.default_features;
+ gfpu->uabi_size = fpu_user_cfg.default_size;
fpu_init_guest_permissions(gfpu);
return true;
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -1545,6 +1545,7 @@ static int fpstate_realloc(u64 xfeatures
newfps->is_confidential = curfps->is_confidential;
newfps->in_use = curfps->in_use;
guest_fpu->xfeatures |= xfeatures;
+ guest_fpu->uabi_size = usize;
}
fpregs_lock();
prev parent reply other threads:[~2021-12-14 13:24 UTC|newest]
Thread overview: 47+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-12-14 2:50 [patch 0/6] x86/fpu: Preparatory changes for guest AMX support Thomas Gleixner
2021-12-14 2:50 ` [patch 1/6] x86/fpu: Extend fpu_xstate_prctl() with guest permissions Thomas Gleixner
2021-12-14 5:13 ` Tian, Kevin
2021-12-14 10:37 ` Paolo Bonzini
2021-12-14 2:50 ` [patch 2/6] x86/fpu: Prepare guest FPU for dynamically enabled FPU features Thomas Gleixner
2021-12-14 2:50 ` [patch 3/6] x86/fpu: Make XFD initialization in __fpstate_reset() a function argument Thomas Gleixner
2021-12-14 2:50 ` [patch 4/6] x86/fpu: Add guest support to xfd_enable_feature() Thomas Gleixner
2021-12-14 6:05 ` Tian, Kevin
2021-12-14 10:21 ` Paolo Bonzini
2021-12-14 13:15 ` Thomas Gleixner
2021-12-15 5:46 ` Tian, Kevin
2021-12-15 9:53 ` Thomas Gleixner
2021-12-15 10:02 ` Tian, Kevin
2021-12-14 2:50 ` [patch 5/6] x86/fpu: Provide fpu_update_guest_xcr0/xfd() Thomas Gleixner
2021-12-14 6:25 ` Tian, Kevin
2021-12-14 15:09 ` Wang, Wei W
2021-12-14 15:40 ` Thomas Gleixner
2021-12-14 16:11 ` Wang, Wei W
2021-12-14 18:04 ` Thomas Gleixner
2021-12-14 19:07 ` Juan Quintela
2021-12-14 20:28 ` Thomas Gleixner
2021-12-14 21:35 ` Juan Quintela
2021-12-15 2:17 ` Wang, Wei W
2021-12-15 10:09 ` Thomas Gleixner
2021-12-15 10:27 ` Paolo Bonzini
2021-12-15 10:41 ` Paolo Bonzini
2021-12-16 1:00 ` Tian, Kevin
2021-12-16 5:36 ` Tian, Kevin
2021-12-16 21:07 ` Paolo Bonzini
2021-12-16 10:21 ` Tian, Kevin
2021-12-16 10:24 ` Paolo Bonzini
2021-12-16 10:26 ` Paolo Bonzini
2021-12-16 13:00 ` Tian, Kevin
2021-12-16 1:04 ` Tian, Kevin
2021-12-16 9:34 ` Thomas Gleixner
2021-12-16 9:59 ` Tian, Kevin
2021-12-16 14:12 ` Thomas Gleixner
2021-12-17 15:33 ` Tian, Kevin
2021-12-15 6:14 ` Tian, Kevin
2021-12-14 2:50 ` [patch 6/6] x86/fpu: Provide kvm_sync_guest_vmexit_xfd_state() Thomas Gleixner
2021-12-15 6:35 ` Liu, Jing2
2021-12-15 9:49 ` Thomas Gleixner
2021-12-14 6:50 ` [patch 0/6] x86/fpu: Preparatory changes for guest AMX support Tian, Kevin
2021-12-14 6:52 ` Liu, Jing2
2021-12-14 7:54 ` Tian, Kevin
2021-12-14 10:42 ` Paolo Bonzini
2021-12-14 13:24 ` Thomas Gleixner [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=877dc7tj30.ffs@tglx \
--to=tglx@linutronix.de \
--cc=jing2.liu@linux.intel.com \
--cc=jun.nakajima@intel.com \
--cc=kevin.tian@intel.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=x86@kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox