Skip to contentSkip to conversation

selftests: vDSO: s390 fixes

PATCH In review Heiko Carstens 2 participants 5 messages Sep 11, 2024

Subsystems (3)
lore
Share & tools
lore

Heiko Carstens

author maintainer
#0 lore raw

cover selftests: vDSO: s390 fixes

Two s390 fixes to make vdso selftests running on s390.

Jason, given that you carry already a lot of changes for vdso selftests I guess these should be routed via the random tree.

Patches apply on top of current random.git master branch.

Thanks,
Heiko

Heiko Carstens (1):
selftests: vDSO: fix vdso_config for s390

Jens Remus (1):
selftests: vDSO: fix ELF hash table entry size for s390x

 tools/testing/selftests/vDSO/parse_vdso.c  | 14 ++++++++++----
 tools/testing/selftests/vDSO/vdso_config.h |  4 ++--
 2 files changed, 12 insertions(+), 6 deletions(-)
Signature · 1 line
2.43.0
author maintainer
#1 lore raw

PATCH 1/2 selftests: vDSO: fix ELF hash table entry size for s390x

From: Jens Remus <[email protected]>

The vDSO self tests fail on s390x for a vDSO linked with the GNU linker ld as follows:

  # ./vdso_test_gettimeofday
  Floating point exception (core dumped)

On s390x the ELF hash table entries are 64 bits instead of 32 bits in size (see Glibc sysdeps/unix/sysv/linux/s390/bits/elfclass.h).

Fixes 40723419f407 ("kselftest: Enable vDSO test on non x86 platforms")
---
 tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
tools/testing/selftests/vDSO/parse_vdso.c +10 -4
index d9ccc5acac18..7dd5668ea8a6 100644
@@ -36,6 +36,12 @@
 #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x)
 #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x)
 
+#ifdef __s390x__
+#define ELF_HASH_ENTRY ELF(Xword)
+#else
+#define ELF_HASH_ENTRY ELF(Word)
+#endif
+
 static struct vdso_info
 {
 	bool valid;
@@ -47,8 +53,8 @@ static struct vdso_info
 	/* Symbol table */
 	ELF(Sym) *symtab;
 	const char *symstrings;
-	ELF(Word) *bucket, *chain;
-	ELF(Word) nbucket, nchain;
+	ELF_HASH_ENTRY *bucket, *chain;
+	ELF_HASH_ENTRY nbucket, nchain;
 
 	/* Version table */
 	ELF(Versym) *versym;
@@ -115,7 +121,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
 	/*
 	 * Fish out the useful bits of the dynamic table.
 	 */
-	ELF(Word) *hash = 0;
+	ELF_HASH_ENTRY *hash = 0;
 	vdso_info.symstrings = 0;
 	vdso_info.symtab = 0;
 	vdso_info.versym = 0;
@@ -133,7 +139,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base)
 				 + vdso_info.load_offset);
 			break;
 		case DT_HASH:
-			hash = (ELF(Word) *)
+			hash = (ELF_HASH_ENTRY *)
 				((uintptr_t)dyn[i].d_un.d_ptr
 				 + vdso_info.load_offset);
 			break;
Signature · 1 line
2.43.0
author maintainer
#2 lore raw

PATCH 2/2 selftests: vDSO: fix vdso_config for s390

In reply to Heiko Carstens

Running vdso_test_correctness on s390x (aka s390 64 bit) emits a warning:

Warning: failed to find clock_gettime64 in vDSO

This is caused by the "#elif defined (__s390__)" check in vdso_config.h which the defines VDSO_32BIT.

If __s390x__ is defined also __s390__ is defined. Therefore the correct check must make sure that only __s390__ is defined.

Therefore add the missing !defined(__s390x__). Also use common __s390x__ define instead of __s390X__.

---
 tools/testing/selftests/vDSO/vdso_config.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
tools/testing/selftests/vDSO/vdso_config.h +2 -2
index 740ce8c98d2e..722260f97561 100644
@@ -25,11 +25,11 @@
 #define VDSO_VERSION		1
 #define VDSO_NAMES		0
 #define VDSO_32BIT		1
-#elif defined (__s390__)
+#elif defined (__s390__) && !defined(__s390x__)
 #define VDSO_VERSION		2
 #define VDSO_NAMES		0
 #define VDSO_32BIT		1
-#elif defined (__s390X__)
+#elif defined (__s390x__)
 #define VDSO_VERSION		2
 #define VDSO_NAMES		0
 #elif defined(__mips__)
Signature · 1 line
2.43.0
#3 lore raw

Re: [PATCH 2/2] selftests: vDSO: fix vdso_config for s390

Quoted 7 lines · Heiko Carstens

Running vdso_test_correctness on s390x (aka s390 64 bit) emits a warning:

Warning: failed to find clock_gettime64 in vDSO

This is caused by the "#elif defined (__s390__)" check in vdso_config.h which the defines VDSO_32BIT.

Quoted 7 lines

If __s390x__ is defined also __s390__ is defined. Therefore the correct check must make sure that only __s390__ is defined.

Therefore add the missing !defined(__s390x__). Also use common __s390x__ define instead of __s390X__.

I'll add to it:

Fixes 693f5ca08ca0 ("kselftest: Extend vDSO selftest")
#4 lore raw
In reply to Heiko Carstens
Quoted 6 lines · Heiko Carstens

Two s390 fixes to make vdso selftests running on s390.

Jason, given that you carry already a lot of changes for vdso selftests I guess these should be routed via the random tree.

Patches apply on top of current random.git master branch.

Sure, I'll apply these. Thanks for the patches. (And I'm looking forward to seeing what might have motivated you to notice these bugs :-).)

Jason