From e0998c0befdc6d58d3b4fd2179d53d0f576d1169 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Sun, 4 Oct 2026 04:51:52 +0200 Subject: [PATCH] musl: declare all riscv vector registers as syscall clobbers https://www.openwall.com/lists/musl/2026/10/04/1 --- lib/libc/musl/arch/riscv32/syscall_arch.h | 9 ++++++++- lib/libc/musl/arch/riscv64/syscall_arch.h | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/libc/musl/arch/riscv32/syscall_arch.h b/lib/libc/musl/arch/riscv32/syscall_arch.h index c507f15f2f0c25082ddc7d4737829055f060c350..c35ade754505543e3353a9e0aecce4d67523d5d4 100644 --- a/lib/libc/musl/arch/riscv32/syscall_arch.h +++ b/lib/libc/musl/arch/riscv32/syscall_arch.h @@ -3,9 +3,16 @@ ((union { long long ll; long l[2]; }){ .ll = x }).l[1] #define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x)) +#define SYSCALL_CLOBBERLIST \ + "v0" , "v1", "v2", "v3", "v4", "v5", "v6", "v7", \ + "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \ + "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \ + "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \ + "vl", "vtype", "vxsat", "vxrm", "memory" + #define __asm_syscall(...) \ __asm__ __volatile__ ("ecall\n\t" \ - : "=r"(a0) : __VA_ARGS__ : "memory"); \ + : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \ return a0; \ static inline long __syscall0(long n) diff --git a/lib/libc/musl/arch/riscv64/syscall_arch.h b/lib/libc/musl/arch/riscv64/syscall_arch.h index 7fd042cd4ad37695f84d87372ff830cf5aa3b22b..82844c58fd42ee1a3d193e66b29ba328986d5b32 100644 --- a/lib/libc/musl/arch/riscv64/syscall_arch.h +++ b/lib/libc/musl/arch/riscv64/syscall_arch.h @@ -1,9 +1,16 @@ #define __SYSCALL_LL_E(x) (x) #define __SYSCALL_LL_O(x) (x) +#define SYSCALL_CLOBBERLIST \ + "v0" , "v1", "v2", "v3", "v4", "v5", "v6", "v7", \ + "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \ + "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \ + "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \ + "vl", "vtype", "vxsat", "vxrm", "memory" + #define __asm_syscall(...) \ __asm__ __volatile__ ("ecall\n\t" \ - : "=r"(a0) : __VA_ARGS__ : "memory"); \ + : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \ return a0; \ static inline long __syscall0(long n) -- 2.54.0