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 F2C08C4828D for ; Sat, 3 Feb 2024 13:01:38 +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=RM09yvUyhD6//mYdfr3oqaL0V1p3KsKDxyh+qTExiVs=; b=hzJQx2n8q+ZOBM jTi1Lijyi52dchO0dMwpbIDKPLzb379CoCGsVkueOeQ0PuRU2zjFpA14viecJmVaozLnfXPaOP7VN 3cV3Wy5vm2TqIlfZ7kVUGv/dMKy0+fYoi91BPMqciFtjCQYCOYWf2mAcn9fOsgjp81pc7Obl0xLPH 9TPOTX503aHm6XpH+7zAT46y8DoB1Mr9DGfzT9Yrx+sLcUHH6XwspmupxFI8Ae4d0ZL8dO02na3F0 BtONl2ia2NM8UIKTBsDpKdw6EVKm6N+3poqzh9aX85CB2oAWo7rZGozi1dUMKoTjIfOGOYwvHj9hT Z0Vq9SOEZsQA0k/adpQg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWFeD-0000000GTHY-2ZAb; Sat, 03 Feb 2024 13:01:29 +0000 Received: from dfw.source.kernel.org ([139.178.84.217]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rWFeB-0000000GTG8-23cV for linux-arm-kernel@lists.infradead.org; Sat, 03 Feb 2024 13:01:28 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by dfw.source.kernel.org (Postfix) with ESMTP id F11E560BAA; Sat, 3 Feb 2024 13:01:26 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 61C37C433F1; Sat, 3 Feb 2024 13:01:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1706965286; bh=WYAnHqfh3wc9ALgAbEUHjU8HQPMdcTokUkC4neL2YMY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=OAcGWw6b+tKUCj4Q377dOFpF7STHZVNvqfUkyXTA2ysBn2YSoUwb/AZrXbLrw5dlc nizLkVJ/AB1XG5lU0OkCOfWtlw6AzoeHR+khV6mtYcJ+wuGv2ssgxN9AUCxRi2uOAK ZXiLEvWZneAR2MYGywMhKDpfu5SrYL8NMer/HQGNWM5NSnhzuK9iZun9h9+A/D1SwT F+FyAgLYI9HPt8JvSIky1P2loBRB7bRikq26UDtKflHQ23OxS9QBMo//TYOOTMNh4Q so87FS1bPJz6LfqZXQVqBOAP/f9o9lkRJ23oTW7C06GnndYhrPdHl2lIs16PLh7SiJ Td7YiWkxEr2Zw== From: Mark Brown Date: Sat, 03 Feb 2024 13:00:40 +0000 Subject: [PATCH v2 1/2] arm64/sme: Restore SMCR on exit from suspend MIME-Version: 1.0 Message-Id: <20240203-arm64-sme-resume-v2-1-a1fbaddc4425@kernel.org> References: <20240203-arm64-sme-resume-v2-0-a1fbaddc4425@kernel.org> In-Reply-To: <20240203-arm64-sme-resume-v2-0-a1fbaddc4425@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=2862; i=broonie@kernel.org; h=from:subject:message-id; bh=WYAnHqfh3wc9ALgAbEUHjU8HQPMdcTokUkC4neL2YMY=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBlvjkT4aXhtj2CXSu9FybDljHxn75/w4PZuyUtMHq8 5JNnjk+JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZb45EwAKCRAk1otyXVSH0KvAB/ 4p6ZI3LJRELdmOTD9CJIEHYV2hSnM8GWKgCbf0qVwltqR5PUoAEAybmvK8z5CALDug3oOu96fr2ucZ 2WyGJJHflFpa6vswKo75XB5/UqQsqk6TVtnJMIlfy2zVgcuck7xVFNbu94vkXdIjO/oNZ3/65lEDQA pUIVXfzo5VACviPzWlj6VMiod0YQyaB1dlQYZltzpB3oOeY9rBuYlFajhb0dFDC/Ll0s0Wr83/kHXg phoPtN8/K2Q8SAgLD4AOXKsU+xWTQ64sc+HcVEQWfFdz0h836fPeG438rraqLStyUi8B+TgDi5nXEb m/T5LTZui/D2SJwL0F30oTzI0STmMt 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-20240203_050127_722841_055A4CEB X-CRM114-Status: GOOD ( 13.98 ) 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 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 | 14 ++++++++++++++ arch/arm64/kernel/suspend.c | 3 +++ 3 files changed, 19 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..8d2a5824d5d3 100644 --- a/arch/arm64/kernel/fpsimd.c +++ b/arch/arm64/kernel/fpsimd.c @@ -1311,6 +1311,20 @@ 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); + write_sysreg_s(0, SYS_SMPRI_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(); } -- 2.30.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel