[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <877dc7tj30.ffs@tglx>
Date: Tue, 14 Dec 2021 14:24:51 +0100
From: Thomas Gleixner <tglx@...utronix.de>
To: Paolo Bonzini <pbonzini@...hat.com>,
LKML <linux-kernel@...r.kernel.org>
Cc: Jing Liu <jing2.liu@...ux.intel.com>,
Yang Zhong <yang.zhong@...el.com>, x86@...nel.org,
kvm@...r.kernel.org, Sean Christoperson <seanjc@...gle.com>,
Jin Nakajima <jun.nakajima@...el.com>,
Kevin Tian <kevin.tian@...el.com>
Subject: Re: [patch 0/6] x86/fpu: Preparatory changes for guest AMX support
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();
Powered by blists - more mailing lists