From mboxrd@z Thu Jan 1 00:00:00 1970 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 6F746C19F2A for ; Thu, 11 Aug 2022 11:05:40 +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=NSPZY4g3zYJZQEcvrTHveVvtENx7C7FN9cnsgcpGwbY=; b=1xv+w8r6+2fu4x Z7B4O/kjwEKLc69w5mzS5heGPeuNRglCZAlPyygKH3zI5KWcQ1Y40XdMkgYJZNOOLVsl4xKlWZeNZ MFxR5LcRps/02wM906EWdFty8FpL2nVT+LhYtkUTNdAg8hx6ejS/QlWOiyf0CDuYqB9dKFsNW+LXU 2dMv7hbVqUqwZSDHbrK0X//49FlmpHwlG0zCRtBvNrKk0rsH938YE6LwBPha0fiX9OrtRd9MML3yI 8x8Z2WD4QN5AND1nPRcs5Gqf0a+yzPtjjsJxkEjLyxACXi1cIw75rrZ+a1kbvUagPDCykcAou1eBY sALYDA4UglNQRby1NJCQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oM5zU-00BSyi-NE; Thu, 11 Aug 2022 11:04:40 +0000 Received: from ams.source.kernel.org ([2604:1380:4601:e00::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oM5z3-00BSjr-Mt for linux-arm-kernel@lists.infradead.org; Thu, 11 Aug 2022 11:04:15 +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 ams.source.kernel.org (Postfix) with ESMTPS id 87413B81FBB; Thu, 11 Aug 2022 11:04:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F6B9C4347C; Thu, 11 Aug 2022 11:04:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1660215849; bh=2EH/bj06jtQNQ2LtBkP1qYrcKHwpFRmEq9ZW7LKC2jo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W6x3c6CGkWj8E7vpn8471u8KnDM8FDUVqECncYLC52HXL7RfCqej/J4nkhe4k5J/1 QOWtARy9p89jqB1QC8bzkPCWxG4i3+8N7ZeNS/w9eRj7m9Dy5FW87rgVOhvj/1mOSw MvzSG5B3ChZZRVa9a9tu+TvstC7yaARHVBGOJex4ZmLQpmmrmr0yWsZHjp7TXPJCeY XTPayZtx65yE3di7PdiRK7NSI+obN5tDrtOdeOXjJRSDyCPCvlNWkFppdqGBAzfnDW o+s1PKKvbmCobu/FS9vHpGANROEA2L8kmSzgaZmFmAVGh/V5bNF0NC9QkUTV8DQl34 ZlErFJzYgwCaA== From: Mark Brown To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, Mark Brown Subject: [PATCH v1 2/4] arm64/signal: Flush FPSIMD register state when disabling streaming mode Date: Thu, 11 Aug 2022 11:57:49 +0100 Message-Id: <20220811105751.25081-3-broonie@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20220811105751.25081-1-broonie@kernel.org> References: <20220811105751.25081-1-broonie@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1488; i=broonie@kernel.org; h=from:subject; bh=2EH/bj06jtQNQ2LtBkP1qYrcKHwpFRmEq9ZW7LKC2jo=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBi9OCsOJH8tY/aKUQZMFpq1lDx7Lhv2E4pMP0bq8Nz u98/ec6JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCYvTgrAAKCRAk1otyXVSH0EifB/ 9N3SGoNSOrBjHieJVnY3gJPBYTqywtJuceHP4wdCtZBRwopoq+hR8Ie4EwtpMr4WsXT4sgeTCL0u81 tKkBEzOBoS6A3VE88+Givdg0jUyyuWMpeO+D8VPqH7FA8XEOXOKqejdKfPcwxR4qrDlp0YxsQuk57g B+S+VXPxdk4i5xKbnE4UZSwm81Yf/OoM1gqh+6Gu9NP67AsQp10SFgSVzyc/Pw0xwFr6HAS4KwlAYH s8cKfn/+1bQvSB2Yj9p0NWIXtOzUpgS6yh4GQXlr7fBN7neNl+3bY1YBD7w3D8T4sBDyanIAICI0Ld Yjv8iizkHSNYux7OpWq+45AaK3QihE 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-20220811_040413_915269_C8620F0F X-CRM114-Status: GOOD ( 14.35 ) 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 --- 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 13dee9cedfc6..51fb4268f0ed 100644 --- a/arch/arm64/kernel/signal.c +++ b/arch/arm64/kernel/signal.c @@ -922,6 +922,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