Skip to content

Commit 3c1940c

Browse files
khueygregkh
authored andcommitted
x86/fpu: Emulate XRSTOR's behavior if the xfeatures PKRU bit is not set
commit d7e5ace upstream The hardware XRSTOR instruction resets the PKRU register to its hardware init value (namely 0) if the PKRU bit is not set in the xfeatures mask. Emulating that here restores the pre-5.14 behavior for PTRACE_SET_REGSET with NT_X86_XSTATE, and makes sigreturn (which still uses XRSTOR) and behave identically. Fixes: e84ba47 ("x86/fpu: Hook up PKRU into ptrace()") 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-6-khuey%40kylehuey.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 3f1c814 commit 3c1940c

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/x86/kernel/fpu/xstate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,8 @@ static int copy_uabi_to_xstate(struct xregs_state *xsave, const void *kbuf,
11681168

11691169
xpkru = __raw_xsave_addr(xsave, XFEATURE_PKRU);
11701170
*pkru = xpkru->pkru;
1171-
}
1171+
} else
1172+
*pkru = 0;
11721173

11731174
/*
11741175
* The state that came in from userspace was user-state only.

0 commit comments

Comments
 (0)