[PATCH] RISC-V: Clobber V state on system calls

Vineet Gupta vineetg@rivosinc.com
Wed Mar 27 22:16:36 GMT 2024


On 3/27/24 14:53, Palmer Dabbelt wrote:
> On Wed, 27 Mar 2024 14:48:45 PDT (-0700), Andrew Waterman wrote:
>> LGTM.  I suspect this hasn't manifested as a bug because a glibc
>> routine with an inline syscall would need to be vectorized for this to
>> be a potential problem.  But the prophylaxis is a good idea.
> IIUC we've also got another quirk where GCC discards all V register 
> state on inline ASM blocks

If so, is this patch needed ? No, it doesn't unless V regs are in
clobber list.

>  (but I think doesn't discard the V CSR 
> state), so it'd be pretty unlikely we actually vectorize anything with 
> the syscall macros.  Getting a reproducer for those is next on the TODO 
> list 😉

If one specifies vtype as clobber, it is refreshed with a vsetvl.
gcc seems to be doing the right thing ATM. I've posted a test which
confirms the same [1]

-Vineet

[1] https://gcc.gnu.org/pipermail/gcc-patches/2024-March/648499.html



More information about the Libc-alpha mailing list