x86/fpu: Make copy_xstate_to_kernel() usable for [x]fpregs_get()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 23 Jun 2021 12:01:42 +0000 (14:01 +0200)
committerBorislav Petkov <bp@suse.de>
Wed, 23 Jun 2021 15:49:47 +0000 (17:49 +0200)
commiteb6f51723f03c9a1c098ed196a31a03e626b9fb6
tree868eeed8377fe03e732162a4cc2c71d0b3807d4f
parentda53f60bb86e60830932926cf1093953a811912c
x86/fpu: Make copy_xstate_to_kernel() usable for [x]fpregs_get()

When xsave with init state optimization is used then a component's state
in the task's xsave buffer can be stale when the corresponding feature bit
is not set.

fpregs_get() and xfpregs_get() invoke fpstate_sanitize_xstate() to update
the task's xsave buffer before retrieving the FX or FP state. That's just
duplicated code as copy_xstate_to_kernel() already handles this correctly.

Add a copy mode argument to the function which allows to restrict the state
copy to the FP and SSE features.

Also rename the function to copy_xstate_to_uabi_buf() so the name reflects
what it is doing.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Reviewed-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20210623121452.805327286@linutronix.de
arch/x86/include/asm/fpu/xstate.h
arch/x86/kernel/fpu/regset.c
arch/x86/kernel/fpu/xstate.c