aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/arch/x86/kernel/fpu/xstate.c
diff options
context:
space:
mode:
authorThomas Gleixner <tglx@linutronix.de>2021-10-13 16:55:54 +0200
committerBorislav Petkov <bp@suse.de>2021-10-21 14:18:23 +0200
commit3ac8d75778fc8c1c22daad9bc674166b862f6f6e (patch)
tree159abc3000949533bf2fbc26f6c3f425e03ccf64 /arch/x86/kernel/fpu/xstate.c
parentx86/fpu: Use fpstate in fpu_copy_kvm_uabi_to_fpstate() (diff)
downloadwireguard-linux-3ac8d75778fc8c1c22daad9bc674166b862f6f6e.tar.xz
wireguard-linux-3ac8d75778fc8c1c22daad9bc674166b862f6f6e.zip
x86/fpu: Use fpstate in __copy_xstate_to_uabi_buf()
With dynamically enabled features the copy function must know the features and the size which is valid for the task. Retrieve them from fpstate. Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Borislav Petkov <bp@suse.de> Link: https://lkml.kernel.org/r/20211013145323.181495492@linutronix.de
Diffstat (limited to 'arch/x86/kernel/fpu/xstate.c')
-rw-r--r--arch/x86/kernel/fpu/xstate.c11
1 files changed, 6 insertions, 5 deletions
diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c
index 4beb010d19fc..54cc0a4db8e8 100644
--- a/arch/x86/kernel/fpu/xstate.c
+++ b/arch/x86/kernel/fpu/xstate.c
@@ -969,7 +969,7 @@ static void copy_feature(bool from_xstate, struct membuf *to, void *xstate,
/**
* __copy_xstate_to_uabi_buf - Copy kernel saved xstate to a UABI buffer
* @to: membuf descriptor
- * @xsave: The xsave from which to copy
+ * @fpstate: The fpstate buffer from which to copy
* @pkru_val: The PKRU value to store in the PKRU component
* @copy_mode: The requested copy mode
*
@@ -979,11 +979,12 @@ static void copy_feature(bool from_xstate, struct membuf *to, void *xstate,
*
* It supports partial copy but @to.pos always starts from zero.
*/
-void __copy_xstate_to_uabi_buf(struct membuf to, struct xregs_state *xsave,
+void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
u32 pkru_val, enum xstate_copy_mode copy_mode)
{
const unsigned int off_mxcsr = offsetof(struct fxregs_state, mxcsr);
struct xregs_state *xinit = &init_fpstate.regs.xsave;
+ struct xregs_state *xsave = &fpstate->regs.xsave;
struct xstate_header header;
unsigned int zerofrom;
u64 mask;
@@ -1003,7 +1004,7 @@ void __copy_xstate_to_uabi_buf(struct membuf to, struct xregs_state *xsave,
break;
case XSTATE_COPY_XSAVE:
- header.xfeatures &= xfeatures_mask_uabi();
+ header.xfeatures &= fpstate->user_xfeatures;
break;
}
@@ -1046,7 +1047,7 @@ void __copy_xstate_to_uabi_buf(struct membuf to, struct xregs_state *xsave,
* but there is no state to copy from in the compacted
* init_fpstate. The gap tracking will zero these states.
*/
- mask = xfeatures_mask_uabi();
+ mask = fpstate->user_xfeatures;
for_each_extended_xfeature(i, mask) {
/*
@@ -1097,7 +1098,7 @@ out:
void copy_xstate_to_uabi_buf(struct membuf to, struct task_struct *tsk,
enum xstate_copy_mode copy_mode)
{
- __copy_xstate_to_uabi_buf(to, &tsk->thread.fpu.fpstate->regs.xsave,
+ __copy_xstate_to_uabi_buf(to, tsk->thread.fpu.fpstate,
tsk->thread.pkru, copy_mode);
}