Re: [patch V3 17/66] x86/fpu: Make copy_xstate_to_kernel() usable for [x]fpregs_get()

From: Borislav Petkov
Date: Mon Jun 21 2021 - 08:32:33 EST


On Fri, Jun 18, 2021 at 04:18:40PM +0200, Thomas Gleixner wrote:
> 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@xxxxxxxxxxxxx>
> ---
> V3: Rename to copy_xstate_to_uabi_buf() - Boris
> V2: New patch
> ---
> arch/x86/include/asm/fpu/xstate.h | 12 +++++++++-
> arch/x86/kernel/fpu/regset.c | 2 -
> arch/x86/kernel/fpu/xstate.c | 42 ++++++++++++++++++++++++++++----------
> 3 files changed, 42 insertions(+), 14 deletions(-)

Reviewed-by: Borislav Petkov <bp@xxxxxxx>

--
Regards/Gruss,
Boris.

SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg