[PATCH v3 3/3] kselftest/arm64: Add lsfe to the hwcaps test

Mark Brown posted 3 patches 1 month, 2 weeks ago
There is a newer version of this series
[PATCH v3 3/3] kselftest/arm64: Add lsfe to the hwcaps test
Posted by Mark Brown 1 month, 2 weeks ago
This feature has no traps associated with it so the SIGILL is not reliable.

Signed-off-by: Mark Brown <broonie@kernel.org>
---
 tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
index 002ec38a8bbb..941890f69df6 100644
--- a/tools/testing/selftests/arm64/abi/hwcap.c
+++ b/tools/testing/selftests/arm64/abi/hwcap.c
@@ -17,6 +17,8 @@
 #include <asm/sigcontext.h>
 #include <asm/unistd.h>
 
+#include <linux/auxvec.h>
+
 #include "../../kselftest.h"
 
 #define TESTS_PER_HWCAP 3
@@ -169,6 +171,18 @@ static void lse128_sigill(void)
 		     : "cc", "memory");
 }
 
+static void lsfe_sigill(void)
+{
+	float __attribute__ ((aligned (16))) mem = 0;
+	register float *memp asm ("x0") = &mem;
+
+	/* LDFADD H0, H0, [X0] */
+	asm volatile(".inst 0x7c200000"
+		     : "+r" (memp)
+		     :
+		     : "cc", "memory");
+}
+
 static void lut_sigill(void)
 {
 	/* LUTI2 V0.16B, { V0.16B }, V[0] */
@@ -762,6 +776,13 @@ static const struct hwcap_data {
 		.cpuinfo = "lse128",
 		.sigill_fn = lse128_sigill,
 	},
+	{
+		.name = "LSFE",
+		.at_hwcap = AT_HWCAP3,
+		.hwcap_bit = HWCAP3_LSFE,
+		.cpuinfo = "lsfe",
+		.sigill_fn = lsfe_sigill,
+	},
 	{
 		.name = "LUT",
 		.at_hwcap = AT_HWCAP2,

-- 
2.39.5
Re: [PATCH v3 3/3] kselftest/arm64: Add lsfe to the hwcaps test
Posted by Will Deacon 2 weeks, 3 days ago
On Mon, Aug 18, 2025 at 08:21:20PM +0100, Mark Brown wrote:
> This feature has no traps associated with it so the SIGILL is not reliable.
> 
> Signed-off-by: Mark Brown <broonie@kernel.org>
> ---
>  tools/testing/selftests/arm64/abi/hwcap.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
> 
> diff --git a/tools/testing/selftests/arm64/abi/hwcap.c b/tools/testing/selftests/arm64/abi/hwcap.c
> index 002ec38a8bbb..941890f69df6 100644
> --- a/tools/testing/selftests/arm64/abi/hwcap.c
> +++ b/tools/testing/selftests/arm64/abi/hwcap.c
> @@ -17,6 +17,8 @@
>  #include <asm/sigcontext.h>
>  #include <asm/unistd.h>
>  
> +#include <linux/auxvec.h>
> +
>  #include "../../kselftest.h"
>  
>  #define TESTS_PER_HWCAP 3
> @@ -169,6 +171,18 @@ static void lse128_sigill(void)
>  		     : "cc", "memory");
>  }
>  
> +static void lsfe_sigill(void)
> +{
> +	float __attribute__ ((aligned (16))) mem = 0;
> +	register float *memp asm ("x0") = &mem;
> +
> +	/* LDFADD H0, H0, [X0] */
> +	asm volatile(".inst 0x7c200000"
> +		     : "+r" (memp)

Doesn't this corrupt H0 without the compiler knowing? It's probably
easier to use STFADD.

> +		     :
> +		     : "cc", "memory");

Why do you need the "cc" clobber?

Will
Re: [PATCH v3 3/3] kselftest/arm64: Add lsfe to the hwcaps test
Posted by Mark Brown 2 weeks, 3 days ago
On Tue, Sep 16, 2025 at 10:16:11PM +0100, Will Deacon wrote:
> On Mon, Aug 18, 2025 at 08:21:20PM +0100, Mark Brown wrote:

> > +	/* LDFADD H0, H0, [X0] */
> > +	asm volatile(".inst 0x7c200000"
> > +		     : "+r" (memp)

> Doesn't this corrupt H0 without the compiler knowing? It's probably
> easier to use STFADD.

Yeah, that's more correct and easier than specifying constraints.  In
practice it should be safe as the compiler is unlikely to use FP in the
instructions it generates and it's a caller saved register.  The program
is in general not careful with constraints.

> > +		     :
> > +		     : "cc", "memory");

> Why do you need the "cc" clobber?

It's overkill.