riscv: Deprecate vector state prctl/sysctl

Andy Chiu tchiu at tenstorrent.com
Fri Oct 30 11:36:49 PDT 2026


Hi Samuel and Radim,

On Tue, Oct 20, 2026 at 06:08:10PM +0000, Radim Krcmar wrote:
> 2026-10-07T01:51:17-07:00, Samuel Holland <samuel.holland at sifive.com>:
> > The ability to prevent userspace from executing vector instructions was
> > provided as a escape hatch for software that was broken by adding vector
> > state to the signal context. This appears to be unused in practice, and
> > creates confusion in the extension support returned by hwprobe(), as in
> > this one special case an extension reported as present by hwprobe() is
> > unusable.
> >
> > Since we believe it is safe to always allow vector usage, hide the prctl
> > and sysctl behind a Kconfig option and mark them as deprecated, so they
> > can be removed in the future. Note that significant userspace software
> > like glibc already considers these controls explicitly unsupported.
> 
> KVM on QEMU breaks because of -EINVAL:
> 
>   static bool kvm_cpu_realize(CPUState *cs, Error **errp)
>   { [...]
>       if (riscv_has_ext(&cpu->env, RVV)) {
>           ret = prctl(PR_RISCV_V_SET_CONTROL, PR_RISCV_V_VSTATE_CTRL_ON);
>           if (ret) {
>               error_setg_errno(errp, errno,
>                                "Error in prctl PR_RISCV_V_SET_CONTROL");
>               return false;
>           }
>       }
> 
> We could have somewhat softer deprecations by defining that the vector
> prctls succeed when user intent matches the current state and deny any
> change.

Thanks for spotting this, after discussing with the team, we would
suggest the following moving forward:

 - The prctl and sysctl interface should remain, and PR_RISCV_V_GET_CONTROL
   always returns the enablement status.
 - Turning on vector with prctl(PR_RISCV_V_SET_CONTROL, PR_RISCV_V_VSTATE_CTRL_ON)
   should always success on a platform that supports vector.
 - Turning off vector with prctl, or sysctl interface should return
   -EINVAL, and must not turn off vector at next execv. A pr_warn here
   could be helpful to inform system administrator that this operation
   is deprecated.
 - Selftest should be updated and verify that turning off vector with
   prctl does not take any effect.

I am happy to help on any part of the work if needed, just let me know.

> 
> Or is RISC-V still bold enough to "fix" userspace and hope for the best?
> (High chance of Linus.)
> 
> >
> > Signed-off-by: Samuel Holland <samuel.holland at sifive.com>
> > ---
> 
> Would be nice to also update selftests and vector.rst.
> 
> Thanks.



More information about the kvm-riscv mailing list