Skip to content

Commit 6a1853b

Browse files
arunarhansendc
authored andcommitted
x86/pkeys: Change caller of update_pkru_in_sigframe()
update_pkru_in_sigframe() will shortly need some information which is only available inside xsave_to_user_sigframe(). Move update_pkru_in_sigframe() inside the other function to make it easier to provide it that information. No functional changes. Signed-off-by: Aruna Ramakrishna <aruna.ramakrishna@oracle.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/all/20241119174520.3987538-2-aruna.ramakrishna%40oracle.com
1 parent 40384c8 commit 6a1853b

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

arch/x86/kernel/fpu/signal.c

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -63,16 +63,6 @@ static inline bool check_xstate_in_sigframe(struct fxregs_state __user *fxbuf,
6363
return true;
6464
}
6565

66-
/*
67-
* Update the value of PKRU register that was already pushed onto the signal frame.
68-
*/
69-
static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru)
70-
{
71-
if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE)))
72-
return 0;
73-
return __put_user(pkru, (unsigned int __user *)get_xsave_addr_user(buf, XFEATURE_PKRU));
74-
}
75-
7666
/*
7767
* Signal frame handlers.
7868
*/
@@ -168,14 +158,8 @@ static inline bool save_xstate_epilog(void __user *buf, int ia32_frame,
168158

169159
static inline int copy_fpregs_to_sigframe(struct xregs_state __user *buf, u32 pkru)
170160
{
171-
int err = 0;
172-
173-
if (use_xsave()) {
174-
err = xsave_to_user_sigframe(buf);
175-
if (!err)
176-
err = update_pkru_in_sigframe(buf, pkru);
177-
return err;
178-
}
161+
if (use_xsave())
162+
return xsave_to_user_sigframe(buf, pkru);
179163

180164
if (use_fxsr())
181165
return fxsave_to_user_sigframe((struct fxregs_state __user *) buf);

arch/x86/kernel/fpu/xstate.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ static inline u64 xfeatures_mask_independent(void)
6969
return fpu_kernel_cfg.independent_features;
7070
}
7171

72+
/*
73+
* Update the value of PKRU register that was already pushed onto the signal frame.
74+
*/
75+
static inline int update_pkru_in_sigframe(struct xregs_state __user *buf, u32 pkru)
76+
{
77+
if (unlikely(!cpu_feature_enabled(X86_FEATURE_OSPKE)))
78+
return 0;
79+
return __put_user(pkru, (unsigned int __user *)get_xsave_addr_user(buf, XFEATURE_PKRU));
80+
}
81+
7282
/* XSAVE/XRSTOR wrapper functions */
7383

7484
#ifdef CONFIG_X86_64
@@ -256,7 +266,7 @@ static inline u64 xfeatures_need_sigframe_write(void)
256266
* The caller has to zero buf::header before calling this because XSAVE*
257267
* does not touch the reserved fields in the header.
258268
*/
259-
static inline int xsave_to_user_sigframe(struct xregs_state __user *buf)
269+
static inline int xsave_to_user_sigframe(struct xregs_state __user *buf, u32 pkru)
260270
{
261271
/*
262272
* Include the features which are not xsaved/rstored by the kernel
@@ -281,6 +291,9 @@ static inline int xsave_to_user_sigframe(struct xregs_state __user *buf)
281291
XSTATE_OP(XSAVE, buf, lmask, hmask, err);
282292
clac();
283293

294+
if (!err)
295+
err = update_pkru_in_sigframe(buf, pkru);
296+
284297
return err;
285298
}
286299

0 commit comments

Comments
 (0)