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:51:52+02:00
loge0998c0befdc6d58d3b4fd2179d53d0f576d1169
tree5b8fdd2bf43ab97fbc91d7809085cb56f1792b0d
parent996321250d9a9438fc65fcfe64a0d6ada04e50a0
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 @@
33((union { long long ll; long l[2]; }){ .ll = x }).l[1]
44#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
613#define __asm_syscall(...) \
714 __asm__ __volatile__ ("ecall\n\t" \
8 : "=r"(a0) : __VA_ARGS__ : "memory"); \
15 : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \
916 return a0; \
1017
1118static inline long __syscall0(long n)
lib/libc/musl/arch/riscv64/syscall_arch.h+8-1
......@@ -1,9 +1,16 @@
11#define __SYSCALL_LL_E(x) (x)
22#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
411#define __asm_syscall(...) \
512 __asm__ __volatile__ ("ecall\n\t" \
6 : "=r"(a0) : __VA_ARGS__ : "memory"); \
13 : "=r"(a0) : __VA_ARGS__ : SYSCALL_CLOBBERLIST); \
714 return a0; \
815
916static inline long __syscall0(long n)