[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <aH6vA+e5v7NMMGnc@x1>
Date: Mon, 21 Jul 2025 14:20:03 -0700
From: Drew Fustini <pdp7pdp7@...il.com>
To: Radim Krčmář <rkrcmar@...tanamicro.com>
Cc: Drew Fustini <fustini@...nel.org>, Palmer Dabbelt <palmer@...belt.com>,
Björn Töpel <bjorn@...osinc.com>,
Alexandre Ghiti <alex@...ti.fr>,
Paul Walmsley <paul.walmsley@...ive.com>,
Samuel Holland <samuel.holland@...ive.com>,
Drew Fustini <dfustini@...storrent.com>,
Andy Chiu <andybnac@...il.com>,
Conor Dooley <conor.dooley@...rochip.com>,
linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
linux-riscv <linux-riscv-bounces@...ts.infradead.org>
Subject: Re: [PATCH] riscv: Add sysctl to control discard of vstate during
syscall
On Mon, Jul 21, 2025 at 04:54:25PM +0200, Radim Krčmář wrote:
> 2025-07-21T14:35:38+02:00, Radim Krčmář <rkrcmar@...tanamicro.com>:
> > 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.
Thanks for providing these references. It does seem like this is
something that an OS can decide and is not mandated by the ISA or psABI.
> > How come we could have broken it with 9657e9b7d253?
>
> We changed the ABI once, so maybe we can change it back?
Reverting 9657e9b7d253 would solve the performance issue for some
implementations that I've highlighted in this patch. However, I am
interested to hear from others that feel the current mandatory
clobbering behavior is ideal for testing (and maybe security?).
Thanks,
Drew
Powered by blists - more mailing lists