Message ID | 20200404203704.69412-2-svens@linux.ibm.com (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | [1/2] selftests/vDSO: prevent SIGFPE if vdso_info.nbucket is zero | expand |
On Sat, Apr 04, 2020 at 10:37:04PM +0200, Sven Schnelle wrote: > s390x used 8 byte (Elf64_Xword) sized hash table entries. > Add some code to the vdso test to handle that properly. Ping? > Signed-off-by: Sven Schnelle <svens@linux.ibm.com> > --- > tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- > tools/testing/selftests/vDSO/vdso_test.c | 11 +++++++---- > 2 files changed, 17 insertions(+), 8 deletions(-) > > diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c > index 8e5a70a24d9a..2e1e88ebee3d 100644 > --- a/tools/testing/selftests/vDSO/parse_vdso.c > +++ b/tools/testing/selftests/vDSO/parse_vdso.c > @@ -58,6 +58,12 @@ extern void *vdso_sym(const char *version, const char *name); > #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x) > #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) > > +#if defined(__s390x__) > +#define ELF_HASH_TYPE ELF(Xword) > +#else > +#define ELF_HASH_TYPE ELF(Word) > +#endif > + > static struct vdso_info > { > bool valid; > @@ -69,8 +75,8 @@ static struct vdso_info > /* Symbol table */ > ELF(Sym) *symtab; > const char *symstrings; > - ELF(Word) *bucket, *chain; > - ELF(Word) nbucket, nchain; > + ELF_HASH_TYPE *bucket, *chain; > + ELF_HASH_TYPE nbucket, nchain; > > /* Version table */ > ELF(Versym) *versym; > @@ -131,7 +137,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_TYPE *hash = 0; > vdso_info.symstrings = 0; > vdso_info.symtab = 0; > vdso_info.versym = 0; > @@ -149,7 +155,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) > + vdso_info.load_offset); > break; > case DT_HASH: > - hash = (ELF(Word) *) > + hash = (ELF_HASH_TYPE *) > ((uintptr_t)dyn[i].d_un.d_ptr > + vdso_info.load_offset); > break; > diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c > index 719d5a6bd664..2b21261a5eba 100644 > --- a/tools/testing/selftests/vDSO/vdso_test.c > +++ b/tools/testing/selftests/vDSO/vdso_test.c > @@ -22,11 +22,14 @@ extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); > extern void vdso_init_from_auxv(void *auxv); > > /* > - * ARM64's vDSO exports its gettimeofday() implementation with a different > - * name and version from other architectures, so we need to handle it as > - * a special case. > + * Both ARM64's and s390x' vDSO exports its gettimeofday() implementation > + * with a different name and version from other architectures, so we need > + * to handle them as a special case. > */ > -#if defined(__aarch64__) > +#if defined(__s390x__) > +const char *version = "LINUX_2.6.29"; > +const char *name = "__kernel_gettimeofday"; > +#elif defined(__aarch64__) > const char *version = "LINUX_2.6.39"; > const char *name = "__kernel_gettimeofday"; > #else > -- > 2.17.1 >
diff --git a/tools/testing/selftests/vDSO/parse_vdso.c b/tools/testing/selftests/vDSO/parse_vdso.c index 8e5a70a24d9a..2e1e88ebee3d 100644 --- a/tools/testing/selftests/vDSO/parse_vdso.c +++ b/tools/testing/selftests/vDSO/parse_vdso.c @@ -58,6 +58,12 @@ extern void *vdso_sym(const char *version, const char *name); #define ELF_BITS_XFORM(bits, x) ELF_BITS_XFORM2(bits, x) #define ELF(x) ELF_BITS_XFORM(ELF_BITS, x) +#if defined(__s390x__) +#define ELF_HASH_TYPE ELF(Xword) +#else +#define ELF_HASH_TYPE ELF(Word) +#endif + static struct vdso_info { bool valid; @@ -69,8 +75,8 @@ static struct vdso_info /* Symbol table */ ELF(Sym) *symtab; const char *symstrings; - ELF(Word) *bucket, *chain; - ELF(Word) nbucket, nchain; + ELF_HASH_TYPE *bucket, *chain; + ELF_HASH_TYPE nbucket, nchain; /* Version table */ ELF(Versym) *versym; @@ -131,7 +137,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_TYPE *hash = 0; vdso_info.symstrings = 0; vdso_info.symtab = 0; vdso_info.versym = 0; @@ -149,7 +155,7 @@ void vdso_init_from_sysinfo_ehdr(uintptr_t base) + vdso_info.load_offset); break; case DT_HASH: - hash = (ELF(Word) *) + hash = (ELF_HASH_TYPE *) ((uintptr_t)dyn[i].d_un.d_ptr + vdso_info.load_offset); break; diff --git a/tools/testing/selftests/vDSO/vdso_test.c b/tools/testing/selftests/vDSO/vdso_test.c index 719d5a6bd664..2b21261a5eba 100644 --- a/tools/testing/selftests/vDSO/vdso_test.c +++ b/tools/testing/selftests/vDSO/vdso_test.c @@ -22,11 +22,14 @@ extern void vdso_init_from_sysinfo_ehdr(uintptr_t base); extern void vdso_init_from_auxv(void *auxv); /* - * ARM64's vDSO exports its gettimeofday() implementation with a different - * name and version from other architectures, so we need to handle it as - * a special case. + * Both ARM64's and s390x' vDSO exports its gettimeofday() implementation + * with a different name and version from other architectures, so we need + * to handle them as a special case. */ -#if defined(__aarch64__) +#if defined(__s390x__) +const char *version = "LINUX_2.6.29"; +const char *name = "__kernel_gettimeofday"; +#elif defined(__aarch64__) const char *version = "LINUX_2.6.39"; const char *name = "__kernel_gettimeofday"; #else
s390x used 8 byte (Elf64_Xword) sized hash table entries. Add some code to the vdso test to handle that properly. Signed-off-by: Sven Schnelle <svens@linux.ibm.com> --- tools/testing/selftests/vDSO/parse_vdso.c | 14 ++++++++++---- tools/testing/selftests/vDSO/vdso_test.c | 11 +++++++---- 2 files changed, 17 insertions(+), 8 deletions(-)