[PATCH] riscv: Add sysctl to control discard of vstate during syscall

Drew Fustini fustini at kernel.org
Mon Jul 21 13:59:39 PDT 2025


On Mon, Jul 21, 2025 at 08:13:48AM -0400, Darius Rad wrote:
> On Fri, Jul 18, 2025 at 08:39:13PM -0700, Drew Fustini wrote:
> > From: Drew Fustini <dfustini at tenstorrent.com>
> > 
> > Clobbering the vector registers can significantly increase system call
> > latency for some implementations. To mitigate this performance impact, a
> > policy mechanism is provided to administrators, distro maintainers, and
> > developers to control vector state discard in the form of a sysctl knob:
> > 
> > /proc/sys/abi/riscv_v_vstate_discard
> > 
> > Valid values are:
> > 
> > 0: Do not discard vector state during syscall
> > 1: Discard vector state during syscall
> > 
> 
> Is the intention for this this mean "don't guarantee vector state is
> clobbered" or "preserve vector state"?  I suspect it is the former, but the
> wording seems unclear.  Additionally, if that's indeed the case, maybe the
> documentation should more clearly articulate the tradeoff (performance vs.
> security/robustness).

Thanks for your comment. I agree it could be worded better and the trade
off should be explained. I believe the motivation behind clobbering in
all syscalls was to make sure that userspace does not rely on the vector
being preserved through a syscall. The goal of this strictness was to
catch any programs that were misbehaving.

Thus, it might be better if I described it as:

0: Vector state is not strictly clobbered in all syscalls
1: Mandatory clobbering of vector state in all syscalls

Thanks,
Drew



More information about the linux-riscv mailing list