]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
src/arch: fix hwprobe include path and ZBC/ZVBC offsets for riscv64 68047/head
authorWenLei <lei.wen2@zte.com.cn>
Fri, 27 Mar 2026 08:40:14 +0000 (16:40 +0800)
committerWenLei <lei.wen2@zte.com.cn>
Sat, 28 Mar 2026 02:56:18 +0000 (10:56 +0800)
Signed-off-by: WenLei <lei.wen2@zte.com.cn>
Fix runtime detection of RISC-V ZBC and ZVBC crypto extensions.

Problems fixed:
- <sys/hwprobe.h> 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 <asm/hwprobe.h>,
  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 <lei.wen2@zte.com.cn>
src/arch/riscv.c

index d7c306c6e16abc4e11634a8d11c6fca99f1d4d5c..90ab9cb872c700f40f22e5bc1b0668e575cc0a80 100644 (file)
@@ -2,7 +2,7 @@
  * Runtime detection of RISC-V vector crypto support.
  */
 
-#include <sys/hwprobe.h>
+#include <asm/hwprobe.h>
 #include <sys/syscall.h>
 #include <unistd.h>
 
@@ -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)