]> git.baikalelectronics.ru Git - kernel.git/commitdiff
x86/fpu: Add uabi_size to guest_fpu
authorThomas Gleixner <tglx@linutronix.de>
Wed, 5 Jan 2022 12:35:28 +0000 (04:35 -0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Fri, 14 Jan 2022 18:44:40 +0000 (13:44 -0500)
Userspace needs to inquire KVM about the buffer size to work
with the new KVM_SET_XSAVE and KVM_GET_XSAVE2. Add the size info
to guest_fpu for KVM to access.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Wei Wang <wei.w.wang@intel.com>
Signed-off-by: Jing Liu <jing2.liu@intel.com>
Signed-off-by: Yang Zhong <yang.zhong@intel.com>
Message-Id: <20220105123532.12586-18-yang.zhong@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/asm/fpu/types.h
arch/x86/kernel/fpu/core.c
arch/x86/kernel/fpu/xstate.c

index 3795d0573773e0c4470d63efef587071135ed1bb..eb7cd1139d978f5fb7baddb23cfb779cfe4e86f8 100644 (file)
@@ -522,6 +522,11 @@ struct fpu_guest {
         */
        u64                             xfd_err;
 
+       /*
+        * @uabi_size:                  Size required for save/restore
+        */
+       unsigned int                    uabi_size;
+
        /*
         * @fpstate:                    Pointer to the allocated guest fpstate
         */
index 271fd5bc043b5ce8410d46e5f1bb326355ecb116..de8e8c21f355677e21f933a9d926d82e37cae160 100644 (file)
@@ -240,6 +240,7 @@ bool fpu_alloc_guest_fpstate(struct fpu_guest *gfpu)
        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;
index 0c0b2323cdec538876636b95dfd445021c16ef69..10fe072f1c92a7aeab9dd9817356179ba48abf44 100644 (file)
@@ -1545,6 +1545,7 @@ static int fpstate_realloc(u64 xfeatures, unsigned int ksize,
                newfps->is_confidential = curfps->is_confidential;
                newfps->in_use = curfps->in_use;
                guest_fpu->xfeatures |= xfeatures;
+               guest_fpu->uabi_size = usize;
        }
 
        fpregs_lock();