[PATCH] arm64/sme: Optimise SME exit on syscall entry

Mark Brown posted 1 patch 2 years, 8 months ago
arch/arm64/kernel/syscall.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
[PATCH] arm64/sme: Optimise SME exit on syscall entry
Posted by Mark Brown 2 years, 8 months ago
Our ABI says that we exit streaming mode on syscall entry. Currently we
check if we are in streaming mode before doing this but since we have a
SMSTOP SM instruction which will clear SVCR.SM in a single atomic operation
we can save ourselves the read of the system register and check of the flag
and just unconditionally do the SMSTOP SM. If we are not in streaming mode
it results in a noop change to SVCR, if we are in streaming mode we will
exit as desired.

No functional change.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 arch/arm64/kernel/syscall.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/arch/arm64/kernel/syscall.c b/arch/arm64/kernel/syscall.c
index a5de47e3df2b..da84cf855c44 100644
--- a/arch/arm64/kernel/syscall.c
+++ b/arch/arm64/kernel/syscall.c
@@ -173,12 +173,8 @@ static inline void fp_user_discard(void)
 	 * register state to track, if this changes the KVM code will
 	 * need updating.
 	 */
-	if (system_supports_sme() && test_thread_flag(TIF_SME)) {
-		u64 svcr = read_sysreg_s(SYS_SVCR);
-
-		if (svcr & SVCR_SM_MASK)
-			sme_smstop_sm();
-	}
+	if (system_supports_sme())
+		sme_smstop_sm();
 
 	if (!system_supports_sve())
 		return;

---
base-commit: b7bfaa761d760e72a969d116517eaa12e404c262
change-id: 20230110-arm64-sme-syscall-smstop-4d12346f6b68

Best regards,
-- 
Mark Brown <broonie@kernel.org>
Re: [PATCH] arm64/sme: Optimise SME exit on syscall entry
Posted by Catalin Marinas 2 years, 8 months ago
On Tue, 10 Jan 2023 19:34:36 +0000, Mark Brown wrote:
> Our ABI says that we exit streaming mode on syscall entry. Currently we
> check if we are in streaming mode before doing this but since we have a
> SMSTOP SM instruction which will clear SVCR.SM in a single atomic operation
> we can save ourselves the read of the system register and check of the flag
> and just unconditionally do the SMSTOP SM. If we are not in streaming mode
> it results in a noop change to SVCR, if we are in streaming mode we will
> exit as desired.
> 
> [...]

Applied to arm64 (for-next/sme), thanks!

[1/1] arm64/sme: Optimise SME exit on syscall entry
      https://git.kernel.org/arm64/c/b2482807fbd4

-- 
Catalin