From: "Chang S. Bae" <chang.seok.bae@intel.com>
To: linux-kernel@vger.kernel.org
Cc: x86@kernel.org, tglx@linutronix.de, mingo@redhat.com,
bp@alien8.de, dave.hansen@linux.intel.com,
aruna.ramakrishna@oracle.com, TonyWWang-oc@zhaoxin.com,
chang.seok.bae@intel.com
Subject: [PATCH 2/2] x86/pkeys: Simplify PKRU update in signal frame
Date: Thu, 13 Feb 2025 17:06:07 -0800 [thread overview]
Message-ID: <20250214010607.7067-3-chang.seok.bae@intel.com> (raw)
In-Reply-To: <20250214010607.7067-1-chang.seok.bae@intel.com>
Commit ae6012d72fa6 ("x86/pkeys: Ensure updated PKRU value is XRSTOR'd")
modified the signal delivery logic to always set the PKRU bit in
xregs_state->header->xfeatures.
The change currently derives the bitmask value using XGETBV(1), rather
than reading the already written value directly from the buffer. Thus,
this approach induces an unnecessary dependency on XGETBV1 for the PKRU
feature.
Eliminate the dependency by using the established helper function.
Subsequently, remove the unused mask argument from
update_pkru_in_sigframe().
Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com>
Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com>
Cc: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com>
---
arch/x86/kernel/fpu/xstate.h | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/arch/x86/kernel/fpu/xstate.h b/arch/x86/kernel/fpu/xstate.h
index 27e20236bbbb..f3fc3369a135 100644
--- a/arch/x86/kernel/fpu/xstate.h
+++ b/arch/x86/kernel/fpu/xstate.h
@@ -84,18 +84,15 @@ static inline int set_xfeature_in_sigframe(struct xregs_state __user *xbuf, u64
/*
* Update the value of PKRU register that was already pushed onto the signal frame.
*/
-static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 mask, u32 pkru)
+static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru)
{
- u64 xstate_bv;
int err;
if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE)))
return 0;
/* Mark PKRU as in-use so that it is restored correctly. */
- xstate_bv = (mask & xfeatures_in_use()) | XFEATURE_MASK_PKRU;
-
- err = __put_user(xstate_bv, &buf->header.xfeatures);
+ err = set_xfeature_in_sigframe(buf, XFEATURE_MASK_PKRU);
if (err)
return err;
@@ -316,7 +313,7 @@ static inline int xsave_to_user_sigframe(struct xregs_state __user *buf, u32 pkr
clac();
if (!err)
- err = update_pkru_in_sigframe(buf, mask, pkru);
+ err = update_pkru_in_sigframe(buf, pkru);
return err;
}
--
2.45.2
prev parent reply other threads:[~2025-02-14 1:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-14 1:06 [PATCH 0/2] x86/pkeys: Remove unnecessary XGETBV1 dependency in signal frame exposition Chang S. Bae
2025-02-14 1:06 ` [PATCH 1/2] x86/fpu: Refactor xfeature bitmask update code for sigframe XSAVE Chang S. Bae
2025-02-14 1:06 ` Chang S. Bae [this message]
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=20250214010607.7067-3-chang.seok.bae@intel.com \
--to=chang.seok.bae@intel.com \
--cc=TonyWWang-oc@zhaoxin.com \
--cc=aruna.ramakrishna@oracle.com \
--cc=bp@alien8.de \
--cc=dave.hansen@linux.intel.com \
--cc=linux-kernel@vger.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
all inboxes | Powered by JetHome®