From patchwork Fri Jan 19 12:29:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13523737 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 D764FC4725D for ; Fri, 19 Jan 2024 12:31:18 +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=utrgqgo0Ksc+xEGo0SYOQoq6WA++ZHVy8a+3ul27Ung=; b=lQGF7cv7/+iiMd i1L3BCyvylL/VFwn88rNBTeYRE5LZ0biXuwPE5xM6HfmTXcAMzuA0ssV4iogM47cVuPbCyNw+fZkl Wpm2GBd3jDiaziIvBFBmSq4bfr0sr4cwjatxYZ+jvJ/SHMP1sjvR2QGhWNnIG283pfq2axIjy+RjN F20b3q+oJGmkH1+aZ9jf1PwqHiYs4AVHTB13D5jT1gJOQw2Vg7WTLFz68dbG8Eg5M59nmEUvOhAQz s3w3U3TGZK3TEBAZ9gPbPIHxNNS1lmCj0NUpumh/F1yTibiP8O0qqXb9KVAjkgWJKemlxjMAl+taW 7OleZBJCRi2cb04cK6oQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQo1K-005TuF-2v; Fri, 19 Jan 2024 12:30:50 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQo1I-005Ttf-0W for linux-arm-kernel@lists.infradead.org; Fri, 19 Jan 2024 12:30:49 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id 2E45CB81BAE; Fri, 19 Jan 2024 12:30:46 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 27AC8C433F1; Fri, 19 Jan 2024 12:30:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1705667445; bh=lf/x0Quh6MyKXlY1+sTXB9JkbW7K3Z8gqVYtKQnWovY=; h=From:Date:Subject:To:Cc:From; b=RPw4y9haj2MJnJkAI4qo+e93kxuyl5RduirN7CTQDBURa2SIqCA/aLSYrPCQtIv5z mu6Dq8R/4bK1DJl9aRJg9OsZPvMc89qttUU0VPKMerKbXSnw1S/sxEn+C1GfHSoYr7 goHrVsXGiZSttzcu7uoTxD87SLLkhInwDtz7RR7uDOVeDqmB60966z0zsOSLta+i+K eoNn1aJiTf1DAj6/SwoGkqfib8um1skRnMUCeBDMCMBnKJFGunny29p22LrkNSjv33 cAyuRYUYYtuGC952IlvmCrDTDcEcZA6hJy4rOKhgyHS6nPks2KfsIMmXKMg4HWgg7V m1Ic4J6otPVUA== From: Mark Brown Date: Fri, 19 Jan 2024 12:29:13 +0000 Subject: [PATCH] arm64/signal: Don't assume that TIF_SVE means we saved SVE state MIME-Version: 1.0 Message-Id: <20240119-arm64-sve-signal-regs-v1-1-b9fd61b0289a@kernel.org> X-B4-Tracking: v=1; b=H4sIABhrqmUC/x3MQQqEMAxA0atI1gaaUnWYq4iLYmMNOB1JQATx7 haXb/H/BcYqbPBtLlA+xORfKqhtYF5jyYySqsE7HxzRB6P++oB2MJrkEjdUzobdQMQukQu+g9r uyouc73ec7vsBYpiLk2cAAAA= To: Catalin Marinas , Will Deacon Cc: Dave Martin , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown , stable@vger.kernel.org X-Mailer: b4 0.13-dev-5c066 X-Developer-Signature: v=1; a=openpgp-sha256; l=2214; i=broonie@kernel.org; h=from:subject:message-id; bh=lf/x0Quh6MyKXlY1+sTXB9JkbW7K3Z8gqVYtKQnWovY=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlqmtzPBMCsko55/jXqsoxUluay7LXpo0hu0HjvHCz PZyP9CSJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZaprcwAKCRAk1otyXVSH0HPNB/ 9y9XJ+fJvmEyASUiIVu/UIAd2Qk4l3C66okxn9mI/S7VqLaUHEh9tLhMijFVytufDmIC4m753GfaAu NSRv8819LWicnjdi4blAutRme2U0WOXNCiY6XR1jUHlzcPF61O+wd6tzc1mHf9SFFFIotsS+SuoDUh QaV3za/dMkCpofz8EputuaEV4eL3hbwSsZDwGVQCL7IG7PhIZqLvQE0s55GT/BaE5QhLCiTnBPWMUG wV52GMdSPH1yuGo1AiztVv3dpjz6R4fexQa18A2M1n3fgj6cgXc9n4k5+Lfs6ZxrceVU/6I8YPutCI P0cyhNis9PwLTRZUlAXnX2tqRVPYHU 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-20240119_043048_460995_1DC8DA31 X-CRM114-Status: GOOD ( 15.47 ) 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 we are in a syscall we will only save the FPSIMD subset even though the task still has access to the full register set, and on context switch we will only remove TIF_SVE when loading the register state. This means that the signal handling code should not assume that TIF_SVE means that the register state is stored in SVE format, it should instead check the format that was recorded during save. Fixes: 8c845e273104 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch") Signed-off-by: Mark Brown Cc: --- arch/arm64/kernel/fpsimd.c | 2 +- arch/arm64/kernel/signal.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) --- base-commit: 0dd3ee31125508cd67f7e7172247f05b7fd1753a change-id: 20240118-arm64-sve-signal-regs-5711e0d10425 Best regards, diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 1559c706d32d..80133c190136 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1626,7 +1626,7 @@ void fpsimd_preserve_current_state(void) void fpsimd_signal_preserve_current_state(void) { fpsimd_preserve_current_state(); - if (test_thread_flag(TIF_SVE)) + if (current->thread.fp_type == FP_STATE_SVE) sve_to_fpsimd(current); } diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 0e8beb3349ea..425b1bc17a3f 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -242,7 +242,7 @@ static int preserve_sve_context(struct sve_context __user *ctx) vl = task_get_sme_vl(current); vq = sve_vq_from_vl(vl); flags |= SVE_SIG_FLAG_SM; - } else if (test_thread_flag(TIF_SVE)) { + } else if (current->thread.fp_type == FP_STATE_SVE) { vq = sve_vq_from_vl(vl); } @@ -878,7 +878,7 @@ static int setup_sigframe_layout(struct rt_sigframe_user_layout *user, if (system_supports_sve() || system_supports_sme()) { unsigned int vq = 0; - if (add_all || test_thread_flag(TIF_SVE) || + if (add_all || current->thread.fp_type == FP_STATE_SVE || thread_sm_enabled(¤t->thread)) { int vl = max(sve_max_vl(), sme_max_vl());