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

From: Radim Krčmář
Date: Mon Jul 21 2025 - 10:55:44 EST


2025-07-21T14:35:38+02:00, Radim Krčmář <rkrcmar@xxxxxxxxxxxxxxxx>:
> Shouldn't the RISC-V Linux syscall ABI be defined somewhere?

To clarify this point. My issue is with the following part in
Documentation/arch/riscv/vector.rst:

>> As indicated by version 1.0 of the V extension [1], vector registers are
>> clobbered by system calls.
>> [...]
>> 1: https://github.com/riscv/riscv-v-spec/blob/master/calling-convention.adoc

The ISA does not say that vector registers are clobbered by system
calls. All the ISA says is:

"This Appendix is only a placeholder to help explain the conventions
used in the code examples, and is not considered frozen or
part of the ratification process. The official RISC-V psABI document
is being expanded to specify the vector calling conventions."

while the RISC-V psABI says:

"The calling convention for system calls does not fall within the
scope of this document. Please refer to the documentation of the
RISC-V execution environment interface (e.g OS kernel ABI, SBI)."

We made a circular dependency, misinterpreted the ISA, and probably
implemented a suboptimal syscall ABI -- preserving vector registers
seems strictly better.

> How come we could have broken it with 9657e9b7d253?

We changed the ABI once, so maybe we can change it back?

Thanks.