[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20210622222459.9C76B034@viggo.jf.intel.com>
Date: Tue, 22 Jun 2021 15:24:59 -0700
From: Dave Hansen <dave.hansen@...ux.intel.com>
To: linux-mm@...ck.org
Cc: linux-kernel@...r.kernel.org,
Dave Hansen <dave.hansen@...ux.intel.com>, tglx@...utronix.de,
mingo@...hat.com, bp@...en8.de, x86@...nel.org, luto@...nel.org
Subject: [RFC][PATCH 2/8] x86/fpu: hook up PKRU into signal user ABIs
From: Dave Hansen <dave.hansen@...ux.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@...ux.intel.com>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...hat.com>
Cc: Borislav Petkov <bp@...en8.de>
Cc: x86@...nel.org
Cc: Andy Lutomirski <luto@...nel.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);
_
Powered by blists - more mailing lists