From nobody Mon Apr 13 21:41:36 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7937BC433FE for ; Wed, 16 Nov 2022 23:34:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234202AbiKPXeN (ORCPT ); Wed, 16 Nov 2022 18:34:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57102 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234155AbiKPXd5 (ORCPT ); Wed, 16 Nov 2022 18:33:57 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1A792F02E; Wed, 16 Nov 2022 15:33:55 -0800 (PST) Date: Wed, 16 Nov 2022 23:33:51 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668641633; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MsnW/9b3W7fq8fblOzT42xDM/SlxUnTHjHj4eknSx64=; b=pPIVnLwpbnzGuO/1R3bbImKCDpkvN3zvwtmBH3mHwlbGtE1UVdxZd2ncs8w1axYHh1aKvP Z4E1oUlmDqRX311OylQtYS5sbbyK+yixI46UbJlApS1FK5LJ1UJyYG9I4hSYotg8uA589B CdA8ccQsDzLq37RXsYd1oCkJ5Xqq55i1+TLOE3To3AcMG1dk2gteZzQlEPRrRdwOQallQD XbhULjCTebRl01sRlV2O+lUBQ015yZ0afrkT9Tk6N6si39jTA/X+MaLrdVb7bk4NxCw8oJ PRxl0iTLDaPu9plhsxS5J7pFGBu5e4XwFpx/z0BvmbQPODylB0gfIaoT0Efq9A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668641633; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=MsnW/9b3W7fq8fblOzT42xDM/SlxUnTHjHj4eknSx64=; b=xC7p0Hhv+SGDHTS1V5SNMT6NY9Zr3CLCTZTj1Jy/IZpD52Noyp+0VbkeQPvTVIkh+3vobh m/M8UwZxD5xbBxAQ== From: "tip-bot2 for Kyle Huey" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/fpu] x86/fpu: Add a pkru argument to copy_uabi_to_xstate() Cc: Kyle Huey , Dave Hansen , x86@kernel.org, linux-kernel@vger.kernel.org MIME-Version: 1.0 Message-ID: <166864163188.4906.12947671892582185831.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The following commit has been merged into the x86/fpu branch of tip: Commit-ID: 2c87767c35ee9744f666ccec869d5fe742c3de0a Gitweb: https://git.kernel.org/tip/2c87767c35ee9744f666ccec869d5fe74= 2c3de0a Author: Kyle Huey AuthorDate: Tue, 15 Nov 2022 15:09:29 -08:00 Committer: Dave Hansen CommitterDate: Wed, 16 Nov 2022 15:03:30 -08:00 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 Signed-off-by: Dave Hansen Link: https://lore.kernel.org/all/20221115230932.7126-4-khuey%40kylehuey.com --- arch/x86/kernel/fpu/xstate.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/arch/x86/kernel/fpu/xstate.c b/arch/x86/kernel/fpu/xstate.c index d6f414a..d657c8b 100644 --- a/arch/x86/kernel/fpu/xstate.c +++ b/arch/x86/kernel/fpu/xstate.c @@ -1200,8 +1200,18 @@ static int copy_from_buffer(void *dst, unsigned int = offset, unsigned int size, } =20 =20 +/** + * copy_uabi_to_xstate - Copy a UABI format buffer to the kernel xstate + * @fpstate: The fpstate buffer to copy to + * @kbuf: The UABI format buffer, if it comes from the kernel + * @ubuf: The UABI format buffer, if it comes from userspace + * @pkru: unused + * + * Converts from the UABI format into the kernel internal hardware + * dependent format. + */ static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf, - const void __user *ubuf) + const void __user *ubuf, u32 *pkru) { struct xregs_state *xsave =3D &fpstate->regs.xsave; unsigned int offset, size; @@ -1270,7 +1280,7 @@ static int copy_uabi_to_xstate(struct fpstate *fpstat= e, const void *kbuf, */ int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *k= buf, u32 *pkru) { - return copy_uabi_to_xstate(fpstate, kbuf, NULL); + return copy_uabi_to_xstate(fpstate, kbuf, NULL, pkru); } =20 /* @@ -1281,7 +1291,7 @@ int copy_uabi_from_kernel_to_xstate(struct fpstate *f= pstate, const void *kbuf, u int copy_sigframe_from_user_to_xstate(struct task_struct *tsk, const void __user *ubuf) { - return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf); + return copy_uabi_to_xstate(tsk->thread.fpu.fpstate, NULL, ubuf, &tsk->thr= ead.pkru); } =20 static bool validate_independent_components(u64 mask)