From patchwork Tue Jan 30 00:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13536581 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 905B2C47DA9 for ; Tue, 30 Jan 2024 00:14:45 +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:In-Reply-To:References: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: List-Owner; bh=e4kB5TkSKkPV18/xECMo2/nRARZNfhIotZdbPu5mOAc=; b=vjnClv4NoOwQtD 9a5D0JBcUFwOvydRtX4sK7B6zi7/Z/ZWbh24OVFcHvnZ2EJtYeYtPTaApWnlOOjesrQ9GHCEf3lON kG4NWsLVrmGPKWxERo8rUrjLkJP9ppwTIdHmI0ExnkGXx9V8nzxKyz+QuOzFNyu6JXqR8SHzrZ4yE sZNJ0zbO13JUVxM3hQ4pkRPAnFVAuj++G71l8h6K09aBmoPGx3yPNBbw7yLSPmMzhzF00Onw5A/pE bTN2WKX3pTJJP9zR4VMnmIS1CvuTMvp/90npKBrfEU+ARtcjqv9njMAfWpquYAeaqHF4oF/8M9LoU R95Ur8wNmj6QGyjRTssg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUblq-0000000Efj2-04UX; Tue, 30 Jan 2024 00:14:34 +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 1rUbln-0000000Efi8-1doY for linux-arm-kernel@lists.infradead.org; Tue, 30 Jan 2024 00:14:32 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id CC85462347; Tue, 30 Jan 2024 00:14:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49F9BC43390; Tue, 30 Jan 2024 00:14:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706573670; bh=ZTo5ZwG70N90xxtm+/9tRfhfP4BHWTK7W1uC77KuLOk=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=tlhllx2rYUBERQO/TVeu+jO1tBlv2SsdA69Fb82Zi8Ueh/FvqjtKAfTleIrzdq11p kVMxq4IxOU5DaXCK2HeNRbeEJFLmPtEuUKL22QmbE7qqwI2ZPmHQnSVC9fLdoLfdpa o567PTPk/6uPl3ln20ArrqRQcw0B3cMCAqy5ivJ8VzCVYAoHX18kk7g5QdzgUOcpre h0/jS3wiG4AjxaF86GEAMr/R4HLB+CORxt+fqzXTQBP7SnpM3iEDZg/IjE7BeUkbEM ZzPqBSoL9h2yxvAdMIHXx26vc9U0Rp9vLO1c0FgM7VkraAa/ZQyE2QPqrcSvtG1hw3 YWJmGl5Hjxodg== From: Mark Brown Date: Tue, 30 Jan 2024 00:02:48 +0000 Subject: [PATCH 1/2] arm64/sme: Restore SMCR on exit from suspend MIME-Version: 1.0 Message-Id: <20240130-arm64-sme-resume-v1-1-0e60ebba18df@kernel.org> References: <20240130-arm64-sme-resume-v1-0-0e60ebba18df@kernel.org> In-Reply-To: <20240130-arm64-sme-resume-v1-0-0e60ebba18df@kernel.org> To: Catalin Marinas , Will Deacon Cc: Dave Martin , Jackson Cooper-Driver , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=2824; i=broonie@kernel.org; h=from:subject:message-id; bh=ZTo5ZwG70N90xxtm+/9tRfhfP4BHWTK7W1uC77KuLOk=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBluD9hwBczBmoZohtBPPFhLyZwbLluJz2W6O5QONUl 43GzPTKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZbg/YQAKCRAk1otyXVSH0MtoB/ 9id4s9xk+85E5vWs/iH8YfCgW0RW41QLhxe3supGv4xCY6wCEAyDqGmcDPWBwVxLkHskdh33bVMbRz KBq6U5u9rCXkckAITaFHFf8ycMwqBykW/WLoM1P5B7IdQyzzj6GYj+nzI/nqbECDBPOaQqZatc0nAi 2qFCQ3fwVOxlY+8J5H7bboUrULAD2y5XxyzRcbw5kD3LmFkjSZFOdODvdxm+Mysvgko+ltfNiThi3L +k0/EbQbm/dL3Yhk8uIihyyRm+Y62RYygYlCrFcud3tYuYgAqH1H53Rez3LBngy1TT0jCHYFgF3QZ3 b3RJStCKjjUTSnNWz5AhUNdBpAtsDu 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-20240129_161431_549512_EFA82C4D X-CRM114-Status: GOOD ( 14.51 ) 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 fields in SMCR_EL1 reset to an architecturally UNKNOWN value. Since we do not otherwise manage the traps configured in this register at runtime we need to reconfigure them after a suspend in case nothing else was kind enough to preserve them for us. The vector length will be restored as part of restoring the SME state for the next SME using task. Fixes: a1f4ccd25cc2 (arm64/sme: Provide Kconfig for SME) Reported-by: Jackson Cooper-Driver Signed-off-by: Mark Brown --- arch/arm64/include/asm/fpsimd.h | 2 ++ arch/arm64/kernel/fpsimd.c | 13 +++++++++++++ arch/arm64/kernel/suspend.c | 3 +++ 3 files changed, 18 insertions(+) diff --git a/arch/arm64/include/asm/fpsimd.h b/arch/arm64/include/asm/fpsimd.h index 50e5f25d3024..7780d343ef08 100644 --- a/arch/arm64/include/asm/fpsimd.h +++ b/arch/arm64/include/asm/fpsimd.h @@ -386,6 +386,7 @@ extern void sme_alloc(struct task_struct *task, bool flush); extern unsigned int sme_get_vl(void); extern int sme_set_current_vl(unsigned long arg); extern int sme_get_current_vl(void); +extern void sme_suspend_exit(void); /* * Return how many bytes of memory are required to store the full SME @@ -421,6 +422,7 @@ static inline int sme_max_vl(void) { return 0; } static inline int sme_max_virtualisable_vl(void) { return 0; } static inline int sme_set_current_vl(unsigned long arg) { return -EINVAL; } static inline int sme_get_current_vl(void) { return -EINVAL; } +static inline void sme_suspend_exit(void) { } static inline size_t sme_state_size(struct task_struct const *task) { diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index a5dc6f764195..69201208bb13 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1311,6 +1311,19 @@ void __init sme_setup(void) get_sme_default_vl()); } +void sme_suspend_exit(void) +{ + u64 smcr = 0; + + if (!system_supports_sme()) + return; + + if (system_supports_fa64()) + smcr |= SMCR_ELx_FA64; + + write_sysreg_s(smcr, SYS_SMCR_EL1); +} + #endif /* CONFIG_ARM64_SME */ static void sve_init_regs(void) diff --git a/arch/arm64/kernel/suspend.c b/arch/arm64/kernel/suspend.c index eca4d0435211..eaaff94329cd 100644 --- a/arch/arm64/kernel/suspend.c +++ b/arch/arm64/kernel/suspend.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -80,6 +81,8 @@ void notrace __cpu_suspend_exit(void) */ spectre_v4_enable_mitigation(NULL); + sme_suspend_exit(); + /* Restore additional feature-specific configuration */ ptrauth_suspend_exit(); } From patchwork Tue Jan 30 00:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13536582 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 4ED39C47DB3 for ; Tue, 30 Jan 2024 00:14:52 +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:In-Reply-To:References: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: List-Owner; bh=HqH4kbVb5Y32NbzdxpmqI/cn8XpDsFIEdUDhUobE/tg=; b=CPCNGijd5TP+fm WXm0pq7Ckj2lsGbv97bYQdEGKHMzn2U+shlg6Ftm6hli5xa8wnUCtvCyHLj8Ne93bLcYpxlH4egKS yv171LnD/3awO+2tsitZFsv9hJcevJD79KV2LUMF8GJsKLZk0bHzd201cptNEUsgV2j5YZAiswgZE 7Det5R8C3EgR8incIqxDE7YSK7NVb4pYfEp8iXGLphk7F7tCee0M1GA7KrVKs2qD26GlenoRyEl4G M/OEvGgnw1yIFYfdLcyZyVdi04M9L6JPihohUL6Bv+tzeNU2cfYAbeybrbZHqZT+WuNJfoUZNbJMY ie6WQrzmX0FNnrjVdwow==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rUbly-0000000EflU-3xdV; Tue, 30 Jan 2024 00:14:42 +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 1rUblp-0000000Efic-0kVq for linux-arm-kernel@lists.infradead.org; Tue, 30 Jan 2024 00:14:34 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id A9161625C6; Tue, 30 Jan 2024 00:14:32 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 129CAC433F1; Tue, 30 Jan 2024 00:14:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706573672; bh=xEARPrXco3uTwEMG96xAAVNItcj/45n5YEk1eOwXClE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=rpfJiGmv2ewynNRmxqcFutzROj92ZWWNfnlXznIBeT9B+qAkKvijXcMfnZjwUVhtP NhihLpFTDJjpzw9k4FF+CfxUhaRDUJMAN+z9W44pz/kDQpbI9Z8RnFAkDkGUQgVI9B n4CT+IUSQzEad1xWllVykN+pTeDuMSOYLYDF1t4f6BckgyttiXv0oLdwODzr9OUYXc ls/2WGTTjNuQ+sZlOL9AJl9NrYlrXF1/pgUCqG41PLpCCa5y/5rD0kztRKovoasGB0 57Yc5VeCx+I3SG7p8YWNm/hOdu0+SjuWn7nHfkG3KqTMohlpVrB5+AFbt50tqC9lYG PcoOXd/lDwODw== From: Mark Brown Date: Tue, 30 Jan 2024 00:02:49 +0000 Subject: [PATCH 2/2] arm64/sme: Restore SMCR_EL1.EZT0 on exit from suspend MIME-Version: 1.0 Message-Id: <20240130-arm64-sme-resume-v1-2-0e60ebba18df@kernel.org> References: <20240130-arm64-sme-resume-v1-0-0e60ebba18df@kernel.org> In-Reply-To: <20240130-arm64-sme-resume-v1-0-0e60ebba18df@kernel.org> To: Catalin Marinas , Will Deacon Cc: Dave Martin , Jackson Cooper-Driver , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-a684c X-Developer-Signature: v=1; a=openpgp-sha256; l=953; i=broonie@kernel.org; h=from:subject:message-id; bh=xEARPrXco3uTwEMG96xAAVNItcj/45n5YEk1eOwXClE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBluD9i6yBs2MgbbLUzAPKlp1ZuhKTGe0vDXTQl6XYM 5TVEHjqJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZbg/YgAKCRAk1otyXVSH0KIZB/ 0VUqbC1WxvC5599zPIxyITE5LsBkJ1mSnsGokZEsNminewQPOex98hDJhyZYzBNMULgL636VUgyLL4 sLiH4tj4vzBEDIuGN4q8lNnLs7PnrNh2tC1+0u9SAHllCPuognJbWsRWZfbejbYxu16Jwci4KqhTjW /TfAx9RQgmbOb4X1qTLpc7Mfd5B7bo4aeJR2ZcLBsRtYGug91XOKzhVX4N4xynZqQatLuzp2A9MK2l qUfvY0yLD11I2dQeVp/3Fcqg1rGLOt8MGRt/I/pfBKJaq3UYLb5ueLUMn9G+I1q9Md2h9NuoSaIBk1 2WysA6QBWN+bsC8h6lTv4xZ30EKYav 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-20240129_161433_294339_D5DD590B X-CRM114-Status: UNSURE ( 9.46 ) X-CRM114-Notice: Please train this message. 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 fields in SMCR_EL1 reset to an architecturally UNKNOWN value. Since we do not otherwise manage the traps configured in this register at runtime we need to reconfigure them after a suspend in case nothing else was kind enough to preserve them for us. Do so for SMCR_EL1.EZT0. Fixes: d4913eee152d (arm64/sme: Add basic enumeration for SME2) Reported-by: Jackson Cooper-Driver Signed-off-by: Mark Brown --- arch/arm64/kernel/fpsimd.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/arm64/kernel/fpsimd.c b/arch/arm64/kernel/fpsimd.c index 69201208bb13..329782fe39c5 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1320,6 +1320,8 @@ void sme_suspend_exit(void) if (system_supports_fa64()) smcr |= SMCR_ELx_FA64; + if (system_supports_sme2()) + smcr |= SMCR_ELx_EZT0; write_sysreg_s(smcr, SYS_SMCR_EL1); }