[v2,03/18] RISC-V: Add support for 32-bit vDSO calls

Message ID 02bea72edffeb116ab4d139d1e14b89d1f58c7ce.1591201405.git.alistair.francis@wdc.com
State Committed
Headers
Series glibc port for 32-bit RISC-V (RV32) |

Commit Message

Alistair Francis June 3, 2020, 4:25 p.m. UTC
  ---
 sysdeps/unix/sysv/linux/riscv/sysdep.h | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)
  

Comments

Maciej W. Rozycki July 8, 2020, 1:01 a.m. UTC | #1
On Wed, 3 Jun 2020, Alistair Francis via Libc-alpha wrote:

> diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> index aa61e8b04d..9f6ed2001b 100644
> --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
> +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> @@ -182,14 +182,21 @@
>  
>  #ifndef __ASSEMBLER__
>  
> -# define VDSO_NAME  "LINUX_4.15"
> -# define VDSO_HASH  182943605
> +# if __riscv_xlen == 32

 Same note on __riscv_xlen vs __WORDSIZE as with 02/18.

 Also given it is a two-way conditional we can choose which leg is first 
and I'd make that the RV64 variant, as the first to be there and more 
developed, as evident here.

>  /* List of system calls which are supported as vsyscalls.  */
> -# define HAVE_CLOCK_GETRES64_VSYSCALL	"__vdso_clock_getres"
> -# define HAVE_CLOCK_GETTIME64_VSYSCALL	"__vdso_clock_gettime"
> -# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
> -# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
> +# else
> +#  define VDSO_NAME  "LINUX_4.15"
> +#  define VDSO_HASH  182943605
> +
> +/* List of system calls which are supported as vsyscalls.  */
> +#  define HAVE_CLOCK_GETRES64_VSYSCALL   "__vdso_clock_getres"
> +#  define HAVE_CLOCK_GETTIME64_VSYSCALL  "__vdso_clock_gettime"
> +#  define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
> +#  define HAVE_GETCPU_VSYSCALL           "__vdso_getcpu"
> +# endif

 Also "__vdso_getcpu" does get exported unlike the time calls with RV32 
AFAICT:

# Symbols present in the vdso
vdso-syms  = rt_sigreturn
ifdef CONFIG_64BIT
vdso-syms += vgettimeofday
endif
vdso-syms += getcpu
vdso-syms += flush_icache

so it should be included (and placed outside the conditional, unlike with 
an earlier version of this change).  Then the change description (and 
preferably a comment as well) ought to explain why the remaining ones have 
been left out for RV32.

  Maciej
  
Alistair Francis July 8, 2020, 6:17 p.m. UTC | #2
On Tue, Jul 7, 2020 at 6:02 PM Maciej W. Rozycki via Libc-alpha
<libc-alpha@sourceware.org> wrote:
>
> On Wed, 3 Jun 2020, Alistair Francis via Libc-alpha wrote:
>
> > diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> > index aa61e8b04d..9f6ed2001b 100644
> > --- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
> > +++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
> > @@ -182,14 +182,21 @@
> >
> >  #ifndef __ASSEMBLER__
> >
> > -# define VDSO_NAME  "LINUX_4.15"
> > -# define VDSO_HASH  182943605
> > +# if __riscv_xlen == 32
>
>  Same note on __riscv_xlen vs __WORDSIZE as with 02/18.

Fixed

>
>  Also given it is a two-way conditional we can choose which leg is first
> and I'd make that the RV64 variant, as the first to be there and more
> developed, as evident here.

Fixed.

>
> >  /* List of system calls which are supported as vsyscalls.  */
> > -# define HAVE_CLOCK_GETRES64_VSYSCALL        "__vdso_clock_getres"
> > -# define HAVE_CLOCK_GETTIME64_VSYSCALL       "__vdso_clock_gettime"
> > -# define HAVE_GETTIMEOFDAY_VSYSCALL  "__vdso_gettimeofday"
> > -# define HAVE_GETCPU_VSYSCALL                "__vdso_getcpu"
> > +# else
> > +#  define VDSO_NAME  "LINUX_4.15"
> > +#  define VDSO_HASH  182943605
> > +
> > +/* List of system calls which are supported as vsyscalls.  */
> > +#  define HAVE_CLOCK_GETRES64_VSYSCALL   "__vdso_clock_getres"
> > +#  define HAVE_CLOCK_GETTIME64_VSYSCALL  "__vdso_clock_gettime"
> > +#  define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
> > +#  define HAVE_GETCPU_VSYSCALL           "__vdso_getcpu"
> > +# endif
>
>  Also "__vdso_getcpu" does get exported unlike the time calls with RV32
> AFAICT:
>
> # Symbols present in the vdso
> vdso-syms  = rt_sigreturn
> ifdef CONFIG_64BIT
> vdso-syms += vgettimeofday
> endif
> vdso-syms += getcpu
> vdso-syms += flush_icache
>
> so it should be included (and placed outside the conditional, unlike with
> an earlier version of this change).  Then the change description (and
> preferably a comment as well) ought to explain why the remaining ones have
> been left out for RV32.

Ok, I have fixed this as well.

Alistair

>
>   Maciej
  

Patch

diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index aa61e8b04d..9f6ed2001b 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -182,14 +182,21 @@ 
 
 #ifndef __ASSEMBLER__
 
-# define VDSO_NAME  "LINUX_4.15"
-# define VDSO_HASH  182943605
+# if __riscv_xlen == 32
+#  define VDSO_NAME  "LINUX_5.4"
+#  define VDSO_HASH  61765876
 
 /* List of system calls which are supported as vsyscalls.  */
-# define HAVE_CLOCK_GETRES64_VSYSCALL	"__vdso_clock_getres"
-# define HAVE_CLOCK_GETTIME64_VSYSCALL	"__vdso_clock_gettime"
-# define HAVE_GETTIMEOFDAY_VSYSCALL	"__vdso_gettimeofday"
-# define HAVE_GETCPU_VSYSCALL		"__vdso_getcpu"
+# else
+#  define VDSO_NAME  "LINUX_4.15"
+#  define VDSO_HASH  182943605
+
+/* List of system calls which are supported as vsyscalls.  */
+#  define HAVE_CLOCK_GETRES64_VSYSCALL   "__vdso_clock_getres"
+#  define HAVE_CLOCK_GETTIME64_VSYSCALL  "__vdso_clock_gettime"
+#  define HAVE_GETTIMEOFDAY_VSYSCALL     "__vdso_gettimeofday"
+#  define HAVE_GETCPU_VSYSCALL           "__vdso_getcpu"
+# endif
 
 # define INTERNAL_SYSCALL(name, nr, args...) \
 	internal_syscall##nr (SYS_ify (name), args)