[PATCH] RISC-V: Clobber V registers on syscalls

Rémi Denis-Courmont remi at remlab.net
Thu Jun 15 10:36:31 PDT 2023


Le keskiviikkona 14. kesäkuuta 2023, 19.35.34 EEST Palmer Dabbelt a écrit :
> The V registers are clobbered by standard ABI functions, so userspace
> probably doesn't have anything useful in them by the time we get to the
> kernel.

Indeed, for your typical system call, wrapped by two or more layers of 
function calls inside libc, userspace will treat the registers as clobbered 
anyhow.

But AFAIU, other architectures don't gratuitiously clobber SIMD or vector 
registers, even those that are callee-clobbered by their respective function 
calling convention, or do they? FWIW, Arm is going the opposite direction with 
their higher privilege calls (newer versions of SMCCC define how to preserve 
SVE vectors).

The kernel cannot simply clobber registers, as that would likely cause data 
leakage from kernel to user mode. So it is unclear what the benefits would be 
here. And I fear that there will be less conventional use cases whence it 
makes sense to preserve registers on system calls.

For example an inline or compiler intrinsic implementation of C++20/C2X 
atomic-wait/atomic-notify, which would presumably invoke the futex() syscall 
on Linux, maybe??

-- 
雷米‧德尼-库尔蒙
http://www.remlab.net/






More information about the linux-riscv mailing list