Skip to content

Commit 1c813ce

Browse files
khueyhansendc
authored andcommitted
x86/fpu: Add a pkru argument to copy_uabi_from_kernel_to_xstate().
Both KVM (through KVM_SET_XSTATE) and ptrace (through PTRACE_SETREGSET with NT_X86_XSTATE) ultimately call copy_uabi_from_kernel_to_xstate(), but the canonical locations for the current PKRU value for KVM guests and processes in a ptrace stop are different (in the kvm_vcpu_arch and the thread_state structs respectively). In preparation for eventually handling PKRU in copy_uabi_to_xstate, pass in a pointer to the PKRU location. Signed-off-by: Kyle Huey <me@kylehuey.com> Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Link: https://lore.kernel.org/all/20221115230932.7126-3-khuey%40kylehuey.com
1 parent 6a877d2 commit 1c813ce

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

arch/x86/kernel/fpu/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ int fpu_copy_uabi_to_guest_fpstate(struct fpu_guest *gfpu, const void *buf,
406406
if (ustate->xsave.header.xfeatures & ~xcr0)
407407
return -EINVAL;
408408

409-
ret = copy_uabi_from_kernel_to_xstate(kstate, ustate);
409+
ret = copy_uabi_from_kernel_to_xstate(kstate, ustate, vpkru);
410410
if (ret)
411411
return ret;
412412

arch/x86/kernel/fpu/regset.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ int xstateregs_set(struct task_struct *target, const struct user_regset *regset,
167167
}
168168

169169
fpu_force_restore(fpu);
170-
ret = copy_uabi_from_kernel_to_xstate(fpu->fpstate, kbuf ?: tmpbuf);
170+
ret = copy_uabi_from_kernel_to_xstate(fpu->fpstate, kbuf ?: tmpbuf, &target->thread.pkru);
171171

172172
out:
173173
vfree(tmpbuf);

arch/x86/kernel/fpu/xstate.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1268,7 +1268,7 @@ static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf,
12681268
* Convert from a ptrace standard-format kernel buffer to kernel XSAVE[S]
12691269
* format and copy to the target thread. Used by ptrace and KVM.
12701270
*/
1271-
int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf)
1271+
int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf, u32 *pkru)
12721272
{
12731273
return copy_uabi_to_xstate(fpstate, kbuf, NULL);
12741274
}

arch/x86/kernel/fpu/xstate.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ extern void __copy_xstate_to_uabi_buf(struct membuf to, struct fpstate *fpstate,
4646
u32 pkru_val, enum xstate_copy_mode copy_mode);
4747
extern void copy_xstate_to_uabi_buf(struct membuf to, struct task_struct *tsk,
4848
enum xstate_copy_mode mode);
49-
extern int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf);
49+
extern int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf, u32 *pkru);
5050
extern int copy_sigframe_from_user_to_xstate(struct task_struct *tsk, const void __user *ubuf);
5151

5252

0 commit comments

Comments
 (0)