Message ID | 20240130-arm64-sme-resume-v1-2-0e60ebba18df@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-43666-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp908906dyb; Mon, 29 Jan 2024 16:15:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGO+JB90WtvQ/X/SGWEjNlQvV+wz52M1MvMgBc/5UC57Janr/7SnQqvy8iL3+WAi1IjPoy2 X-Received: by 2002:a05:6808:221e:b0:3bd:f014:eddc with SMTP id bd30-20020a056808221e00b003bdf014eddcmr7236917oib.3.1706573729989; Mon, 29 Jan 2024 16:15:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706573729; cv=pass; d=google.com; s=arc-20160816; b=Pk0EyeakBHM8p/+YZKZoxWmmybC0O9EVxjqBOuZNQ6GWJdMTRiQ4735e6cHhb//WDr t32O2OS5uwEvXMfaAlWzVoIBjY1GO2uT36DJ4RJ9y0RibQuRIJVyWlMQbSieU6JwjC6U x/2vGpbw2yVwm2RPel+Pc0W7EwsD4zCMJzlRz87PsDyOgKLU+abGyyiiCCq/z+SrP1jU R2OmX7SsYJqH8HDYbX6zJtbUMebE6AJ98kiEtJCmAftafqdOZrV2Xe78VMo3AziMApxt 7MtzjHX7B09quHBUEI9ak+nHucoG4Ke8GJc7wwkk49cjaXhcGkJLhG1dJ82UwFkkhlzv 8wyg== 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=m+lYsivp3XG9Vn+NuvFwLq1DKUI/T1bkpRexP+jhSP0=; fh=0mGf4Cbu606ATNCCcSl9jdUnQus/lINFItlNRZrR8jk=; b=1FLUk7u80M2IeNaSetZP1aVIXiQOdUIGgdl1GOlvqTgJ5d2UmUtLLiiYua76CfpgK1 yGiahgXXo+TyEoEvbujpWb4mqzaGp4Y4Os8zNfJm0vwe5lX585xijCYLIWZowZFZ2nio Jmkk4lav6hqLQmU+euI+zoueRhUnGAUW6ghETqYOEdm/bauJKdOBYMaWhN5B5hBhIhBZ kh+ToHySAvUIESQ4rtIYKHsVIbPlNxkUvWUj9O0B1nF1XC1c3R2ccAYFLcWuiru0Q8En yRjJlCSofm1fHD7981kfQsUAEuJaelxzotFzh/nJa0HcWUXAw16c0a7Vz+oxjAb98gH7 optw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rpfJiGmv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43666-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b129-20020a633487000000b005d760c23e01si6638652pga.462.2024.01.29.16.15.29 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Jan 2024 16:15:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-43666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=rpfJiGmv; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-43666-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-43666-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D3AA9B233D5 for <ouuuleilei@gmail.com>; Tue, 30 Jan 2024 00:15:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9CDE52EAF7; Tue, 30 Jan 2024 00:14:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="rpfJiGmv" 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 E394D1F5E6 for <linux-kernel@vger.kernel.org>; Tue, 30 Jan 2024 00:14:32 +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=1706573673; cv=none; b=qHHe7hFg3CmAu7Tc+tE5gKMAo/d63aG2X58hZ8HSenXoWk+Kfn4Hc1xWyP6AqQw7tNBGFutVQHiQYQA+lcSwkj2W4sVIgFnTsxEWOuocZkt9jb2KwJhrBSGeb3udQEbL0dp9AVaMhIkl5tIzRC+BDsg3iECa3sBhyk27QSLTJPI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706573673; c=relaxed/simple; bh=xEARPrXco3uTwEMG96xAAVNItcj/45n5YEk1eOwXClE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=j6hh0jhnLUfmnPRpqN6Yqgk8TgBDp56y2bGFjQl5DtsHcGF9nVxkjoWA89X8RfG6hDtqcUIxs89avYHcJfVixHNaNJaaasvkpFU576H/r82SF6ZEfX9K3Bh8sdGxcx+/NQu9fR24nneh6ytz4/bQxeKrOKc/FIviYBmteonZXSo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=rpfJiGmv; arc=none smtp.client-ip=10.30.226.201 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 <broonie@kernel.org> Date: Tue, 30 Jan 2024 00:02:49 +0000 Subject: [PATCH 2/2] arm64/sme: Restore SMCR_EL1.EZT0 on exit from suspend Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit 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 <catalin.marinas@arm.com>, Will Deacon <will@kernel.org> Cc: Dave Martin <Dave.Martin@arm.com>, Jackson Cooper-Driver <Jackson.Cooper-Driver@arm.com>, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Brown <broonie@kernel.org> 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-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789472255446464966 X-GMAIL-MSGID: 1789472255446464966 |
Series |
arm64/sme: Fix handling of traps on resume
|
|
Commit Message
Mark Brown
Jan. 30, 2024, 12:02 a.m. UTC
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 <Jackson.Cooper-Driver@arm.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
arch/arm64/kernel/fpsimd.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Tue, Jan 30, 2024 at 12:02:49AM +0000, Mark Brown wrote: > 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 <Jackson.Cooper-Driver@arm.com> > Signed-off-by: Mark Brown <broonie@kernel.org> > --- > 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; Ditto comments on patch 1. Unrelated to this patch, it is worth having a prctl for this? The architecture seems to discourage software written for the SME ISA to implicitly rely on FA64, so it would useful to be able to run with it disabled even on hardware that supports it. > + if (system_supports_sme2()) > + smcr |= SMCR_ELx_EZT0; Side question: since ZT0 is likely to be sporadically used, maybe it is worth having separate lazy restore for it versus the main SME state? (Not relevant for this series though, and probably best deferred until there is hardware to benchmark on. Also, ZT0 is small compared with the SME state proper...) [...] Cheers ---Dave
On Tue, Jan 30, 2024 at 10:54:06AM +0000, Dave Martin wrote: > On Tue, Jan 30, 2024 at 12:02:49AM +0000, Mark Brown wrote: > > + if (system_supports_sme2()) > > + smcr |= SMCR_ELx_EZT0; > Side question: since ZT0 is likely to be sporadically used, maybe it > is worth having separate lazy restore for it versus the main SME state? > (Not relevant for this series though, and probably best deferred until > there is hardware to benchmark on. Also, ZT0 is small compared with > the SME state proper...) One of the advantages SME has here is that we've got a clear indication if userspace is actively using the registers through SMSTART and SMSTOP. We only restore ZT0 at all whenever PSTATE.ZA is set and the strong recommendation is that should only be set when either ZA or ZT0 are in active use for power and performance reasons. While it is likely that there will be code that uses ZA but doesn't touch ZT0 I would expect that the overhead of entering the kernel to do a lazy restore will be sufficiently high for it to be an unreasonable penalty on code that does touch it, as you say it's not *that* big compared to likely ZA sizes.
On Tue, Jan 30, 2024 at 02:34:23PM +0000, Mark Brown wrote: > On Tue, Jan 30, 2024 at 10:54:06AM +0000, Dave Martin wrote: > > On Tue, Jan 30, 2024 at 12:02:49AM +0000, Mark Brown wrote: > > > > + if (system_supports_sme2()) > > > + smcr |= SMCR_ELx_EZT0; > > > Side question: since ZT0 is likely to be sporadically used, maybe it > > is worth having separate lazy restore for it versus the main SME state? > > (Not relevant for this series though, and probably best deferred until > > there is hardware to benchmark on. Also, ZT0 is small compared with > > the SME state proper...) > > One of the advantages SME has here is that we've got a clear indication > if userspace is actively using the registers through SMSTART and SMSTOP. > We only restore ZT0 at all whenever PSTATE.ZA is set and the strong Good point. I was still thinking in SVE mode there. > recommendation is that should only be set when either ZA or ZT0 are in > active use for power and performance reasons. While it is likely that > there will be code that uses ZA but doesn't touch ZT0 I would expect > that the overhead of entering the kernel to do a lazy restore will be > sufficiently high for it to be an unreasonable penalty on code that does > touch it, as you say it's not *that* big compared to likely ZA sizes. Agreed. Cheers ---Dave
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); }