[PATCH v5 0/1] riscv: Add RVV memset for both multiarch and non-multiarch builds

Yao Zihong zihong.plct@isrc.iscas.ac.cn
Thu Dec 11 15:33:41 GMT 2025


Changes since v4:
  * Renamed `memset_vector` to `memset-vector` for consistency. (Peter Bergner)
  * Moved the RVV implementation into `sysdeps/riscv/rvv/` and added
    multiarch wrappers that include it, enabling RVV memset for both
    multiarch and non-multiarch builds as requested. (Peter Bergner)
  * Dropped the `memcpy` redirection, since it does not belong to this
    patch and will be handled separately. (Peter Bergner)

Changes since v3:
  * Clarified commit message to describe the SIGILL consequence when RVV is
    disabled via prctl(). (Darius Rad)

Change since v2:
  * Removed unnecessary `#include` and fixed minor spacing issues.
  * Fixed commit message wording and added a note describing the resolver
    behavior when the RVV extension is disabled via prctl(). (Darius Rad)
  * Folded the two hwprobe calls into a single call by probing both
    CPUPERF_0 and IMA_EXT_0 together. (Vineet Gupta)

Change since v1:
  * Fixed typos and comment wording. (Peter Bergner)

---

Hi all,

This patch wires up an RVV implementation of `memset` for both multiarch (IFUNC)
and non-multiarch RISC-V builds.

It serves as a minimal pilot for integrating Hau Hsu's 2023 RVV work
under a unified ifunc-based framework. Once validated, this approach can
be extended to the rest of the string/memory routines.

---

Background
----------
The original RVV implementations were proposed by Hau Hsu in [1].

My earlier patch series attempted to integrate Hau's work for the entire
str*/mem* family under a unified multiarch/IFUNC framework.

Jeff Law later suggested narrowing the scope to a single function to
validate the integration model. He also identified a hang issue in my
earlier version and provided a corrective patch introducing a redirect
header to fix it [2]. This series follows that approach.

There was also a discussion regarding the use of dl_hwcap as the runtime
indicator in the v2 patch [3][4]. The case where the RVV extension is
disabled via prctl() is considered very rare, and reviewers agreed it
should not block progress on this series. Meanwhile, we are coordinating
with the kernel side to address this more properly.

---

Testing
-------
Testing was conducted on MUSE-Pi (SpacemiT M1). The glibc testsuite passed
without any additional regressions compared with glibc master when the RVV
extension was not disabled via prctl().

Summary of test results for(MUSE-Pi):
    UNSUPPORTED: elf/tst-env-setuid
    XPASS: elf/tst-protected1a
    XPASS: elf/tst-protected1b
    UNSUPPORTED: elf/tst-valgrind-smoke
    UNSUPPORTED: io/tst-faccessat-setuid
    UNSUPPORTED: libio/tst-fopen-compat
    UNSUPPORTED: math/test-ceil-except-2
    UNSUPPORTED: math/test-fesetexcept-traps
    UNSUPPORTED: math/test-fexcept-traps
    UNSUPPORTED: math/test-floor-except-2
    UNSUPPORTED: math/test-nearbyint-except-2
    UNSUPPORTED: math/test-trunc-except-2
    UNSUPPORTED: misc/tst-adjtimex
    UNSUPPORTED: misc/tst-clock_adjtime
    UNSUPPORTED: misc/tst-epoll-ioctls
    FAIL: misc/tst-gethostid
    UNSUPPORTED: misc/tst-mseal
    UNSUPPORTED: misc/tst-mseal-pkey
    UNSUPPORTED: misc/tst-ntp_adjtime
    UNSUPPORTED: misc/tst-pidfd_getinfo
    UNSUPPORTED: misc/tst-pkey
    UNSUPPORTED: nptl/test-cond-printers
    UNSUPPORTED: nptl/test-condattr-printers
    UNSUPPORTED: nptl/test-mutex-printers
    UNSUPPORTED: nptl/test-mutexattr-printers
    UNSUPPORTED: nptl/test-rwlock-printers
    UNSUPPORTED: nptl/test-rwlockattr-printers
    FAIL: nss/test-netdb
    UNSUPPORTED: posix/tst-spawn-cgroup
    FAIL: resolv/tst-bug18665
    FAIL: resolv/tst-bug18665-tcp
    FAIL: resolv/tst-ns_rr_cursor
    FAIL: resolv/tst-resolv-ai_idn
    FAIL: resolv/tst-resolv-ai_idn-latin1
    FAIL: resolv/tst-resolv-ai_idn-nolibidn2
    FAIL: resolv/tst-resolv-aliases
    FAIL: resolv/tst-resolv-basic
    FAIL: resolv/tst-resolv-byaddr
    FAIL: resolv/tst-resolv-invalid-cname
    FAIL: resolv/tst-resolv-noaaaa
    FAIL: resolv/tst-resolv-noaaaa-vc
    FAIL: resolv/tst-resolv-res_init-multi
    FAIL: resolv/tst-resolv-search
    FAIL: resolv/tst-resolv-semi-failure
    FAIL: resolv/tst-resolv-short-response
    FAIL: resolv/tst-resolv-threads
    UNSUPPORTED: string/tst-strerror
    UNSUPPORTED: string/tst-strsignal
    UNSUPPORTED: time/tst-clock_settime
    UNSUPPORTED: time/tst-settimeofday
                    === Summary of results ===
         19 FAIL
       6641 PASS
         29 UNSUPPORTED
         16 XFAIL
          2 XPASS
---

Yao Zihong (1):
  riscv: Add RVV memset for both multiarch and non-multiarch builds

 .../riscv/multiarch/dl-symbol-redir-ifunc.h   | 26 +++++++++
 sysdeps/riscv/multiarch/memset-generic.c      | 26 +++++++++
 sysdeps/riscv/multiarch/memset-vector.S       | 25 ++++++++
 sysdeps/riscv/preconfigure                    |  1 +
 sysdeps/riscv/preconfigure.ac                 |  1 +
 sysdeps/riscv/rv32/rvv/Implies                |  2 +
 sysdeps/riscv/rv64/rvv/Implies                |  2 +
 sysdeps/riscv/rvv/memset.S                    | 53 +++++++++++++++++
 .../unix/sysv/linux/riscv/multiarch/Makefile  |  3 +
 .../linux/riscv/multiarch/ifunc-impl-list.c   | 22 +++++--
 .../unix/sysv/linux/riscv/multiarch/memset.c  | 58 +++++++++++++++++++
 11 files changed, 215 insertions(+), 4 deletions(-)
 create mode 100644 sysdeps/riscv/multiarch/dl-symbol-redir-ifunc.h
 create mode 100644 sysdeps/riscv/multiarch/memset-generic.c
 create mode 100644 sysdeps/riscv/multiarch/memset-vector.S
 create mode 100644 sysdeps/riscv/rv32/rvv/Implies
 create mode 100644 sysdeps/riscv/rv64/rvv/Implies
 create mode 100644 sysdeps/riscv/rvv/memset.S
 create mode 100644 sysdeps/unix/sysv/linux/riscv/multiarch/memset.c

-- 
2.47.2



More information about the Libc-alpha mailing list