From: Dave Hansen <dave.hansen@linux.intel.com>
To: linux-mm@kvack.org
Cc: linux-kernel@vger.kernel.org,Dave Hansen
<dave.hansen@linux.intel.com>,tglx@linutronix.de,mingo@redhat.com,bp@alien8.de,x86@kernel.org,luto@kernel.org
Subject: [RFC][PATCH 0/8] x86/pkeys: remove PKRU from kernel XSAVE buffer
Date: Tue, 22 Jun 2021 15:24:55 -0700 [thread overview]
Message-ID: <20210622222455.E901B5AC@viggo.jf.intel.com> (raw)
This is a rework of the kernel's Protection Keys Register code. It severs
the connection between PKRU and XSAVE as thoroughly as possible without
affecting the existing ABIs.
This compiles in a few configurations and passes the pkeys selftest, but
that's about it. It's not been pummeled enough yet for merging anywhere.
This is on top of the current:
git://git.kernel.org/pub/scm/linux/kernel/git/tglx/devel.git x86/fpu
specifically:
3d168301c78d ("x86/fpu/signal: Let xrstor handle the features to init")
--
PKRU is currently a strange beast. It can be XSAVE-managed and it has
space allocated in the thread 'fpstate' buffer. However, it is
switched more eagerly than other FPU state because PKRU affects things
like copy_to/from_user(). This is because PKRU affects user *PERMISSION*
accesses, not just accesses made from user *MODE* itself.
This leaves PKRU in a very odd position. It is stored in the kernel
XSAVE buffer but the XSAVE architecture is not used to manage it.
Move PKRU out of the 'fpstate' buffer. Instead, allocate space in the
thread_struct for it and save/restore it in the context-switch path
separately from the XSAVE-managed features. This removes the ambiguity
of having PKRU state in two places for each task.
include/asm/fpu/internal.h | 2 -
include/asm/fpu/xstate.h | 2 -
include/asm/pkru.h | 10 +++--
kernel/cpu/common.c | 19 +++++++++-
kernel/fpu/core.c | 8 ++--
kernel/fpu/signal.c | 12 +++++-
kernel/fpu/xstate.c | 83 ++++++++++++++++++++++++++++++---------------
kernel/process_64.c | 9 ++--
kernel/signal.c | 1
kvm/x86.c | 8 ++--
mm/pkeys.c | 21 ++---------
11 files changed, 113 insertions(+), 62 deletions(-)
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>
next reply other threads:[~2021-06-22 22:25 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 22:24 Dave Hansen [this message]
2021-06-22 22:24 ` [RFC][PATCH 1/8] x86/pkeys: add PKRU storage outside of task " Dave Hansen
2021-06-22 22:24 ` [RFC][PATCH 2/8] x86/fpu: hook up PKRU into signal user ABIs Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 3/8] x86/fpu: separate the setup of xfeatures not in fpstate Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 4/8] x86/fpu: remove PKRU from FPU user state clearing Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 5/8] x86/fpu: XSAVE buffer access routine rename Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 6/8] x86/fpu: update xstate size calculations for non-XSAVE-managed features Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 7/8] x86/fpu: actually stop using XSAVE on PKRU Dave Hansen
2021-06-22 22:25 ` [RFC][PATCH 8/8] x86/pkeys: remove init_pkru_value variable Dave Hansen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210622222455.E901B5AC@viggo.jf.intel.com \
--to=dave.hansen@linux.intel.com \
--cc=bp@alien8.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=luto@kernel.org \
--cc=mingo@redhat.com \
--cc=tglx@linutronix.de \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox