public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Evan Green <evan@rivosinc.com>
To: libc-alpha@sourceware.org
Cc: Florian Weimer <fweimer@redhat.com>,
	palmer@rivosinc.com, vineetg@rivosinc.com, slewis@rivosinc.com,
	Evan Green <evan@rivosinc.com>
Subject: [PATCH v9 2/6] riscv: Add hwprobe vdso call support
Date: Thu, 30 Nov 2023 10:32:35 -0800	[thread overview]
Message-ID: <20231130183239.598100-3-evan@rivosinc.com> (raw)
In-Reply-To: <20231130183239.598100-1-evan@rivosinc.com>

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 v7)

Changes in v7:
 - Use INTERNAL_VSYSCALL_CALL (Florian)

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 | 17 ++++++++++++++---
 sysdeps/unix/sysv/linux/riscv/sysdep.h  |  1 +
 4 files changed, 28 insertions(+), 3 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 e28194e344..6a9a44657f 100644
--- a/sysdeps/unix/sysv/linux/riscv/hwprobe.c
+++ b/sysdeps/unix/sysv/linux/riscv/hwprobe.c
@@ -27,9 +27,20 @@ int __riscv_hwprobe (struct riscv_hwprobe *__pairs, size_t __pair_count,
 		     unsigned int __flags)
 {
   int r;
-
-  r = INTERNAL_SYSCALL_CALL (riscv_hwprobe, 5, __pairs, __pair_count,
-                             __cpu_count, __cpus, __flags);
+  __riscv_hwprobe_t vdso_hwprobe =
+    (__riscv_hwprobe_t)GLRO(dl_vdso_riscv_hwprobe);
+
+  if (vdso_hwprobe != NULL)
+    {
+      r = INTERNAL_VSYSCALL_CALL (vdso_hwprobe, 5, __pairs, __pair_count,
+                                  __cpu_count, __cpus, __flags);
+    }
+  else
+    {
+      r = INTERNAL_SYSCALL_CALL (riscv_hwprobe, 5, __pairs, __pair_count,
+                                 __cpu_count, __cpus, __flags);
+
+    }
 
   /* Negate negative errno values to match pthreads API. */
   return -r;
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


  parent reply	other threads:[~2023-11-30 18:32 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-30 18:32 [PATCH v9 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Evan Green
2023-11-30 18:32 ` [PATCH v9 1/6] riscv: Add Linux hwprobe syscall support Evan Green
2023-12-06 17:22   ` Adhemerval Zanella Netto
2023-12-06 17:24     ` Adhemerval Zanella Netto
2023-11-30 18:32 ` Evan Green [this message]
2023-12-06 17:34   ` [PATCH v9 2/6] riscv: Add hwprobe vdso call support Adhemerval Zanella Netto
2023-12-11 21:02     ` Evan Green
2023-11-30 18:32 ` [PATCH v9 3/6] riscv: Add __riscv_hwprobe pointer to ifunc calls Evan Green
2023-12-06  0:31   ` enh
2023-11-30 18:32 ` [PATCH v9 4/6] riscv: Enable multi-arg ifunc resolvers Evan Green
2023-11-30 18:32 ` [PATCH v9 5/6] riscv: Add ifunc helper method to hwprobe.h Evan Green
2023-12-06 17:39   ` Adhemerval Zanella Netto
2023-12-06 18:17   ` enh
2023-12-06 19:42     ` Palmer Dabbelt
2023-12-07  9:46     ` Florian Weimer
2023-12-07 16:32       ` enh
2023-12-07 16:47         ` Florian Weimer
2023-12-07 17:09           ` enh
2023-11-30 18:32 ` [PATCH v9 6/6] riscv: Add and use alignment-ignorant memcpy Evan Green
2023-12-06 17:07 ` [PATCH v9 0/6] RISC-V: ifunced memcpy using new kernel hwprobe interface Palmer Dabbelt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231130183239.598100-3-evan@rivosinc.com \
    --to=evan@rivosinc.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=palmer@rivosinc.com \
    --cc=slewis@rivosinc.com \
    --cc=vineetg@rivosinc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).