public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/3] selftests: vDSO: chacha: Bugfixes
@ 2025-03-24 14:03 Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 1/3] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-24 14:03 UTC (permalink / raw)
  To: Shuah Khan, Jason A. Donenfeld, Heiko Carstens, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kselftest, linux-kernel, Shuah Khan, Thomas Weißschuh

Bugfixes for a few issues I ran into.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
Thomas Weißschuh (3):
      selftests: vDSO: chacha: Correctly skip test if necessary
      selftests: vDSO: chacha: Include asm/hwcap.h for arm64
      selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS

 tools/testing/selftests/vDSO/vdso_test_chacha.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
---
base-commit: 586de92313fcab8ed84ac5f78f4d2aae2db92c59
change-id: 20250324-s390-vdso-hwcap-0914c0f7c7f1

Best regards,
-- 
Thomas Weißschuh <thomas.weissschuh@linutronix.de>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH 1/3] selftests: vDSO: chacha: Correctly skip test if necessary
  2025-03-24 14:03 [PATCH 0/3] selftests: vDSO: chacha: Bugfixes Thomas Weißschuh
@ 2025-03-24 14:03 ` Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 2/3] selftests: vDSO: chacha: Include asm/hwcap.h for arm64 Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS Thomas Weißschuh
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-24 14:03 UTC (permalink / raw)
  To: Shuah Khan, Jason A. Donenfeld, Heiko Carstens, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kselftest, linux-kernel, Shuah Khan, Thomas Weißschuh

According to kselftest.h ksft_exit_skip() is not meant to be called when
a plan has already been printed.

Use the recommended function ksft_test_result_skip().

This fixes a bug, where the TAP output would be invalid when skipping:

	TAP version 13
	1..1
	ok 2 # SKIP Not implemented on architecture

The SKIP line should start with "ok 1" as the plan only contains one test.

Fixes: 3b5992eaf730 ("selftests: vDSO: unconditionally build chacha test")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>

---
I'm not sure if this is not a general bug in ksft_exit_skip().
First ksft_xskip is incremented then read back through ksft_test_num() and
then that result is incremented again.

In any case, using the correct function is better.
---
 tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
index 8757f738b0b1a76a48c83c5e5df79925a30c1bc7..0aad682b12c8836efabb49a65a47cf87466891a3 100644
--- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
+++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
@@ -76,7 +76,8 @@ static void reference_chacha20_blocks(uint8_t *dst_bytes, const uint32_t *key, u
 
 void __weak __arch_chacha20_blocks_nostack(uint8_t *dst_bytes, const uint32_t *key, uint32_t *counter, size_t nblocks)
 {
-	ksft_exit_skip("Not implemented on architecture\n");
+	ksft_test_result_skip("Not implemented on architecture\n");
+	ksft_finished();
 }
 
 int main(int argc, char *argv[])

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 2/3] selftests: vDSO: chacha: Include asm/hwcap.h for arm64
  2025-03-24 14:03 [PATCH 0/3] selftests: vDSO: chacha: Bugfixes Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 1/3] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
@ 2025-03-24 14:03 ` Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS Thomas Weißschuh
  2 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-24 14:03 UTC (permalink / raw)
  To: Shuah Khan, Jason A. Donenfeld, Heiko Carstens, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kselftest, linux-kernel, Shuah Khan, Thomas Weißschuh

The hwcap constants are not available unconditionally.

Include asm/hwcap.h to make them available.

Not all architectures provide this header, so gate the inclusion behind an
architecture-specific ifdef.

Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/vDSO/vdso_test_chacha.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
index 0aad682b12c8836efabb49a65a47cf87466891a3..fd5c5108b42f04ec459d39b74f33edc2ceafbba1 100644
--- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
+++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
@@ -13,6 +13,7 @@
 #include "../kselftest.h"
 
 #if defined(__aarch64__)
