[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YNIV5Wk7E1LNhekk@zn.tnic>
Date: Tue, 22 Jun 2021 18:55:01 +0200
From: Borislav Petkov <bp@...e.de>
To: Thomas Gleixner <tglx@...utronix.de>
Cc: LKML <linux-kernel@...r.kernel.org>,
Andy Lutomirski <luto@...nel.org>,
Dave Hansen <dave.hansen@...ux.intel.com>,
Fenghua Yu <fenghua.yu@...el.com>,
Tony Luck <tony.luck@...el.com>,
Yu-cheng Yu <yu-cheng.yu@...el.com>,
Sebastian Andrzej Siewior <bigeasy@...utronix.de>,
Peter Zijlstra <peterz@...radead.org>,
Kan Liang <kan.liang@...ux.intel.com>
Subject: Re: [patch V3 52/66] x86/fpu: Add PKRU storage outside of task XSAVE
buffer
On Fri, Jun 18, 2021 at 04:19:15PM +0200, Thomas Gleixner wrote:
> From: Dave Hansen <dave.hansen@...ux.intel.com>
>
> PKRU is currently partly XSAVE-managed and partly not. It has space in the
> task XSAVE buffer and is context-switched by XSAVE/XRSTOR. However, it is
> switched more eagerly than FPU because there may be a need for PKRU to be
> up-to-date for things like copy_to/from_user() since PKRU affects
> user-permission memory accesses, not just accesses from userspace itself.
>
> This leaves PKRU in a very odd position. XSAVE brings very little value to
> the table for how Linux uses PKRU except for signal related XSTATE
> handling.
>
> Prepare to move PKRU away from being XSAVE-managed. Allocate space in the
> thread_struct for it and save/restore it in the context-switch path
> separately from the XSAVE-managed features. task->thread_struct.pkru is
> only valid when the task is scheduled out. For the current task the
> authoritative source is the hardware, i.e. it has to be retrieved via
> rdpkru().
>
> Leave the XSAVE code in place for now to ensure bisectability.
>
> Signed-off-by: Dave Hansen <dave.hansen@...ux.intel.com>
> Signed-off-by: Thomas Gleixner <tglx@...utronix.de>
> ---
> V3: Fix the fallout on !PKRU enabled systems in copy_thread() - Intel testing via Dave
> ---
> arch/x86/include/asm/processor.h | 9 +++++++++
> arch/x86/kernel/process.c | 7 +++++++
> arch/x86/kernel/process_64.c | 25 +++++++++++++++++++++++++
> 3 files changed, 41 insertions(+)
Reviewed-by: Borislav Petkov <bp@...e.de>
--
Regards/Gruss,
Boris.
SUSE Software Solutions Germany GmbH, GF: Felix Imendörffer, HRB 36809, AG Nürnberg
Powered by blists - more mailing lists