lkml.org 
[lkml]   [2021]   [Jun]   [22]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[RFC][PATCH 2/8] x86/fpu: hook up PKRU into signal user ABIs
From
Date

From: Dave Hansen <dave.hansen@linux.intel.com>

One nice thing about having PKRU be XSAVE-managed is that it gets naturally
exposed into the XSAVE-using ABIs. Now that XSAVE will not be used to
manage PKRU, these ABIs need to be manually enabled to deal with PKRU.

For signals (the restore_hwregs_from_user() path), it's quite
straightforward. restore_hwregs_from_user() will update PKRU in from
the user signal buffer. Ensure that PKRU is shuffled into the thread
storage.

Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: x86@kernel.org
Cc: Andy Lutomirski <luto@kernel.org>
---

b/arch/x86/kernel/fpu/signal.c | 7 +++++++
1 file changed, 7 insertions(+)

diff -puN arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru arch/x86/kernel/fpu/signal.c
--- a/arch/x86/kernel/fpu/signal.c~fpu-sig-stash-pkru 2021-06-22 14:49:07.899051760 -0700
+++ b/arch/x86/kernel/fpu/signal.c 2021-06-22 14:49:07.903051760 -0700
@@ -233,6 +233,13 @@ static int restore_hwregs_from_user(void

if (!ret && unlikely(init_bv))
os_xrstor(&init_fpstate.xsave, init_bv);
+
+ /*
+ * PKRU may have been modified by XRSTOR,
+ * save the possibly updated value:
+ */
+ current->thread.pkru = read_pkru();
+
return ret;
} else if (use_fxsr()) {
return fxrstor_from_user_sigframe(buf);
_
\
 
 \ /
  Last update: 2021-06-23 00:26    [W:0.055 / U:0.100 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site