Received: by 2002:a05:7412:d1aa:b0:fc:a2b0:25d7 with SMTP id ba42csp708005rdb; Mon, 29 Jan 2024 16:14:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOOFQ0DQFfBnTC2s5uTmA+ijzjTY3aWkSKh4P8BMOl/Zr3kO+vukfIIk3/MpLdyw8MMh6w X-Received: by 2002:a17:902:fe82:b0:1d7:85cd:e93b with SMTP id x2-20020a170902fe8200b001d785cde93bmr165318plm.15.1706573684230; Mon, 29 Jan 2024 16:14:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706573684; cv=pass; d=google.com; s=arc-20160816; b=vNShTAM1gcuY/WlZiG228+gU1fXxi4aXJGBFYQ6a2Hxqo+SI8uWzrPOS2idQjEJFC3 Pu74BnpcS/TtVkbHLd7VO/esNAWoQ3c1FKH0Wj5jgHQ53udmXg9Cmc84SziHRWVIsILO yXcgiCyiy5RsRMo/9Qb3c4RFn+RZpEmfsRSnuIgx/b1F6tTa5jfLNWsM8HuUDAu+gznd EDPiGSPWrjBbF6j2UV3AfUhfx8JTIeWos+XBZuIdpohz2aD2lhU3cMTomlrOuMizTYsl 6NSCvXv9a0DteQayl73rfedwzQB3q85xGmaBFL/i7ect733SPZr446D/zbSzJzjPbJF7 yMSw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :subject:date:from:dkim-signature; bh=UXIjgYAqUFQRjrkLG8bY68e7SSKhlg2AmsC57IcYojE=; fh=0mGf4Cbu606ATNCCcSl9jdUnQus/lINFItlNRZrR8jk=; b=iNRkovvZ72/9l5Q+QEtgsY623+2dizvc9POVFr9fLMZsc8KYd13i8qHci1AteBbZML ALRzq9MBZMPKZEYiK9edOSIeat614V2uhdH2S05F9wnxL4XgIWGU3+ckBprKT9pUJphB AsE2xQS8/iKmCqnNhf31B7gkIRGfK/YFZbfcxiao1Zt//F6e7ppcIpKf1s3gbgUTF3xZ irgt0myWHBFRpLgDlLHuXf/1MWAwqO0yZ1gEINh2UWmTE9RtuTzrjUzoEGloWzqFMHcS FPauAR3qFqBICW7xvfVMOB8c6FFZCp1AB26v+XVgiyL4LdesXPOUwCWlGEDiv4zYNUvB BCVw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tlhllx2r; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id q10-20020a170902b10a00b001d748e13788si6522814plr.93.2024.01.29.16.14.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:14:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=tlhllx2r; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43665-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43665-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6183C284A6D for ; Tue, 30 Jan 2024 00:14:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A6CAA168BE; Tue, 30 Jan 2024 00:14:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tlhllx2r" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CB57D125CA for ; Tue, 30 Jan 2024 00:14:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706573670; cv=none; b=HbvaUJG0fD7TgTcIHAOWzTIbJS2eSiEvad0C5rZV4buyroZsQWfp/ZHn9OcTh0y2TeTnXc6MiKdNnlmN5JxpHqFOyHoi0dZDcbkTQLms3zjzu8LPyjNdnAlnL+A0Ur+Izz+Q1NfO9SrxjVoMn9C4DIguOnZcJ6GJ9J+EzPftAe8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706573670; c=relaxed/simple; bh=ZTo5ZwG70N90xxtm+/9tRfhfP4BHWTK7W1uC77KuLOk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=GeWRSyMjAxoXWEs6WEdcE+KCRhv9cLNSnmmoFD+8MqzoXT9lr4584IgBSpaLp5a2jW8GpXoQN+c7LuEUJeoFJKeZpmD1ZT/APLyCNDuR6cdi0pXkCUPa3Y205WNZ7LfK7UUVaNqQNUk9FapVJ97jWtvBxF1epUyR3N/1ioZnDro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tlhllx2r; arc=none smtp.client-ip=10.30.226.201 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 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(); } -- 2.30.2