Skip to content

Commit 2c87767

Browse files
khueyhansendc
authored andcommitted
x86/fpu: Add a pkru argument to copy_uabi_to_xstate()
In preparation for moving PKRU handling code out of fpu_copy_uabi_to_guest_fpstate() and into copy_uabi_to_xstate(), add an argument that copy_uabi_from_kernel_to_xstate() can use to pass the canonical location of the PKRU value. For copy_sigframe_from_user_to_xstate() the kernel will actually restore the PKRU value from the fpstate, but pass in the thread_struct's pkru location anyways for consistency. 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-4-khuey%40kylehuey.com
1 parent 1c813ce commit 2c87767

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

arch/x86/kernel/fpu/xstate.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,8 +1200,18 @@ static int copy_from_buffer(void *dst, unsigned int offset, unsigned int size,
12001200
}
12011201

12021202

1203+
/**
1204+
* copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate
1205+
* @fpstate: The fpstate buffer to copy to
1206+
* @kbuf: The UABI format buffer, if it comes from the kernel
1207+
* @ubuf: The UABI format buffer, if it comes from userspace
1208+
* @pkru: unused
1209+
*
1210+
* Converts from the UABI format into the kernel internal hardware
1211+
* dependent format.
1212+
*/
12031213
static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf,
1204-
const void __user *ubuf)
1214+
const void __user *ubuf, u32 *pkru)
12051215
{
12061216
struct xregs_state *xsave = &fpstate->regs.xsave;
12071217
unsigned int offset, size;
@@ -1270,7 +1280,7 @@ static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf,
12701280
*/
12711281
int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf, u32 *pkru)
12721282
{
1273-
return copy_uabi_to_xstate(fpstate, kbuf, NULL);
1283+
return copy_uabi_to_xstate(fpstate, kbuf, NULL, pkru);
12741284
}
12751285

12761286
/*
@@ -1281,7 +1291,7 @@ int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf, u
12811291
int copy_sigframe_from_user_to_xstate(struct task_struct *tsk,
12821292
const void __user *ubuf)
12831293
{
1284-
return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf);
1294+
return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thread.pkru);
12851295
}
12861296

12871297
static bool validate_independent_components(u64 mask)

0 commit comments

Comments
 (0)