[PATCH v4] riscv: Discard vector state on syscalls

Andy Chiu andy.chiu at sifive.com
Tue Jul 4 20:50:50 PDT 2023


On Thu, Jun 29, 2023 at 10:22 PM Björn Töpel <bjorn at kernel.org> wrote:
>
> From: Björn Töpel <bjorn at rivosinc.com>
>
> The RISC-V vector specification states:
>   Executing a system call causes all caller-saved vector registers
>   (v0-v31, vl, vtype) and vstart to become unspecified.
>
> The vector registers are set to all 1s, vill is set (invalid), and the
> vector status is set to Dirty.
>
> That way we can prevent userspace from accidentally relying on the
> stated save.
>
> Rémi pointed out [1] that writing to the registers might be
> superfluous, and setting vill is sufficient.
>
> Link: https://lore.kernel.org/linux-riscv/12784326.9UPPK3MAeB@basile.remlab.net/ # [1]
> Suggested-by: Darius Rad <darius at bluespec.com>
> Suggested-by: Palmer Dabbelt <palmer at rivosinc.com>
> Suggested-by: Rémi Denis-Courmont <remi at remlab.net>
> Signed-off-by: Björn Töpel <bjorn at rivosinc.com>

Thanks,
Reviewed-by: Andy Chiu <andy.chiu at sifive.com>



More information about the linux-riscv mailing list