authorgravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-04 04:51:52+02:00
committergravatar for alex@alexrp.comAlex Rønne Petersen <alex@alexrp.com> 2026-10-04 04:52:49+02:00
log7f87e864df7a45f0df7ba41fbebd7eaf3fb2ee7c
treef7ad953f590e8d0fa85556c7467921b55e3f402a
parent327181a1a5d51769351296c164f3cc506812e12b
signature Signed by SSH key SHA256:7B/LJ7bpR1eX8aCXSr4mtd5M45VMPKcx9zY8e95b5QM

musl: declare all riscv vector registers as syscall clobbers

https://www.openwall.com/lists/musl/2026/10/04/1

2 files changed, 16 insertions(+), 2 deletions(-)

lib/libc/musl/arch/riscv32/syscall_arch.h+8-1
...@@ -3,9 +3,16 @@...@@ -3,9 +3,16 @@
3((union { long long ll; long l[2]; }){ .ll = x }).l[1]3((union { long long ll; long l[2]; }){ .ll = x }).l[1]
4#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))4#define __SYSCALL_LL_O(x) __SYSCALL_LL_E((x))
55
6#define SYSCALL_CLOBBERLIST \
7 "v0" , "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
8 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
9 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
10 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \
11 "vl", "vtype", "vxsat", "vxrm", "memory"
12
6#define __asm_syscall(...) \13#define __asm_syscall(...) \
7 __asm__ __volatile__ ("ecall\n\t" \14 __asm__ __volatile__ ("ecall\n\t" \
8 : "=r"(a0) : __VA_ARGS__ : "memory"); \15 : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \
9 return a0; \16 return a0; \
1017
11static inline long __syscall0(long n)18static inline long __syscall0(long n)
lib/libc/musl/arch/riscv64/syscall_arch.h+8-1
...@@ -1,9 +1,16 @@...@@ -1,9 +1,16 @@
1#define __SYSCALL_LL_E(x) (x)1#define __SYSCALL_LL_E(x) (x)
2#define __SYSCALL_LL_O(x) (x)2#define __SYSCALL_LL_O(x) (x)
33
4#define SYSCALL_CLOBBERLIST \
5 "v0" , "v1", "v2", "v3", "v4", "v5", "v6", "v7", \
6 "v8", "v9", "v10", "v11", "v12", "v13", "v14", "v15", \
7 "v16", "v17", "v18", "v19", "v20", "v21", "v22", "v23", \
8 "v24", "v25", "v26", "v27", "v28", "v29", "v30", "v31", \
9 "vl", "vtype", "vxsat", "vxrm", "memory"
10
4#define __asm_syscall(...) \11#define __asm_syscall(...) \
5 __asm__ __volatile__ ("ecall\n\t" \12 __asm__ __volatile__ ("ecall\n\t" \
6 : "=r"(a0) : __VA_ARGS__ : "memory"); \13 : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \
7 return a0; \14 return a0; \
815
9static inline long __syscall0(long n)16static inline long __syscall0(long n)