From patchwork Wed Aug 2 23:46:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13338959 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 993A2C001DE for ; Wed, 2 Aug 2023 23:47:49 +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=rB75G7+3sy2UwKVIGiiXuH9Gw7/vY01GSllR++qdx98=; b=bs4+26RsAdGEIj DWmwJ3CUKsthF7nH0yHD0TqzxEuYzXiUzPslHj2ev/+lYvptVn8XeXAO+wCBlnjlhtsvp3aYooh2I 4kJxFI0m/RoF+f0uebq/iiCK8P0iWPOUGvfkbvCv7YCHhy7c62s9JYc+ONPcTphvbnP1ggwQcs52m S4oDYZHy6yptKXg04vuoolZBrUNibtxlBF8f1ncIuVuMQI07QYbIHKdQ9aK8ToPLpdPsuAA42N6ks NlgVaauCqJzvdsoPL80SZHvNxty7n1fx1eaTNcinY1UtggnvGSdDLqVTsQe7XkshrumdufFVc5u7k uYactnOUWIEY27Vmvbpw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qRLYm-006AO6-3A; Wed, 02 Aug 2023 23:47:20 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qRLYk-006ANi-1p for linux-arm-kernel@lists.infradead.org; Wed, 02 Aug 2023 23:47:19 +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 5F8C761B6F; Wed, 2 Aug 2023 23:47:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 59BEBC433C7; Wed, 2 Aug 2023 23:47:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1691020036; bh=/qLrq5KmhPCru0yGNrw689Q7iuDeimHvE/3JmRSDTww=; h=From:Date:Subject:To:Cc:From; b=AwGQtqIPzjbR8wMuR5jn2X71Mwj4xDLmlhgEmXwS6B3MUajRsljJLfcJoV+JWzkpB RzPxVWhsI3E/BTIFE7+Idh22k3TjJLZTFlUeLJw1YvZFYX7vmg22cAl+M2dUjKuYC0 ZSLPwBslwt6qGqlztOwGzXdAErfHGcQ6kG+/z3PtP0RsYMVGjfEgI5mGuDODF4FL/6 90DddhJfnLjAH6LEDvcwRiZ9pPGVbIK2huHwt9lvNmfl1amXfswQFM+TabHFvKrpJl 0w/BZs6N3v33CFxpF/PiWFd91eQPWJtYj/SWmMXP71Lu4Mc+pjZIgpPbEpQuIN2MUc VKLVj7VY2RgMA== From: Mark Brown Date: Thu, 03 Aug 2023 00:46:39 +0100 Subject: [PATCH] arm64/fpsimd: Clear SME state in the target task when setting the VL MIME-Version: 1.0 Message-Id: <20230803-arm64-fix-ptrace-tif-sme-v1-1-88312fd6fbfd@kernel.org> X-B4-Tracking: v=1; b=H4sIAN7qymQC/x2MywqAIBAAfyX23IKZSPUr0cF0rT30YI0IpH9PO g7MTIZEwpRgqDII3Zz42As0dQV+dftCyKEwaKVb1SmNTjZrMPKD5yXOE14cMW2Eao6hN77T1gY o+SlUrH89Tu/7AXktrpBqAAAA To: Catalin Marinas , Will Deacon Cc: David Spickett , 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=1382; i=broonie@kernel.org; h=from:subject:message-id; bh=/qLrq5KmhPCru0yGNrw689Q7iuDeimHvE/3JmRSDTww=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkyusCoD1cpgdbLKtmBqNR295Gzu5KbTY2MY4nxVPB 0NnJ2mmJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZMrrAgAKCRAk1otyXVSH0B3JB/ 9WoAz7QxboWYtzDkqt8/cmsOqEMDh0uIswB63EKF0rOJZSkukmRnuVUIIt01kyH9jEh6/CfbJeIhMX COMMFmM3tzymxHyb+FQOU3sFXzx+GxDmQiB79Jvwhh9+djemFdAKmSkOjmZROUrl+cGhPiGSbfpwRl t230mvLmbkeDajUEwoCeiFjRnH8prZPX8yfCEaLWFslWxL3I+awa2jrGm0XSwkmojp5oFAueyYfrnu 2NwKEiwEjAi6pDcqqueBmmkR94EiKYlEkbk2X9rkUeTIXO/MteVFapOop7v7kuwNJRSZfRRAhDQoE+ sB21YuxIJTucBsPanLSxDuQwgrole5 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_164718_670048_D4C9FABC X-CRM114-Status: GOOD ( 12.10 ) 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 SME vector lengths we clear TIF_SME to reenable SME traps, doing a reallocation of the backing storage on next use. We do this using clear_thread_flag() which operates on the current thread, meaning that when setting the vector length via ptrace we may both not force traps for the target task and force a spurious flush of any SME state that the tracing task may have. Clear the flag in the target task. Fixes: e12310a0d30f ("arm64/sme: Implement ptrace support for streaming mode SVE registers") Reported-by: David Spickett Signed-off-by: Mark Brown Cc: stable@vger.kernel.org --- arch/arm64/kernel/fpsimd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- base-commit: 5d0c230f1de8c7515b6567d9afba1f196fb4e2f4 change-id: 20230802-arm64-fix-ptrace-tif-sme-0bfd94c8266d Best regards, diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 520b681a07bb..a61a1fd6492d 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -909,7 +909,7 @@ int vec_set_vector_length(struct task_struct *task, enum vec_type type, */ task->thread.svcr &= ~(SVCR_SM_MASK | SVCR_ZA_MASK); - clear_thread_flag(TIF_SME); + clear_tsk_thread_flag(task, TIF_SME); free_sme = true; } }