Skip to contentSkip to conversation

arm64/signal: Clean up SVE/SME feature checking inconsistency

PATCH Superseded Mark Brown 2 participants 2 messages Jun 24, 2022 arm64

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Mark Brown

author
#0 lore raw

PATCH v2 1/1 arm64/signal: Clean up SVE/SME feature checking inconsistency

Currently when restoring signal state we check to see if SVE is supported in restore_sigframe() but check to see if SVE is supported inside restore_sve_fpsimd_context(). This makes no real difference since SVE is always supported in systems with SME but looks a bit untidy and makes things slightly harder to follow, move the SVE check next to the SME one in restore_sve_fpsimd_context().

---

v2:
- Add a stub restore_sve_fpsimd_context() to hopefully fix an allnoconfig issue, I can't reproduce locally.

 arch/arm64/kernel/signal.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
arch/arm64/kernel/signal.c +11 -8
index b0980fbb6bc7..6b6a79806e82 100644
@@ -280,6 +280,9 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
 
 		vl = task_get_sme_vl(current);
 	} else {
+		if (!system_supports_sve())
+			return -EINVAL;
+
 		vl = task_get_sve_vl(current);
 	}
 
@@ -342,9 +345,13 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
 
 #else /* ! CONFIG_ARM64_SVE */
 
-/* Turn any non-optimised out attempts to use these into a link error: */
+static int restore_sve_fpsimd_context(struct user_ctxs *user)
+{
+	return 0;
+}
+
+/* Turn any non-optimised out attempts to use this into a link error: */
 extern int preserve_sve_context(void __user *ctx);
-extern int restore_sve_fpsimd_context(struct user_ctxs *user);
 
 #endif /* ! CONFIG_ARM64_SVE */
 
@@ -649,14 +656,10 @@ static int restore_sigframe(struct pt_regs *regs,
 		if (!user.fpsimd)
 			return -EINVAL;
 
-		if (user.sve) {
-			if (!system_supports_sve())
-				return -EINVAL;
-
+		if (user.sve)
 			err = restore_sve_fpsimd_context(&user);
-		} else {
+		else
 			err = restore_fpsimd_context(user.fpsimd);
-		}
 	}
 
 	if (err == 0 && system_supports_sme() && user.za)
Signature · 7 lines
2.30.2


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
maintainer
#1 lore raw
Quoted 32 lines · Mark Brown

Currently when restoring signal state we check to see if SVE is supported in restore_sigframe() but check to see if SVE is supported inside restore_sve_fpsimd_context(). This makes no real difference since SVE is always supported in systems with SME but looks a bit untidy and makes things slightly harder to follow, move the SVE check next to the SME one in restore_sve_fpsimd_context().

---

v2:
- Add a stub restore_sve_fpsimd_context() to hopefully fix an allnoconfig issue, I can't reproduce locally.

 arch/arm64/kernel/signal.c | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)
arch/arm64/kernel/signal.c +3 -0
index b0980fbb6bc7..6b6a79806e82 100644
@@ -280,6 +280,9 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
 
 		vl = task_get_sme_vl(current);
 	} else {
+		if (!system_supports_sve())
+			return -EINVAL;
+
 		vl = task_get_sve_vl(current);
 	}
 

arch/arm64/kernel/signal.c static int restore_sve_fpsimd_context(struct user_ctxs *user) · line 351

Quoted 8 lines
arch/arm64/kernel/signal.c +4 -1
@@ -342,9 +345,13 @@ static int restore_sve_fpsimd_context(struct user_ctxs *user)
 
 #else /* ! CONFIG_ARM64_SVE */
 
-/* Turn any non-optimised out attempts to use these into a link error: */
+static int restore_sve_fpsimd_context(struct user_ctxs *user)
+{
+	return 0;
+}

Given that this should never be called, should we return an error instead of 0 (or possibly even WARN/BUG)?

Will

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel