Skip to content

Commit 2d3b0ba

Browse files
ChangSeokBaegregkh
authored andcommitted
x86/pkeys: Simplify PKRU update in signal frame
commit d1e4207 upstream. The signal delivery logic was modified to always set the PKRU bit in xregs_state->header->xfeatures by this commit: ae6012d ("x86/pkeys: Ensure updated PKRU value is XRSTOR'd") However, the change derives the bitmask value using XGETBV(1), rather than simply updating the buffer that already holds the value. Thus, this approach induces an unnecessary dependency on XGETBV1 for PKRU handling. Eliminate the dependency by using the established helper function. Subsequently, remove the now-unused 'mask' argument. Signed-off-by: Chang S. Bae <chang.seok.bae@intel.com> Signed-off-by: Ingo Molnar <mingo@kernel.org> Cc: Andy Lutomirski <luto@kernel.org> Cc: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Oleg Nesterov <oleg@redhat.com> Cc: Tony W Wang-oc <TonyWWang-oc@zhaoxin.com> Cc: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/r/20250416021720.12305-9-chang.seok.bae@intel.com Cc: Ben Hutchings <ben@decadent.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 124dece commit 2d3b0ba

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

arch/x86/kernel/fpu/xstate.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,15 @@ static inline int set_xfeature_in_sigframe(struct xregs_state __user *xbuf, u64
8585
/*
8686
* Update the value of PKRU register that was already pushed onto the signal frame.
8787
*/
88-
static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u64 mask, u32 pkru)
88+
static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru)
8989
{
90-
u64 xstate_bv;
9190
int err;
9291

9392
if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE)))
9493
return 0;
9594

9695
/* Mark PKRU as in-use so that it is restored correctly. */
97-
xstate_bv = (mask & xfeatures_in_use()) | XFEATURE_MASK_PKRU;
98-
99-
err = __put_user(xstate_bv, &buf->header.xfeatures);
96+
err = set_xfeature_in_sigframe(buf, XFEATURE_MASK_PKRU);
10097
if (err)
10198
return err;
10299

@@ -320,7 +317,7 @@ static inline int xsave_to_user_sigframe(struct xregs_state __user *buf, u32 pkr
320317
clac();
321318

322319
if (!err)
323-
err = update_pkru_in_sigframe(buf, mask, pkru);
320+
err = update_pkru_in_sigframe(buf, pkru);
324321

325322
return err;
326323
}

0 commit comments

Comments
 (0)