+#include <asm/hwcap.h>
 static bool cpu_has_capabilities(void)
 {
 	return getauxval(AT_HWCAP) & HWCAP_ASIMD;

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS
  2025-03-24 14:03 [PATCH 0/3] selftests: vDSO: chacha: Bugfixes Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 1/3] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
  2025-03-24 14:03 ` [PATCH 2/3] selftests: vDSO: chacha: Include asm/hwcap.h for arm64 Thomas Weißschuh
@ 2025-03-24 14:03 ` Thomas Weißschuh
  2025-03-24 15:55   ` Heiko Carstens
  2 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-24 14:03 UTC (permalink / raw)
  To: Shuah Khan, Jason A. Donenfeld, Heiko Carstens, Andy Lutomirski,
	Thomas Gleixner, Vincenzo Frascino
  Cc: linux-kselftest, linux-kernel, Shuah Khan, Thomas Weißschuh

s390 does not provide a hwcap.h UAPI header.

Add an inline definition for the constant HWCAP_S390_VXRS until a proper
UAPI header is introduced.

Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
---
 tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
index fd5c5108b42f04ec459d39b74f33edc2ceafbba1..0ce5189718ce35b0a4d69b71559db8379b598b93 100644
--- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
+++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
@@ -19,6 +19,9 @@ static bool cpu_has_capabilities(void)
 	return getauxval(AT_HWCAP) & HWCAP_ASIMD;
 }
 #elif defined(__s390x__)
+#ifndef HWCAP_S390_VXRS
+#define HWCAP_S390_VXRS	(1 << 11)
+#endif
 static bool cpu_has_capabilities(void)
 {
 	return getauxval(AT_HWCAP) & HWCAP_S390_VXRS;

-- 
2.48.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS
  2025-03-24 14:03 ` [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS Thomas Weißschuh
@ 2025-03-24 15:55   ` Heiko Carstens
  2025-03-25  6:48     ` Thomas Weißschuh
  0 siblings, 1 reply; 8+ messages in thread
From: Heiko Carstens @ 2025-03-24 15:55 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Shuah Khan, Jason A. Donenfeld, Andy Lutomirski, Thomas Gleixner,
	Vincenzo Frascino, linux-kselftest, linux-kernel, Shuah Khan

On Mon, Mar 24, 2025 at 03:03:17PM +0100, Thomas Weißschuh wrote:
> s390 does not provide a hwcap.h UAPI header.
> 
> Add an inline definition for the constant HWCAP_S390_VXRS until a proper
> UAPI header is introduced.
> 
> Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> ---
>  tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
> index fd5c5108b42f04ec459d39b74f33edc2ceafbba1..0ce5189718ce35b0a4d69b71559db8379b598b93 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
> @@ -19,6 +19,9 @@ static bool cpu_has_capabilities(void)
>  	return getauxval(AT_HWCAP) & HWCAP_ASIMD;
>  }
>  #elif defined(__s390x__)
> +#ifndef HWCAP_S390_VXRS
> +#define HWCAP_S390_VXRS	(1 << 11)
> +#endif
>  static bool cpu_has_capabilities(void)
>  {
>  	return getauxval(AT_HWCAP) & HWCAP_S390_VXRS;

How did this cause a problem?

Did you use something different than glibc(-devel) on your test
system? Just wondering since glibc-devel provides the define since
ages and is also required for getauxval().

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS
  2025-03-24 15:55   ` Heiko Carstens
@ 2025-03-25  6:48     ` Thomas Weißschuh
  2025-03-25  7:18       ` Heiko Carstens
  0 siblings, 1 reply; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-25  6:48 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Shuah Khan, Jason A. Donenfeld, Andy Lutomirski, Thomas Gleixner,
	Vincenzo Frascino, linux-kselftest, linux-kernel, Shuah Khan

On Mon, Mar 24, 2025 at 04:55:13PM +0100, Heiko Carstens wrote:
> On Mon, Mar 24, 2025 at 03:03:17PM +0100, Thomas Weißschuh wrote:
> > s390 does not provide a hwcap.h UAPI header.
> > 
> > Add an inline definition for the constant HWCAP_S390_VXRS until a proper
> > UAPI header is introduced.
> > 
> > Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > ---
> >  tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 +++
> >  1 file changed, 3 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/vDSO/vdso_test_chacha.c b/tools/testing/selftests/vDSO/vdso_test_chacha.c
> > index fd5c5108b42f04ec459d39b74f33edc2ceafbba1..0ce5189718ce35b0a4d69b71559db8379b598b93 100644
> > --- a/tools/testing/selftests/vDSO/vdso_test_chacha.c
> > +++ b/tools/testing/selftests/vDSO/vdso_test_chacha.c
> > @@ -19,6 +19,9 @@ static bool cpu_has_capabilities(void)
> >  	return getauxval(AT_HWCAP) & HWCAP_ASIMD;
> >  }
> >  #elif defined(__s390x__)
> > +#ifndef HWCAP_S390_VXRS
> > +#define HWCAP_S390_VXRS	(1 << 11)
> > +#endif
> >  static bool cpu_has_capabilities(void)
> >  {
> >  	return getauxval(AT_HWCAP) & HWCAP_S390_VXRS;
> 
> How did this cause a problem?
> 
> Did you use something different than glibc(-devel) on your test
> system? Just wondering since glibc-devel provides the define since
> ages and is also required for getauxval().

I used nolibc (from the kernel tree at tools/include/nolibc/) to make cross
platform usage of the tests easier. See also [0].
I got confused by the existence of hwcap.h in the kernel UAPI headers for
various architectures and didn't check the libc headers.
So this isn't really a bug right now, and the hwcap changes will only really be
necessary once my other work goes upstream.

[0] https://lore.kernel.org/lkml/20250217-kunit-kselftests-v1-0-42b4524c3b0a@linutronix.de/

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS
  2025-03-25  6:48     ` Thomas Weißschuh
@ 2025-03-25  7:18       ` Heiko Carstens
  2025-03-25 10:54         ` Thomas Weißschuh
  0 siblings, 1 reply; 8+ messages in thread
From: Heiko Carstens @ 2025-03-25  7:18 UTC (permalink / raw)
  To: Thomas Weißschuh
  Cc: Shuah Khan, Jason A. Donenfeld, Andy Lutomirski, Thomas Gleixner,
	Vincenzo Frascino, linux-kselftest, linux-kernel, Shuah Khan

On Tue, Mar 25, 2025 at 07:48:48AM +0100, Thomas Weißschuh wrote:
> On Mon, Mar 24, 2025 at 04:55:13PM +0100, Heiko Carstens wrote:
> > On Mon, Mar 24, 2025 at 03:03:17PM +0100, Thomas Weißschuh wrote:
> > > s390 does not provide a hwcap.h UAPI header.
> > > 
> > > Add an inline definition for the constant HWCAP_S390_VXRS until a proper
> > > UAPI header is introduced.
> > > 
> > > Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
> > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > > ---
> > >  tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 +++
> > >  1 file changed, 3 insertions(+)

...

> > >  #elif defined(__s390x__)
> > > +#ifndef HWCAP_S390_VXRS
> > > +#define HWCAP_S390_VXRS	(1 << 11)
> > > +#endif
> > >  static bool cpu_has_capabilities(void)
> > >  {
> > >  	return getauxval(AT_HWCAP) & HWCAP_S390_VXRS;
> > 
> > How did this cause a problem?
> > 
> > Did you use something different than glibc(-devel) on your test
> > system? Just wondering since glibc-devel provides the define since
> > ages and is also required for getauxval().
> 
> I used nolibc (from the kernel tree at tools/include/nolibc/) to make cross
> platform usage of the tests easier. See also [0].
> I got confused by the existence of hwcap.h in the kernel UAPI headers for
> various architectures and didn't check the libc headers.
> So this isn't really a bug right now, and the hwcap changes will only really be
> necessary once my other work goes upstream.

Thanks for explaining!

Acked-by: Heiko Carstens <hca@linux.ibm.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS
  2025-03-25  7:18       ` Heiko Carstens
@ 2025-03-25 10:54         ` Thomas Weißschuh
  0 siblings, 0 replies; 8+ messages in thread
From: Thomas Weißschuh @ 2025-03-25 10:54 UTC (permalink / raw)
  To: Heiko Carstens
  Cc: Shuah Khan, Jason A. Donenfeld, Andy Lutomirski, Thomas Gleixner,
	Vincenzo Frascino, linux-kselftest, linux-kernel, Shuah Khan

On Tue, Mar 25, 2025 at 08:18:40AM +0100, Heiko Carstens wrote:
> On Tue, Mar 25, 2025 at 07:48:48AM +0100, Thomas Weißschuh wrote:
> > On Mon, Mar 24, 2025 at 04:55:13PM +0100, Heiko Carstens wrote:
> > > On Mon, Mar 24, 2025 at 03:03:17PM +0100, Thomas Weißschuh wrote:
> > > > s390 does not provide a hwcap.h UAPI header.
> > > > 
> > > > Add an inline definition for the constant HWCAP_S390_VXRS until a proper
> > > > UAPI header is introduced.
> > > > 
> > > > Fixes: 210860e7f733 ("selftests: vDSO: check cpu caps before running chacha test")
> > > > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > > > ---
> > > >  tools/testing/selftests/vDSO/vdso_test_chacha.c | 3 +++
> > > >  1 file changed, 3 insertions(+)
> 
> ...
> 
> > > >  #elif defined(__s390x__)
> > > > +#ifndef HWCAP_S390_VXRS
> > > > +#define HWCAP_S390_VXRS	(1 << 11)
> > > > +#endif
> > > >  static bool cpu_has_capabilities(void)
> > > >  {
> > > >  	return getauxval(AT_HWCAP) & HWCAP_S390_VXRS;
> > > 
> > > How did this cause a problem?
> > > 
> > > Did you use something different than glibc(-devel) on your test
> > > system? Just wondering since glibc-devel provides the define since
> > > ages and is also required for getauxval().
> > 
> > I used nolibc (from the kernel tree at tools/include/nolibc/) to make cross
> > platform usage of the tests easier. See also [0].
> > I got confused by the existence of hwcap.h in the kernel UAPI headers for
> > various architectures and didn't check the libc headers.
> > So this isn't really a bug right now, and the hwcap changes will only really be
> > necessary once my other work goes upstream.
> 
> Thanks for explaining!
> 
> Acked-by: Heiko Carstens <hca@linux.ibm.com>

Thanks!

I'll wait for some more feedback and then resend the series with some better
explanations, and without the incorrect Fixes: tags.
If there is pushback for applying any of the patches now, I'll carry them
downstream and will resubmit them as part of the later series which integrates
more of the vDSO selftests with nolibc.

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-03-25 10:55 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-24 14:03 [PATCH 0/3] selftests: vDSO: chacha: Bugfixes Thomas Weißschuh
2025-03-24 14:03 ` [PATCH 1/3] selftests: vDSO: chacha: Correctly skip test if necessary Thomas Weißschuh
2025-03-24 14:03 ` [PATCH 2/3] selftests: vDSO: chacha: Include asm/hwcap.h for arm64 Thomas Weißschuh
2025-03-24 14:03 ` [PATCH 3/3] selftests: vDSO: chacha: Provide default definition of HWCAP_S390_VXRS Thomas Weißschuh
2025-03-24 15:55   ` Heiko Carstens
2025-03-25  6:48     ` Thomas Weißschuh
2025-03-25  7:18       ` Heiko Carstens
2025-03-25 10:54         ` Thomas Weißschuh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox