[PATCH v6 2/5] riscv: Add hwprobe vdso call support
Evan Green
evan@rivosinc.com
Wed Aug 2 15:59:00 GMT 2023
The new riscv_hwprobe syscall also comes with a vDSO for faster answers
to your most common questions. Call in today to speak with a kernel
representative near you!
Signed-off-by: Evan Green <evan@rivosinc.com>
Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
---
(no changes since v3)
Changes in v3:
- Add the "return" to the vsyscall
- Fix up vdso arg types to match kernel v4 version
- Remove ifdef around INLINE_VSYSCALL (Adhemerval)
Changes in v2:
- Add vDSO interface
sysdeps/unix/sysv/linux/dl-vdso-setup.c | 10 ++++++++++
sysdeps/unix/sysv/linux/dl-vdso-setup.h | 3 +++
sysdeps/unix/sysv/linux/riscv/hwprobe.c | 6 ++++--
sysdeps/unix/sysv/linux/riscv/sysdep.h | 1 +
4 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.c b/sysdeps/unix/sysv/linux/dl-vdso-setup.c
index 97eaaeac37..ed8b1ef426 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso-setup.c
+++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.c
@@ -71,6 +71,16 @@ PROCINFO_CLASS int (*_dl_vdso_clock_getres_time64) (clockid_t,
# ifdef HAVE_GET_TBFREQ
PROCINFO_CLASS uint64_t (*_dl_vdso_get_tbfreq)(void) RELRO;
# endif
+
+/* RISC-V specific ones. */
+# ifdef HAVE_RISCV_HWPROBE
+PROCINFO_CLASS int (*_dl_vdso_riscv_hwprobe)(void *,
+ size_t,
+ size_t,
+ unsigned long *,
+ unsigned int) RELRO;
+# endif
+
#endif
#undef RELRO
diff --git a/sysdeps/unix/sysv/linux/dl-vdso-setup.h b/sysdeps/unix/sysv/linux/dl-vdso-setup.h
index 867072b897..39eafd5316 100644
--- a/sysdeps/unix/sysv/linux/dl-vdso-setup.h
+++ b/sysdeps/unix/sysv/linux/dl-vdso-setup.h
@@ -47,6 +47,9 @@ setup_vdso_pointers (void)
#ifdef HAVE_GET_TBFREQ
GLRO(dl_vdso_get_tbfreq) = dl_vdso_vsym (HAVE_GET_TBFREQ);
#endif
+#ifdef HAVE_RISCV_HWPROBE
+ GLRO(dl_vdso_riscv_hwprobe) = dl_vdso_vsym (HAVE_RISCV_HWPROBE);
+#endif
}
#endif
diff --git a/sysdeps/unix/sysv/linux/riscv/hwprobe.c b/sysdeps/unix/sysv/linux/riscv/hwprobe.c
index 81f24dbc19..57b06c22a5 100644
--- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c
+++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c
@@ -20,11 +20,13 @@
#include <sys/syscall.h>
#include <sys/hwprobe.h>
#include <sysdep.h>
+#include <sysdep-vdso.h>
int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count,
size_t __cpu_count, unsigned long int *__cpus,
unsigned int __flags)
{
- return INLINE_SYSCALL_CALL (riscv_hwprobe, __pairs, __pair_count,
- __cpu_count, __cpus, __flags);
+ /* The vDSO may be able to provide the answer without a syscall. */
+ return INLINE_VSYSCALL(riscv_hwprobe, 5, __pairs, __pair_count,
+ __cpu_count, __cpus, __flags);
}
diff --git a/sysdeps/unix/sysv/linux/riscv/sysdep.h b/sysdeps/unix/sysv/linux/riscv/sysdep.h
index 5583b96d23..ee015dfeb6 100644
--- a/sysdeps/unix/sysv/linux/riscv/sysdep.h
+++ b/sysdeps/unix/sysv/linux/riscv/sysdep.h
@@ -156,6 +156,7 @@
/* List of system calls which are supported as vsyscalls (for RV32 and
RV64). */
# define HAVE_GETCPU_VSYSCALL "__vdso_getcpu"
+# define HAVE_RISCV_HWPROBE "__vdso_riscv_hwprobe"
# undef HAVE_INTERNAL_BRK_ADDR_SYMBOL
# define HAVE_INTERNAL_BRK_ADDR_SYMBOL 1
--
2.34.1
More information about the Libc-alpha
mailing list