From patchwork Mon Mar 25 16:35:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13602507 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 A23A2C54E64 for ; Mon, 25 Mar 2024 16:39:07 +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=6RCJKJFp6cOoDj+Ywa4oJWOtYFtfz4FGx89wnJ0qPHE=; b=QMxS7oQgi7Lcos HijnF/cW+IErB5eUDYYZJy5y/i/Sa1YqBlvg6VuLRveLsXWD6+geSdhhbW+y+TU6xHEDvJbnR97s4 cArInUvZ4VgmsseZOMgbyYw4LHnMtKQt1kcxv2cy2bDzIaol1V1ENnzGeyRXwvvr3OEuGJJUCRJAQ +O4gsJf8u/7YnH9axQD5zjr6L5Uu+u70J2HZbbpiUYayQ4voMmFZ/tQpf080d+w78taYtFuObLqHg qHpiXq/d/eIg0U/MmbjWgxwIksiXvKkgHrdN88GCrtCEl7s9nufUSoNWGF9RWjMZY9AvotXkhjeCS mkGg+qjvSTOPid+fGCjg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1ronLd-00000000oBA-1SgC; Mon, 25 Mar 2024 16:38:57 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1ronLZ-00000000o8w-0Zwt for linux-arm-kernel@lists.infradead.org; Mon, 25 Mar 2024 16:38:55 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id 7064760FAD; Mon, 25 Mar 2024 16:38:52 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9FC35C433C7; Mon, 25 Mar 2024 16:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711384732; bh=CJxKR8UNymWiAkoGTQUmm74DhnvBaZZP9hB+tXHxzbc=; h=From:Date:Subject:To:Cc:From; b=DYBBbfxQjeyNps22kMv0rulCkXFHojXbH9GUt6jbDb3ClU+ZmcJxc3phHFvCHUH0h hsH+HcaIOJbLjKlZtB5n4mCupg4Yp4s7SDj0CzD8+zYNeuYK0Bmtn/dsvC2E/KDrqb 5B2fvf+8Xfe17H+QwKq/UQ7f4riUdVIBhgsF8Q0czq+N0lHKl5tkKChyOLqwjBeP3G NxXQ8cDV2i8Arp+dRoiqH2jR/3sk67UUuoLyT7WPnhqqafYHNKjUbG2LMnWRVadi+2 wYotyyEqJG9vfkVS/ChHHXrz1fdtFoHYqvrRJpfM7DJ2kVenS2Eo7Xd4WOHtxOwI1J 3//If3AyujgtA== From: Mark Brown Date: Mon, 25 Mar 2024 16:35:21 +0000 Subject: [PATCH] arm64/ptrace: Use saved floating point state type to determine SVE layout MIME-Version: 1.0 Message-Id: <20240325-arm64-ptrace-fp-type-v1-1-8dc846caf11f@kernel.org> X-B4-Tracking: v=1; b=H4sIAMinAWYC/6tWKk4tykwtVrJSqFYqSi3LLM7MzwNyDHUUlJIzE vPSU3UzU4B8JSMDIxMDQyNL3cSiXDMT3YKSosTkVN20At2SyoJU3RTj5FQTizQLCwvjVCWg1oK i1LTMCrCx0bG1tQCrOV2MZgAAAA== 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.14-dev X-Developer-Signature: v=1; a=openpgp-sha256; l=2118; i=broonie@kernel.org; h=from:subject:message-id; bh=CJxKR8UNymWiAkoGTQUmm74DhnvBaZZP9hB+tXHxzbc=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBmAaiZtvwmf4UFALoOXmuGK0ixd/tNCvVGCopl8RQD qUB6X46JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZgGomQAKCRAk1otyXVSH0KN8B/ 9r7e1IHguFKU+kRZM5X5JfT/i3nfrnQ86DPw3GiS81xr2njfX5ae53taWoc+vtFBkN0sfmkxtPp5op T1Fd5Fd/bNoiyCA0jtaOR7ZU7Oj19tl1tufFgxgRxbIBlflpOgkTHpDQ2qJzC4q0JaJFSoq/E+xDGB 4ObNZNaf2i1V5i9bgDLNkhqRmC5iwuk+GAM+hXzy9bzprAs/ENWuGKbQ17OZq7n96C3wdSmxd1k9Vh S1mHMHbZEBj6oNUtOezs5rEDAuMK06tDl6meLbwzH+PtzMqGdKQoInlzPPmQeYH6YfWe1JLk+mg26b yXXs8mltU+rLX6+2RIGaigALtzXIBZ 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-20240325_093854_382062_F9AD269E X-CRM114-Status: GOOD ( 13.73 ) 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 The SVE register sets have two different formats, one of which is a wrapped version of the standard FPSIMD register set and another with actual SVE register data. At present we check TIF_SVE to see if full SVE register state should be provided when reading the SVE regset but if we were in a syscall we may have saved only floating point registers even though that is set. Fix this and simplify the logic by checking and using the format which we recorded when deciding if we should use FPSIMD or SVE format. Fixes: 8c845e273104 ("arm64/sve: Leave SVE enabled on syscall if we don't context switch") Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- arch/arm64/kernel/ptrace.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) --- base-commit: 4cece764965020c22cff7665b18a012006359095 change-id: 20240129-arm64-ptrace-fp-type-d3ce48f8883e Best regards, diff --git a/arch/arm64/kernel/ptrace.c b/arch/arm64/kernel/ptrace.c index 162b030ab9da..0d022599eb61 100644 --- a/arch/arm64/kernel/ptrace.c +++ b/arch/arm64/kernel/ptrace.c @@ -761,7 +761,6 @@ static void sve_init_header_from_task(struct user_sve_header *header, { unsigned int vq; bool active; - bool fpsimd_only; enum vec_type task_type; memset(header, 0, sizeof(*header)); @@ -777,12 +776,10 @@ static void sve_init_header_from_task(struct user_sve_header *header, case ARM64_VEC_SVE: if (test_tsk_thread_flag(target, TIF_SVE_VL_INHERIT)) header->flags |= SVE_PT_VL_INHERIT; - fpsimd_only = !test_tsk_thread_flag(target, TIF_SVE); break; case ARM64_VEC_SME: if (test_tsk_thread_flag(target, TIF_SME_VL_INHERIT)) header->flags |= SVE_PT_VL_INHERIT; - fpsimd_only = false; break; default: WARN_ON_ONCE(1); @@ -790,7 +787,7 @@ static void sve_init_header_from_task(struct user_sve_header *header, } if (active) { - if (fpsimd_only) { + if (target->thread.fp_type == FP_STATE_FPSIMD) { header->flags |= SVE_PT_REGS_FPSIMD; } else { header->flags |= SVE_PT_REGS_SVE;