From: WenLei Date: Fri, 27 Mar 2026 08:40:14 +0000 (+0800) Subject: src/arch: fix hwprobe include path and ZBC/ZVBC offsets for riscv64 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ccfff1acd6fa5babc7de035271b7f91fccabb8c;p=ceph.git src/arch: fix hwprobe include path and ZBC/ZVBC offsets for riscv64 Signed-off-by: WenLei Fix runtime detection of RISC-V ZBC and ZVBC crypto extensions. Problems fixed: - only exists in glibc >= 2.40 (released 2024-07-22). Many production RISC-V distros still use older glibc (Ubuntu 22.04: 2.35, Debian 12: 2.36, etc.) and would fail to compile. Therefore we switch to the kernel UAPI header , which works with all current glibc versions. Proof: - Absent in glibc 2.39: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h;hb=refs/tags/glibc-2.39 - Present in glibc 2.40: https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/riscv/sys/hwprobe.h;hb=refs/tags/glibc-2.40 - Introducing commit: https://sourceware.org/git/?p=glibc.git;a=commit;h=426d0e1aa8f17426d13707594111df712d2b8911 - Incorrect fallback bit positions: - RISCV_HWPROBE_EXT_ZBC was (1ULL << 15) → should be (1ULL << 7) - RISCV_HWPROBE_EXT_ZVBC was (1ULL << 20) → should be (1ULL << 18) Signed-off-by: WenLei --- diff --git a/src/arch/riscv.c b/src/arch/riscv.c index d7c306c6e16a..90ab9cb872c7 100644 --- a/src/arch/riscv.c +++ b/src/arch/riscv.c @@ -2,7 +2,7 @@ * Runtime detection of RISC-V vector crypto support. */ -#include +#include #include #include @@ -10,11 +10,11 @@ int ceph_arch_riscv_zbc = 0; int ceph_arch_riscv_zvbc = 0; #ifndef RISCV_HWPROBE_EXT_ZBC -#define RISCV_HWPROBE_EXT_ZBC (1ULL << 15) +#define RISCV_HWPROBE_EXT_ZBC (1ULL << 7) #endif #ifndef RISCV_HWPROBE_EXT_ZVBC -#define RISCV_HWPROBE_EXT_ZVBC (1ULL << 20) +#define RISCV_HWPROBE_EXT_ZVBC (1ULL << 18) #endif static int do_hwprobe(struct riscv_hwprobe *pairs, size_t count)