mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andy Chiu <tchiu@tenstorrent.com>
To: Samuel Holland <samuel.holland@sifive.com>
Cc: Samuel Holland <samuel.holland@sifive.com>,
	Paul Walmsley <pjw@kernel.org>, Anup Patel <anup@brainfault.org>,
	Atish Patra <atish.patra@linux.dev>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kvm-riscv@lists.infradead.org" <kvm-riscv@lists.infradead.org>,
	"linux-riscv@lists.infradead.org"
	<linux-riscv@lists.infradead.org>,
	linux-riscv <linux-riscv-bounces@lists.infradead.org>
Subject: Re:  riscv: Deprecate vector state prctl/sysctl
Date: Fri, 30 Oct 2026 13:36:49 -0500	[thread overview]
Message-ID: <auTjwQoRqV5ayKdx@Tao-Chiu's-Mac> (raw)
In-Reply-To: <DM9V74ODA23L.36WJYLIGDDVMG@qti.qualcomm.com>

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@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@sifive.com>
> > ---
> 
> Would be nice to also update selftests and vector.rst.
> 
> Thanks.

  reply	other threads:[~2026-10-30 18:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07  8:51 [PATCH 0/3] riscv: Deprecate userspace vector control interfaces Samuel Holland
2026-10-07  8:51 ` [PATCH 1/3] riscv: Drop CONFIG_RISCV_ISA_V_DEFAULT_ENABLE Samuel Holland
2026-10-13 16:59   ` Andy Chiu
2026-10-07  8:51 ` [PATCH 2/3] riscv: Deprecate vector state prctl/sysctl Samuel Holland
2026-10-13 16:57   ` Andy Chiu
2026-10-20 18:08   ` Radim Krcmar
2026-10-30 18:36     ` Andy Chiu [this message]
2026-10-07  8:51 ` [PATCH 3/3] RISC-V: KVM: Decouple vector prctl state from VM ISA Samuel Holland
2026-10-13 16:58   ` Andy Chiu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='auTjwQoRqV5ayKdx@Tao-Chiu'\''s-Mac' \
    --to=tchiu@tenstorrent.com \
    --cc=anup@brainfault.org \
    --cc=atish.patra@linux.dev \
    --cc=kvm-riscv@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv-bounces@lists.infradead.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=samuel.holland@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®