Re: [patch V3 51/66] x86/fpu: Dont restore PKRU in fpregs_restore_userspace()

From: Borislav Petkov
Date: Tue Jun 22 2021 - 12:08:17 EST


On Fri, Jun 18, 2021 at 04:19:14PM +0200, Thomas Gleixner wrote:
> switch_to(), flush_thread() write the task's PKRU value eagerly so the PKRU
> value of current is always valid in the hardware.
>
> That means there is no point in restoring PKRU on exit to user or when
> reactivating the task's FPU registers in the signal frame setup path.
>
> This allows to remove all the xstate buffer updates with PKRU values once
> the PKRU state is stored in thread struct while a task is scheduled out.
>
> Signed-off-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
> ---
> V3: Restore supervisor state too. (Yu-Cheng)
> ---
> arch/x86/include/asm/fpu/internal.h | 16 +++++++++++++++-
> arch/x86/include/asm/fpu/xstate.h | 19 +++++++++++++++++++
> arch/x86/kernel/fpu/core.c | 2 +-
> 3 files changed, 35 insertions(+), 2 deletions(-)

Reviewed-by: Borislav Petkov <bp@xxxxxxx>

--
Regards/Gruss,
Boris.

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