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 B97C2C28B2B for ; Wed, 17 Aug 2022 18:25:47 +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:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=jteFmK6mNFE8sgu0qbiUHipaUskkJrEqZEGlnN3Iao0=; b=Y1rbMIu3kYCjRl uQMP6egnNVIoct1KB7xWSGf3QG39HWJCeWzow80SHnaRqvhQranY9OXalOgPSSLTqQfmvuqxx4mHw 6tC/D/zMp0A8jhz/EcC9c/qZU1quT4KiZyrH6jxaTMa23scYb7NEX5afNthN3iOXJQpOg8eFujMzE YDedOXDt/i87jH1mWbcNHDdctC1HutthNr7WQFBEQkysH6uV4KnWxJOSuXHwnW8VJOF6cAkDYUs3O mAoqN8p5KYJjbal/ipjRxlKysrT/m5BMWn+lo2/4HMf0lbbjmF/jiHDCvV3abQ0WyyTfkoKv3SkZ7 7a1riVy9wjS9R/YqZlfw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oONig-004whg-0e; Wed, 17 Aug 2022 18:24:46 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oONiN-004wPd-7V for linux-arm-kernel@lists.infradead.org; Wed, 17 Aug 2022 18:24:28 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 74CCC6134B; Wed, 17 Aug 2022 18:24:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id C83ACC433B5; Wed, 17 Aug 2022 18:24:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660760663; bh=rCzYXyxf3pdoJTPvwKpUOksfGQEnBA+KCqryoqhGxPQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tpaxKAZevO8tbHogW4KGyI+jz/OtSBFc6evWJek+Z1oz+diOT6HFh1mju98yEP10R aAkuoBNTl4vSbtRGymLDMeShESwV0z5pJ6sUNhs1mNzuZC2dPdSMywSrvKdDYmxmsg JwE+j6L0a+m0ArqK7Wog4v+8fMFE4QCBCs6tELkc/CLxWfgTzNXVYVOrKqPJlDDOK+ tI8q0Kx1YQn4klnUenEKS/VS/N/HpuGbo24Fn3ftQXeFKcW858yYJFJqgHKLu1aUyG iaABJzcf9tqthi4CRayaEMZ8n+q4Pqs8ZK/tto4hHAxkwFLKKLGLkb8zq9IGUsCuMS Yl7pXS3NpQfLA== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v3 2/4] arm64/signal: Flush FPSIMD register state when disabling streaming mode Date: Wed, 17 Aug 2022 19:23:22 +0100 Message-Id: <20220817182324.638214-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220817182324.638214-1-broonie@kernel.org> References: <20220817182324.638214-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1544; i=broonie@kernel.org; h=from:subject; bh=rCzYXyxf3pdoJTPvwKpUOksfGQEnBA+KCqryoqhGxPQ=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBi/TIZSesiay5HRG7dWwVo22sgCK9he1xTqWZrZV7O uLH4Ar6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYv0yGQAKCRAk1otyXVSH0CwLB/ 4kDWFP9Uh20PMkTbPkToq8BbTm1E+nGyLKWMnVNMwDP1j6rV9BTQ9mCV/Qbwd/4nWlRwcrArfUIxpp Ar0I3OPHlFZFoxHVJGjbLVh0uSr9aN5ts+qpOO4JErxb7Ywz2FJ/K61X9rI4y6/248aDLij0YQvKx6 +mNo3xpgZGxNPsdY2U+FDIiaZf1wqiy2+ZdHv7iykeILt5PT8kc7+Iq1ld7akw6I68rNTQkVnNlq/8 igakFNJkgdu4wbUEfj3kL6gU9wod1J3UqmJ8nB5jvKY02tx3IEVa5rh0m1+YLVT6SiD7OcUmew8HQj sUN8LmwUZgd7YDYgvRza4rGvzRJv7L 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-20220817_112427_354004_51F2E701 X-CRM114-Status: GOOD ( 13.80 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org When handling a signal delivered to a context with streaming mode enabled we will disable streaming mode for the signal handler, when doing so we should also flush the saved FPSIMD register state like exiting streaming mode in the hardware would do so that if that state is reloaded we get the same behaviour. Without this we will reload whatever the last FPSIMD state that was saved for the task was. Fixes: 40a8e87bb3285 ("arm64/sme: Disable ZA and streaming mode when handling signals") Signed-off-by: Mark Brown Reviewed-by: Catalin Marinas --- arch/arm64/kernel/signal.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm64/kernel/signal.c b/arch/arm64/kernel/signal.c index 0685b8784927..0d28a783a69a 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -926,6 +926,16 @@ static void setup_return(struct pt_regs *regs, struct k_sigaction *ka, /* Signal handlers are invoked with ZA and streaming mode disabled */ if (system_supports_sme()) { + /* + * If we were in streaming mode the saved register + * state was SVE but we will exit SM and use the + * FPSIMD register state - flush the saved FPSIMD + * register state in case it gets loaded. + */ + if (current->thread.svcr & SVCR_SM_MASK) + memset(¤t->thread.uw.fpsimd_state, 0, + sizeof(current->thread.uw.fpsimd_state)); + current->thread.svcr &= ~(SVCR_ZA_MASK | SVCR_SM_MASK); sme_smstop(); -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel