From patchwork Thu Aug 3 00:19:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13339064 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 688BCC001DF for ; Thu, 3 Aug 2023 00:19:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:Cc:To:Message-Id:MIME-Version:Subject: Date:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=qhE03J1pSawxl4UQWxzxY3MhsvC+UbT61ElFi5VN/Ds=; b=QYYE2F7o4sBvnE c1ueXpeM8gXVSkfuObC3UUa2Gx3u7AYE/pZplx8iHl1fLvNhWhl0xZwAvI4uvqrNuUbiRg1U78wvW uHw9Gj73QsdxArEjnT+Z2cmXvSEP6uW6VFF49jBUbWxbXYasGrwymbMOC0q3zUu1TNZcLc0CC9bfN CeJFgUAYgD/lWjasQHLBiubUllx+/POPatO++5rGdcdij1w/Hqy6nwpMFlhJJ0+zO5pxBshfSdtgZ C2cJC+XdPaZS03Uzt9Ce934APg3gGBy1mvRIbSP6vJytd5tOkjj6NfLGs8iAGw/XzVkvODK6TqHdQ H0eiEM+T7RgPLWkdemGw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRM3v-006FwB-1p; Thu, 03 Aug 2023 00:19:31 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRM3s-006Fve-0d for linux-arm-kernel@lists.infradead.org; Thu, 03 Aug 2023 00:19:29 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A2BAB61A6A; Thu, 3 Aug 2023 00:19:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 93262C433C8; Thu, 3 Aug 2023 00:19:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691021967; bh=i9njW3CU3ysA1Et78tlBxgdc/qGyJY9FPTxEpsTmWG8=; h=From:Date:Subject:To:Cc:From; b=gOq2g+d+9ejMTOZzt81mXK2BHSp/st6eOC25ZVL8ViGAJKxMOnQRjGTVVFkeXHPH0 mHW/G1MpIEsG/b+1uYo/suVsGKrUb2oJPLdLHNgCs02pj6GdbtS0uiMlpkQlYSch12 N6xPumaKDJvUnQkROASUWZn9sU9zkiyaXsfr2okI5kz/h54lhN45hXWBWkIxYuiH12 dCE5w471iYIJHahmjtGL1lWI6TwAF5fgg81DcQ7nCxC7DcaHobiinhbnS4cbD2/wlU fLL+mH5LQdKTfwVzmYULP/oFwUOOiFNE3ccWvkpVXH/nyULAzK3oFtviMpXtJ4+UkR 6uhxIT/80yvfg== From: Mark Brown Date: Thu, 03 Aug 2023 01:19:06 +0100 Subject: [PATCH] arm64/ptrace: Flush FP state when setting ZT0 MIME-Version: 1.0 Message-Id: <20230803-arm64-fix-ptrace-zt0-flush-v1-1-72e854eaf96e@kernel.org> X-B4-Tracking: v=1; b=H4sIAHnyymQC/x3MQQqDMBBA0avIrB1IUom2VxEXaTLRAWtlokWU3 L3B5YPPvyCRMCV4VRcI/TjxdynQdQV+cstIyKEYjDIP1SmDTj62wcgHrps4T3huCuO8pwmDDa1 +P2PXWA1lsAqV7p73Q85/8JYuIGwAAAA= To: Oleg Nesterov , Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown , stable@vger.kernel.org X-Mailer: b4 0.13-dev-034f2 X-Developer-Signature: v=1; a=openpgp-sha256; l=1168; i=broonie@kernel.org; h=from:subject:message-id; bh=i9njW3CU3ysA1Et78tlBxgdc/qGyJY9FPTxEpsTmWG8=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkyvKM6LEBaAVCoqRA9QISwmgFmsYT68gBlAiT5Dxk 8jA1SXeJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZMryjAAKCRAk1otyXVSH0OCmB/ 9oDJr0WeoFr09Y2F5qiVli1uwiYN1YbqiAUwFb/SF8+odcLDXeI6ZFGmv2F17nmGJDUXwGesHkwvOY iBMku5e5fgpYudMQ+fvBPPL6reyM1/47yrMwS0bIvfQQCvxCqRNZk4pMm7WzoZi1TbUsD37Pj2Bq8r L7k9Uo2EtwfVuK6CYHeBhwR44vHDY0UBgy7FrEhEL/uA5xPg0AXHW1LlgOtoD/7zqBR+qWRA/yViPc /4PhoF4Q2K/0L7qmNQQOgyU0ZG8GkQrCdlLqCPGDwD6v5y6rOndBLXXm+xsTXjmvwfdh8JmXrILkaF 5VEFacWWgVBGYg2NAygyvUZNKsWPez X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230802_171928_274824_DBDAA660 X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When setting ZT0 via ptrace we do not currently force a reload of the floating point register state from memory, do that to ensure that the newly set value gets loaded into the registers on next task execution. The function was templated off the function for FPSIMD which due to our providing the option of embedding a FPSIMD regset within the SVE regset does not directly include the flush. Fixes: f90b529bcbe5 ("arm64/sme: Implement ZT0 ptrace support") Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- arch/arm64/kernel/ptrace.c | 2 ++ 1 file changed, 2 insertions(+) --- base-commit: 5d0c230f1de8c7515b6567d9afba1f196fb4e2f4 change-id: 20230802-arm64-fix-ptrace-zt0-flush-d6d71b9f8461 Best regards, diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index d7f4f0d1ae12..740e81e9db04 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -1180,6 +1180,8 @@ static int zt_set(struct task_struct *target, if (ret == 0) target->thread.svcr |= SVCR_ZA_MASK; + fpsimd_flush_task_state(target); + return ret; }