From patchwork Wed Nov 16 23:33:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 21325 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp115793wrr; Wed, 16 Nov 2022 15:35:06 -0800 (PST) X-Google-Smtp-Source: AA0mqf4CHpSx2YW2xXxRf080Zk/cB2oOeCzl7QJ1nYh9wH6m4v/cqzRnS8ClzgwOkXWsQSRNrUgk X-Received: by 2002:a17:907:c787:b0:7ad:8035:ae3d with SMTP id tz7-20020a170907c78700b007ad8035ae3dmr114362ejc.46.1668641706709; Wed, 16 Nov 2022 15:35:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668641706; cv=none; d=google.com; s=arc-20160816; b=D7hltQjtmhGiWJDT3cvMQTc/5rBfD98UFt58j4Y9KgpVoXV8fRQa5lbHLZtFjQ5HJK DLJvau2IL3xOj09k80q+ONBJDhiCAfBqM0ECBFIns7CtOMnyeuDyf3YxP5FJuZITlhV+ OrdXKLaGci0ZhY/eNfFyxUQbnXtI3cXLPapy90rtipWKK+2uX6l2qjly2VZFy0DCsuSz +Gr1ob/unccRZ97vstaSvIx9+Y/wkrnxkE8YpeptM3XY9U4OaEj8G2cd9mDvP3ijMFO/ Ho8Tx6K2/VaCeNgKTB2QAUA39rYHgpNCOdBGGXr8JSXV2kHWDuqalLMqc0tl55lXdDGU RzRQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:cc:subject:to:reply-to:sender:from :dkim-signature:dkim-signature:date; bh=MsnW/9b3W7fq8fblOzT42xDM/SlxUnTHjHj4eknSx64=; b=LMets+BFMZx7TMc52pMuqviwrLiPGz/iBT/tPZxxXz62h8x4ZPwFTFUrjR2/W2Kt4H o/Heswrtr/fcpoijG00LW+1RGM94ELLkODPxeXxMRO6+Rg7Zg/GnXUVn1Lj4whg4Em4V rOXVwSDz4QyLXSNxn98R2/B0+G2G22Tae6NfQgYOl5V57mATa87s6XrzI1EKCBV3uJLM 3LVxw+dwfp+7AWvWwG0mH4mZBCF32yX1lIICdw7TY3ctSuhtT32Siw2JtxU0ZhdH/9w9 0GOcCHIPgUCwZ4pl8Ky/i4F5vv146Cbes8rKeW/M3c9SXa6gLMoMHA0CAVkC9oadSMRM mYcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pPIVnLwp; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a17090626c600b0078c37681f89si12435902ejc.650.2022.11.16.15.34.43; Wed, 16 Nov 2022 15:35:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pPIVnLwp; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234348AbiKPXeM (ORCPT + 99 others); Wed, 16 Nov 2022 18:34:12 -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 X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749697646559005010?= X-GMAIL-MSGID: =?utf-8?q?1749697646559005010?= The following commit has been merged into the x86/fpu branch of tip: Commit-ID: 2c87767c35ee9744f666ccec869d5fe742c3de0a Gitweb: https://git.kernel.org/tip/2c87767c35ee9744f666ccec869d5fe742c3de0a 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, } +/** + * 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 = &fpstate->regs.xsave; unsigned int offset, size; @@ -1270,7 +1280,7 @@ static int copy_uabi_to_xstate(struct fpstate *fpstate, const void *kbuf, */ int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, const void *kbuf, u32 *pkru) { - return copy_uabi_to_xstate(fpstate, kbuf, NULL); + return copy_uabi_to_xstate(fpstate, kbuf, NULL, pkru); } /* @@ -1281,7 +1291,7 @@ int copy_uabi_from_kernel_to_xstate(struct fpstate *fpstate, 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->thread.pkru); } static bool validate_independent_components(u64 mask)