[PATCH] RISC-V: Clobber V registers on syscalls
Rémi Denis-Courmont
remi at remlab.net
Fri Jun 16 12:58:31 PDT 2023
Le torstaina 15. kesäkuuta 2023, 23.33.44 EEST Palmer Dabbelt a écrit :
> > 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
> What's the data leakage?
Typically "clobbering" the register means that you are writing something else
in them. If you don't restore them (or expressly reset them to zero or some
other fixed value), then you leak daata.
Of course, if you don't actually use the register, then you don't leak
anything in them. But then it's unclear what the benefit of marking them as
clobbered is.
(...)
> It'd have to be a pretty special case: at least in libstdc++ and glibc
> the futex calls are behind function calls,
Traditionally, atomic variable methods are intrinsics, which result in either
inline or outline C runtime calls (with some ad-hoc ABI that clobbers very
little). They cannot be C functions, since they accept parameters of several
different types.
atomic_notify_one, atomic_notify_all, and atomic_wait or however their
standardised names end up, will presumably be outlines of the later type, that
just happen to wrap futex() on Linux.
But anyway, if the spec says that registers are clobbered by system calls as
Björn pointed out, then that's that.
--
Rémi Denis-Courmont
http://www.remlab.net/
More information about the linux-riscv
mailing list