diff --git a/elf/Makefile b/elf/Makefile
index 396ec51424..f00061852b 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -2620,7 +2620,7 @@ $(objpfx)argv0test.out: tst-rtld-argv0.sh $(objpfx)ld.so \
 # glibc-hwcaps mechanism for this architecture).  Used to obtain test
 # coverage for some glibc-hwcaps tests for the widest possible range
 # of systems.
-glibc-hwcaps-first-subdirs-for-tests = power9 x86-64-v2 z13
+glibc-hwcaps-first-subdirs-for-tests = power9 x86-64-v2 z13 rv-v1
 
 # The test modules are parameterized by preprocessor macros.
 LDFLAGS-libmarkermod1-1.so += -Wl,-soname,libmarkermod1.so
diff --git a/elf/tst-glibc-hwcaps-cache.script b/elf/tst-glibc-hwcaps-cache.script
index d58fc8c5de..ea3d0186c9 100644
--- a/elf/tst-glibc-hwcaps-cache.script
+++ b/elf/tst-glibc-hwcaps-cache.script
@@ -36,3 +36,6 @@ mkdirp 0770 $L/glibc-hwcaps/x86-64-v4
 cp $B/elf/libmarkermod4-2.so $L/glibc-hwcaps/x86-64-v2/libmarkermod4.so
 cp $B/elf/libmarkermod4-3.so $L/glibc-hwcaps/x86-64-v3/libmarkermod4.so
 cp $B/elf/libmarkermod4-4.so $L/glibc-hwcaps/x86-64-v4/libmarkermod4.so
+
+mkdirp 0770 $L/glibc-hwcaps/rv64-v1
+cp $B/elf/libmarkermod2-2.so $L/glibc-hwcaps/rv64-v1/libmarkermod2.so
diff --git a/sysdeps/riscv/rv64/Makefile b/sysdeps/riscv/rv64/Makefile
new file mode 100644
index 0000000000..15658ba26e
--- /dev/null
+++ b/sysdeps/riscv/rv64/Makefile
@@ -0,0 +1,21 @@
+
+ifeq ($(subdir),elf)
+
+$(objpfx)tst-glibc-hwcaps: \
+  $(objpfx)libmarkermod2-1.so
+
+$(objpfx)tst-glibc-hwcaps.out: \
+  $(objpfx)libmarkermod2.so \
+    $(objpfx)glibc-hwcaps/rv64-v1/libmarkermod2.so \
+
+$(objpfx)glibc-hwcaps/rv64-v1/libmarkermod2.so: $(objpfx)libmarkermod2-2.so
+	$(make-target-directory)
+	cp $< $@
+
+ifeq (no,$(build-hardcoded-path-in-tests))
+# This is an ld.so.cache test, and RPATH/RUNPATH in the executable
+# interferes with its test objectives.
+tests-container += tst-glibc-hwcaps-cache
+endif
+
+endif # $(subdir) == elf
diff --git a/sysdeps/riscv/rv64/dl-hwcaps-subdirs.c b/sysdeps/riscv/rv64/dl-hwcaps-subdirs.c
new file mode 100644
index 0000000000..2845e97eff
--- /dev/null
+++ b/sysdeps/riscv/rv64/dl-hwcaps-subdirs.c
@@ -0,0 +1,49 @@
+/* Architecture-specific glibc-hwcaps subdirectories.  RISC-V version.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <dl-hwcaps.h>
+#include <ldsodefs.h>
+#include <sys/hwprobe.h>
+
+const char _dl_hwcaps_subdirs[] = "rv64-v1";
+enum { subdirs_count = 1 }; /* Number of components in _dl_hwcaps_subdirs.  */
+
+uint32_t
+_dl_hwcaps_subdirs_active (void)
+{
+  int active = 0;
+  unsigned long int mask;
+  struct riscv_hwprobe pair[2];
+
+  /* Test in reverse preference order. */
+  /* v1: RV64GC_Zba_Zbb */
+  pair[0].key = RISCV_HWPROBE_KEY_BASE_BEHAVIOR;
+  pair[1].key = RISCV_HWPROBE_KEY_IMA_EXT_0;
+  if (__riscv_hwprobe(pair, 2, 0, NULL, 0) != 0)
+    return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
+
+  mask = RISCV_HWPROBE_IMA_FD | RISCV_HWPROBE_IMA_C |
+         RISCV_HWPROBE_EXT_ZBA | RISCV_HWPROBE_EXT_ZBB;
+
+  if (!(pair[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA) ||
+      ((pair[1].value & mask) != mask))
+    return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
+  ++active;
+
+  return _dl_hwcaps_subdirs_build_bitmask (subdirs_count, active);
+}
diff --git a/sysdeps/riscv/rv64/tst-glibc-hwcaps.c b/sysdeps/riscv/rv64/tst-glibc-hwcaps.c
new file mode 100644
index 0000000000..988d3492ef
--- /dev/null
+++ b/sysdeps/riscv/rv64/tst-glibc-hwcaps.c
@@ -0,0 +1,58 @@
+/* glibc-hwcaps subdirectory test.  RISC-V 64-bit version.
+   Copyright (C) 2023 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <https://www.gnu.org/licenses/>.  */
+
+#include <stdio.h>
+#include <string.h>
+#include <support/check.h>
+#include <sys/hwprobe.h>
+#include <sys/param.h>
+
+extern int marker2 (void);
+
+/* Return the arch level, 10 for the baseline libmarkermod*.so's.  */
+static int
+compute_level (void)
+{
+  struct riscv_hwprobe pair[2];
+  unsigned long int mask;
+
+  pair[0].key = RISCV_HWPROBE_KEY_BASE_BEHAVIOR;
+  pair[1].key = RISCV_HWPROBE_KEY_IMA_EXT_0;
+  if (__riscv_hwprobe(pair, 2, 0, NULL, 0) != 0)
+    return 10;
+
+  mask = RISCV_HWPROBE_IMA_FD | RISCV_HWPROBE_IMA_C |
+         RISCV_HWPROBE_EXT_ZBA | RISCV_HWPROBE_EXT_ZBB;
+
+  if (!(pair[0].value & RISCV_HWPROBE_BASE_BEHAVIOR_IMA) ||
+      ((pair[1].value & mask) != mask))
+    return 10;
+
+  return 11;
+}
+
+static int
+do_test (void)
+{
+  int level = compute_level ();
+  printf ("info: detected architecture level: arch%d\n", level);
+  TEST_COMPARE (marker2 (), MIN (level - 9, 2));
+  return 0;
+}
+
+#include <support/test-driver.c>
diff --git a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h
index 49e27ee855..030939c0c6 100644
--- a/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h
+++ b/sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h
@@ -46,6 +46,8 @@ struct riscv_hwprobe {
 #define RISCV_HWPROBE_KEY_IMA_EXT_0	4
 #define		RISCV_HWPROBE_IMA_FD		(1 << 0)
 #define		RISCV_HWPROBE_IMA_C		(1 << 1)
+#define		RISCV_HWPROBE_EXT_ZBA		(1 << 2)
+#define		RISCV_HWPROBE_EXT_ZBB		(1 << 3)
 #define RISCV_HWPROBE_KEY_CPUPERF_0	5
 #define		RISCV_HWPROBE_MISALIGNED_UNKNOWN	(0 << 0)
 #define		RISCV_HWPROBE_MISALIGNED_EMULATED	(1 << 0)
