* [PATCH v1] Documentation: riscv: update Vector discovery for userspace
@ 2026-01-07 0:06 Andy Chiu
2026-01-07 11:33 ` kernel test robot
0 siblings, 1 reply; 3+ messages in thread
From: Andy Chiu @ 2026-01-07 0:06 UTC (permalink / raw)
To: linux-riscv, linux-doc, pjw
Cc: Andy Chiu, Zihong Yao, linux-kernel, Alexandre Ghiti,
paul.walmsley, greentime.hu, nick.hu, nylon.chen, eric.lin,
vincent.chen, zong.li, yongxuan.wang, samuel.holland
Make it explicit that users may use both HWCAP and
PR_RISCV_V_GET_CONTROL for checking the availability of Vector
extensions. This addresses the ABI usage concern[1] arised from the user
space community in supporting Vector sub-exts and multiversioning.
[1]: https://bugzilla.kernel.org/show_bug.cgi?id=220795
Suggested-by: Zihong Yao <zihong.plct@isrc.iscas.ac.cn>
Signed-off-by: Andy Chiu <andybnac@gmail.com>
---
Documentation/arch/riscv/vector.rst | 49 +++++++++++++++++++++++------
1 file changed, 39 insertions(+), 10 deletions(-)
diff --git a/Documentation/arch/riscv/vector.rst b/Documentation/arch/riscv/vector.rst
index 3987f5f76a9d..1fde56ffe85b 100644
--- a/Documentation/arch/riscv/vector.rst
+++ b/Documentation/arch/riscv/vector.rst
@@ -13,13 +13,14 @@ order to support the use of the RISC-V Vector Extension.
Two new prctl() calls are added to allow programs to manage the enablement
status for the use of Vector in userspace. The intended usage guideline for
these interfaces is to give init systems a way to modify the availability of V
-for processes running under its domain. Calling these interfaces is not
-recommended in libraries routines because libraries should not override policies
-configured from the parent process. Also, users must note that these interfaces
-are not portable to non-Linux, nor non-RISC-V environments, so it is discourage
-to use in a portable code. To get the availability of V in an ELF program,
-please read :c:macro:`COMPAT_HWCAP_ISA_V` bit of :c:macro:`ELF_HWCAP` in the
-auxiliary vector.
+for processes running under its domain. Changing Vector policy by calling
+:c:macro:`PR_RISCV_V_SET_CONTROL` is not recommended in library routines
+because libraries should not override policies configured by the parent process.
+Also, users must note that these interfaces are not portable to non-Linux,
+nor non-RISC-V environments, so their use is discouraged in portable code.
+To get the availability of V in an ELF program, user code may read the result of
+:c:macro:`PR_RISCV_V_GET_CONTROL`, or the :c:macro:`COMPAT_HWCAP_ISA_V` bit
+of :c:macro:`ELF_HWCAP` in the auxiliary vector.
* prctl(PR_RISCV_V_SET_CONTROL, unsigned long arg)
@@ -91,9 +92,9 @@ auxiliary vector.
Gets the same Vector enablement status for the calling thread. Setting for
next execve() call and the inheritance bit are all OR-ed together.
- Note that ELF programs are able to get the availability of V for itself by
- reading :c:macro:`COMPAT_HWCAP_ISA_V` bit of :c:macro:`ELF_HWCAP` in the
- auxiliary vector.
+ Note that ELF programs are able to get the availability of the standard V
+ extension for itself by reading :c:macro:`COMPAT_HWCAP_ISA_V` bit of
+ :c:macro:`ELF_HWCAP` in the auxiliary vector.
Return value:
* a nonnegative value on success;
@@ -138,3 +139,31 @@ 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
+
+4. Vector Extensions Discovery
+-------------------------------
+
+Existing kernel supports running Vector code in the user space on hardware
+that only implements zve32x subextension, or 0.7 version of the spec when
+compiled with c:macro:`RISCV_ISA_V && RISCV_ISA_XTHEADVECTOR`. When the kernel
+recognizes and supports an extension on a hardware implementation, the
+kernel indicates its existence on /proc/cpuinfo, and the corresponding bits
+obtained from riscv_hwprobe(2) is also set.
+
+The existence of an extension does not necessary guarantee its availibility to
+any given process. Traditionally, :c:macro:`ELF_HWCAP` is used for such
+availibility check. This remains useful for checking the availabilty for standard
+Vector extension, by referencing the :c:macro:`COMPAT_HWCAP_ISA_V` bit.
+
+However, though the kernel provides compatibility for flexible hardware
+configurations, the kernel does not report the availability of subextension, nor
+pre-standarized Vector in :c:macro:`ELF_HWCAP` to prevent exagerating the
+limited bit space.
+
+c:macro:`HWCAP` is designed to serve as a quick check to see if the standard
+Vector is both *pressence* and *available* to the process. For any non-standard
+Vector extensions, the ABI guaranteed way to identify their existence is by
+going through the hwprobe(2) interface. Then, the
+:c:macro:`prctl(PR_RISCV_V_GET_CONTROL)` serves as the availibility
+check to see if executing any Vector instructions is allowed by the runtime
+environment.
--
2.39.3 (Apple Git-145)
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1] Documentation: riscv: update Vector discovery for userspace
2026-01-07 0:06 [PATCH v1] Documentation: riscv: update Vector discovery for userspace Andy Chiu
@ 2026-01-07 11:33 ` kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2026-01-07 11:33 UTC (permalink / raw)
To: Andy Chiu, linux-riscv, linux-doc, pjw
Cc: oe-kbuild-all, Andy Chiu, Zihong Yao, linux-kernel,
Alexandre Ghiti, paul.walmsley, greentime.hu, nick.hu, nylon.chen,
eric.lin, vincent.chen, zong.li, yongxuan.wang, samuel.holland
Hi Andy,
kernel test robot noticed the following build warnings:
[auto build test WARNING on lwn/docs-next]
[also build test WARNING on linus/master v6.19-rc4 next-20260107]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/Documentation-riscv-update-Vector-discovery-for-userspace/20260107-080917
base: git://git.lwn.net/linux.git docs-next
patch link: https://lore.kernel.org/r/20260107000609.63892-1-andybnac%40gmail.com
patch subject: [PATCH v1] Documentation: riscv: update Vector discovery for userspace
reproduce: (https://download.01.org/0day-ci/archive/20260107/202601071253.83RmycAh-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202601071253.83RmycAh-lkp@intel.com/
All warnings (new ones prefixed by >>):
Documentation/userspace-api/landlock:453: ./include/uapi/linux/landlock.h:45: ERROR: Unknown target name: "network flags". [docutils]
Documentation/userspace-api/landlock:453: ./include/uapi/linux/landlock.h:50: ERROR: Unknown target name: "scope flags". [docutils]
Documentation/userspace-api/landlock:453: ./include/uapi/linux/landlock.h:24: ERROR: Unknown target name: "filesystem flags". [docutils]
Documentation/userspace-api/landlock:462: ./include/uapi/linux/landlock.h:153: ERROR: Unknown target name: "filesystem flags". [docutils]
Documentation/userspace-api/landlock:462: ./include/uapi/linux/landlock.h:176: ERROR: Unknown target name: "network flags". [docutils]
>> Documentation/arch/riscv/vector.rst:163: WARNING: Unparseable C cross-reference: 'prctl(PR_RISCV_V_GET_CONTROL)'
Invalid C declaration: Expected end of definition. [error at 5]
prctl(PR_RISCV_V_GET_CONTROL)
-----^
vim +163 Documentation/arch/riscv/vector.rst
162
> 163 c:macro:`HWCAP` is designed to serve as a quick check to see if the standard
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1] Documentation: riscv: update Vector discovery for userspace
@ 2026-01-29 15:48 Rémi Denis-Courmont
0 siblings, 0 replies; 3+ messages in thread
From: Rémi Denis-Courmont @ 2026-01-29 15:48 UTC (permalink / raw)
To: linux-riscv
Hi,
Late to the party but...
> Make it explicit that users may use both HWCAP and
> PR_RISCV_V_GET_CONTROL for checking the availability of Vector
> extensions.
No? Some user-space checks HWCAP. Some check `hwprobe()` in line with
Documentation/arch/riscv/hwprobe.rst in the same directory. Some check
hwprobe() and fallback to HWCAP.
It's a few years too late to disallow using __riscv_hwprove() for this
purpose.
> This addresses the ABI usage concern[1] arised from the user
> space community in supporting Vector sub-exts and multiversioning.
That looks to me that it only muddles the situation more rather than clarify
it by recommending yet another way to detect Vectors that does not match what
running code actually does.
If it were up to me, I would just deprecate the prctl() RVV controls. Their
original intent appears to have been to allow running legacy non-vector code
that would hypothetically not accomodate larger machine contexts in signal
handling. However, given that Vectors are enabled by default, backward
compatibility in that hypothetical scenario never actually existed. So it
seems like it was merged as some kind of bad compromise / commitee design.
Alternatively, clarify that the RVV prctl()'s are only meant for, well,
running legacy code that can't accomodate vector registers, and MUST NOT be
used otherwise as it is known to break apps and libraries with runtime feature
detection.
Or, but that's going to be controversial, and arguably also an ABI break, make
hwprobe() account for the vector state of the process.
Br,
--
德尼-库尔蒙‧雷米
https://www.remlab.net/
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-29 21:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 0:06 [PATCH v1] Documentation: riscv: update Vector discovery for userspace Andy Chiu
2026-01-07 11:33 ` kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2026-01-29 15:48 Rémi Denis-Courmont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox