sphinx.addnodesdocument)}( rawsourcechildren]( translations LanguagesNode)}(hhh](h pending_xref)}(hhh]docutils.nodesTextChinese (Simplified)}parenthsba attributes}(ids]classes]names]dupnames]backrefs] refdomainstdreftypedoc reftarget%/translations/zh_CN/arch/riscv/vectormodnameN classnameN refexplicitutagnamehhh ubh)}(hhh]hChinese (Traditional)}hh2sbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/zh_TW/arch/riscv/vectormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hItalian}hhFsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/it_IT/arch/riscv/vectormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hJapanese}hhZsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ja_JP/arch/riscv/vectormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hKorean}hhnsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/ko_KR/arch/riscv/vectormodnameN classnameN refexplicituh1hhh ubh)}(hhh]hSpanish}hhsbah}(h]h ]h"]h$]h&] refdomainh)reftypeh+ reftarget%/translations/sp_SP/arch/riscv/vectormodnameN classnameN refexplicituh1hhh ubeh}(h]h ]h"]h$]h&]current_languageEnglishuh1h hh _documenthsourceNlineNubhcomment)}(h SPDX-License-Identifier: GPL-2.0h]h SPDX-License-Identifier: GPL-2.0}hhsbah}(h]h ]h"]h$]h&] xml:spacepreserveuh1hhhhhh?/var/lib/git/docbuild/linux/Documentation/arch/riscv/vector.rsthKubhsection)}(hhh](htitle)}(h)Vector Extension Support for RISC-V Linuxh]h)Vector Extension Support for RISC-V Linux}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhKubh paragraph)}(hThis document briefly outlines the interface provided to userspace by Linux in order to support the use of the RISC-V Vector Extension.h]hThis document briefly outlines the interface provided to userspace by Linux in order to support the use of the RISC-V Vector Extension.}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhhhhubh)}(hhh](h)}(h1. prctl() Interfaceh]h1. prctl() Interface}(hhhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhhhhhK ubh)}(hXTwo 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.h](hXvTwo 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 }(hhhhhNhNubh)}(h:c:macro:`COMPAT_HWCAP_ISA_V`h]hliteral)}(hhh]hCOMPAT_HWCAP_ISA_V}(hhhhhNhNubah}(h]h ](xrefcc-macroeh"]h$]h&]uh1hhhubah}(h]h ]h"]h$]h&]refdocarch/riscv/vector refdomainjreftypemacro refexplicitrefwarn reftargetCOMPAT_HWCAP_ISA_Vuh1hhhhK hhubh bit of }(hhhhhNhNubh)}(h:c:macro:`ELF_HWCAP`h]h)}(hjh]h ELF_HWCAP}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnj ELF_HWCAPuh1hhhhK hhubh in the auxiliary vector.}(hhhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK hhhhubh bullet_list)}(hhh](h list_item)}(hX prctl(PR_RISCV_V_SET_CONTROL, unsigned long arg) Sets the Vector enablement status of the calling thread, where the control argument consists of two 2-bit enablement statuses and a bit for inheritance mode. Other threads of the calling process are unaffected. Enablement status is a tri-state value each occupying 2-bit of space in the control argument: * :c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`: Use the system-wide default enablement status on execve(). The system-wide default setting can be controlled via sysctl interface (see sysctl section below). * :c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`: Allow Vector to be run for the thread. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`: Disallow Vector. Executing Vector instructions under such condition will trap and casuse the termination of the thread. arg: The control argument is a 5-bit value consisting of 3 parts, and accessed by 3 masks respectively. The 3 masks, PR_RISCV_V_VSTATE_CTRL_CUR_MASK, PR_RISCV_V_VSTATE_CTRL_NEXT_MASK, and PR_RISCV_V_VSTATE_CTRL_INHERIT represents bit[1:0], bit[3:2], and bit[4]. bit[1:0] accounts for the enablement status of current thread, and the setting at bit[3:2] takes place at next execve(). bit[4] defines the inheritance mode of the setting in bit[3:2]. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value. Return value: * 0 on success; * EINVAL: Vector not supported, invalid enablement status for current or next mask; * EPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread. On success: * A valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set. * Every successful call overwrites a previous setting for the calling thread. h](h)}(h0prctl(PR_RISCV_V_SET_CONTROL, unsigned long arg)h]h0prctl(PR_RISCV_V_SET_CONTROL, unsigned long arg)}(hjOhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjKubh block_quote)}(hX Sets the Vector enablement status of the calling thread, where the control argument consists of two 2-bit enablement statuses and a bit for inheritance mode. Other threads of the calling process are unaffected. Enablement status is a tri-state value each occupying 2-bit of space in the control argument: * :c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`: Use the system-wide default enablement status on execve(). The system-wide default setting can be controlled via sysctl interface (see sysctl section below). * :c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`: Allow Vector to be run for the thread. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`: Disallow Vector. Executing Vector instructions under such condition will trap and casuse the termination of the thread. arg: The control argument is a 5-bit value consisting of 3 parts, and accessed by 3 masks respectively. The 3 masks, PR_RISCV_V_VSTATE_CTRL_CUR_MASK, PR_RISCV_V_VSTATE_CTRL_NEXT_MASK, and PR_RISCV_V_VSTATE_CTRL_INHERIT represents bit[1:0], bit[3:2], and bit[4]. bit[1:0] accounts for the enablement status of current thread, and the setting at bit[3:2] takes place at next execve(). bit[4] defines the inheritance mode of the setting in bit[3:2]. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value. Return value: * 0 on success; * EINVAL: Vector not supported, invalid enablement status for current or next mask; * EPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread. On success: * A valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set. * Every successful call overwrites a previous setting for the calling thread. h](h)}(hSets the Vector enablement status of the calling thread, where the control argument consists of two 2-bit enablement statuses and a bit for inheritance mode. Other threads of the calling process are unaffected.h]hSets the Vector enablement status of the calling thread, where the control argument consists of two 2-bit enablement statuses and a bit for inheritance mode. Other threads of the calling process are unaffected.}(hjchhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj_ubh)}(h]Enablement status is a tri-state value each occupying 2-bit of space in the control argument:h]h]Enablement status is a tri-state value each occupying 2-bit of space in the control argument:}(hjqhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhj_ubjE)}(hhh](jJ)}(h:c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`: Use the system-wide default enablement status on execve(). The system-wide default setting can be controlled via sysctl interface (see sysctl section below). h]h)}(h:c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`: Use the system-wide default enablement status on execve(). The system-wide default setting can be controlled via sysctl interface (see sysctl section below).h](h)}(h):c:macro:`PR_RISCV_V_VSTATE_CTRL_DEFAULT`h]h)}(hjh]hPR_RISCV_V_VSTATE_CTRL_DEFAULT}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjPR_RISCV_V_VSTATE_CTRL_DEFAULTuh1hhhhK!hjubh: Use the system-wide default enablement status on execve(). The system-wide default setting can be controlled via sysctl interface (see sysctl section below).}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK!hjubah}(h]h ]h"]h$]h&]uh1jIhjubjJ)}(hM:c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`: Allow Vector to be run for the thread. h]h)}(hL:c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`: Allow Vector to be run for the thread.h](h)}(h$:c:macro:`PR_RISCV_V_VSTATE_CTRL_ON`h]h)}(hjh]hPR_RISCV_V_VSTATE_CTRL_ON}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjPR_RISCV_V_VSTATE_CTRL_ONuh1hhhhK%hjubh(: Allow Vector to be run for the thread.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK%hjubah}(h]h ]h"]h$]h&]uh1jIhjubjJ)}(h:c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`: Disallow Vector. Executing Vector instructions under such condition will trap and casuse the termination of the thread. h]h)}(h:c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`: Disallow Vector. Executing Vector instructions under such condition will trap and casuse the termination of the thread.h](h)}(h%:c:macro:`PR_RISCV_V_VSTATE_CTRL_OFF`h]h)}(hjh]hPR_RISCV_V_VSTATE_CTRL_OFF}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjPR_RISCV_V_VSTATE_CTRL_OFFuh1hhhhK(hjubhy: Disallow Vector. Executing Vector instructions under such condition will trap and casuse the termination of the thread.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK(hjubah}(h]h ]h"]h$]h&]uh1jIhjubeh}(h]h ]h"]h$]h&]bullet*uh1jDhhhK!hj_ubh)}(hgarg: The control argument is a 5-bit value consisting of 3 parts, and accessed by 3 masks respectively.h]hgarg: The control argument is a 5-bit value consisting of 3 parts, and accessed by 3 masks respectively.}(hj/hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK+hj_ubh)}(hXVThe 3 masks, PR_RISCV_V_VSTATE_CTRL_CUR_MASK, PR_RISCV_V_VSTATE_CTRL_NEXT_MASK, and PR_RISCV_V_VSTATE_CTRL_INHERIT represents bit[1:0], bit[3:2], and bit[4]. bit[1:0] accounts for the enablement status of current thread, and the setting at bit[3:2] takes place at next execve(). bit[4] defines the inheritance mode of the setting in bit[3:2].h]hXVThe 3 masks, PR_RISCV_V_VSTATE_CTRL_CUR_MASK, PR_RISCV_V_VSTATE_CTRL_NEXT_MASK, and PR_RISCV_V_VSTATE_CTRL_INHERIT represents bit[1:0], bit[3:2], and bit[4]. bit[1:0] accounts for the enablement status of current thread, and the setting at bit[3:2] takes place at next execve(). bit[4] defines the inheritance mode of the setting in bit[3:2].}(hj=hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK.hj_ubj^)}(hXm* :c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen. * :c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value. h]jE)}(hhh](jJ)}(hX:c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status. h]h)}(hX:c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status.h](h)}(h*:c:macro:`PR_RISCV_V_VSTATE_CTRL_CUR_MASK`h]h)}(hj\h]hPR_RISCV_V_VSTATE_CTRL_CUR_MASK}(hj^hhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjZubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjPR_RISCV_V_VSTATE_CTRL_CUR_MASKuh1hhhhK5hjVubhX: bit[1:0]: Account for the Vector enablement status for the calling thread. The calling thread is not able to turn off Vector once it has been enabled. The prctl() call fails with EPERM if the value in this mask is PR_RISCV_V_VSTATE_CTRL_OFF but the current enablement status is not off. Setting PR_RISCV_V_VSTATE_CTRL_DEFAULT here takes no effect but to set back the original enablement status.}(hjVhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK5hjRubah}(h]h ]h"]h$]h&]uh1jIhjOubjJ)}(hX8:c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen. h]h)}(hX7:c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`: bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen.h](h)}(h+:c:macro:`PR_RISCV_V_VSTATE_CTRL_NEXT_MASK`h]h)}(hjh]h PR_RISCV_V_VSTATE_CTRL_NEXT_MASK}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnj PR_RISCV_V_VSTATE_CTRL_NEXT_MASKuh1hhhhK=hjubhX : bit[3:2]: Account for the Vector enablement setting for the calling thread at the next execve() system call. If PR_RISCV_V_VSTATE_CTRL_DEFAULT is used in this mask, then the enablement status will be decided by the system-wide enablement status when execve() happen.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK=hjubah}(h]h ]h"]h$]h&]uh1jIhjOubjJ)}(hXZ:c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value. h]h)}(hXY:c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value.h](h)}(h):c:macro:`PR_RISCV_V_VSTATE_CTRL_INHERIT`h]h)}(hjh]hPR_RISCV_V_VSTATE_CTRL_INHERIT}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjPR_RISCV_V_VSTATE_CTRL_INHERITuh1hhhhKChjubhX0: bit[4]: the inheritance mode for the setting at PR_RISCV_V_VSTATE_CTRL_NEXT_MASK. If the bit is set then the following execve() will not clear the setting in both PR_RISCV_V_VSTATE_CTRL_NEXT_MASK and PR_RISCV_V_VSTATE_CTRL_INHERIT. This setting persists across changes in the system-wide default value.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhKChjubah}(h]h ]h"]h$]h&]uh1jIhjOubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhK5hjKubah}(h]h ]h"]h$]h&]uh1j]hhhK5hj_ubhdefinition_list)}(hhh](hdefinition_list_item)}(hReturn value: * 0 on success; * EINVAL: Vector not supported, invalid enablement status for current or next mask; * EPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread. h](hterm)}(h Return value:h]h Return value:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKNhj ubh definition)}(hhh]jE)}(hhh](jJ)}(h 0 on success;h]h)}(hj(h]h 0 on success;}(hj*hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKJhj&ubah}(h]h ]h"]h$]h&]uh1jIhj#ubjJ)}(hQEINVAL: Vector not supported, invalid enablement status for current or next mask;h]h)}(hQEINVAL: Vector not supported, invalid enablement status for current or next mask;h]hQEINVAL: Vector not supported, invalid enablement status for current or next mask;}(hjAhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKKhj=ubah}(h]h ]h"]h$]h&]uh1jIhj#ubjJ)}(hkEPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread. h]h)}(hjEPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread.h]hjEPERM: Turning off Vector in PR_RISCV_V_VSTATE_CTRL_CUR_MASK if Vector was enabled for the calling thread.}(hjYhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKMhjUubah}(h]h ]h"]h$]h&]uh1jIhj#ubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhKJhj ubah}(h]h ]h"]h$]h&]uh1jhj ubeh}(h]h ]h"]h$]h&]uh1jhhhKNhjubj )}(hXhOn success: * A valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set. * Every successful call overwrites a previous setting for the calling thread. h](j)}(h On success:h]h On success:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKWhjubj)}(hhh]jE)}(hhh](jJ)}(hXA valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set.h]h)}(hXA valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set.h]hXA valid setting for PR_RISCV_V_VSTATE_CTRL_CUR_MASK takes place immediately. The enablement status specified in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK happens at the next execve() call, or all following execve() calls if PR_RISCV_V_VSTATE_CTRL_INHERIT bit is set.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKQhjubah}(h]h ]h"]h$]h&]uh1jIhjubjJ)}(hLEvery successful call overwrites a previous setting for the calling thread. h]h)}(hKEvery successful call overwrites a previous setting for the calling thread.h]hKEvery successful call overwrites a previous setting for the calling thread.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKVhjubah}(h]h ]h"]h$]h&]uh1jIhjubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhKQhjubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1jhhhKWhjubeh}(h]h ]h"]h$]h&]uh1jhj_ubeh}(h]h ]h"]h$]h&]uh1j]hhhKhjKubeh}(h]h ]h"]h$]h&]uh1jIhjFhhhhhNubjJ)}(hXprctl(PR_RISCV_V_GET_CONTROL) 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. Return value: * a nonnegative value on success; * EINVAL: Vector not supported. h](h)}(hprctl(PR_RISCV_V_GET_CONTROL)h]hprctl(PR_RISCV_V_GET_CONTROL)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKYhjubj^)}(hXGets 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. Return value: * a nonnegative value on success; * EINVAL: Vector not supported. h](h)}(hGets the same Vector enablement status for the calling thread. Setting for next execve() call and the inheritance bit are all OR-ed together.h]hGets the same Vector enablement status for the calling thread. Setting for next execve() call and the inheritance bit are all OR-ed together.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK[hjubh)}(hNote 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.h](hSNote that ELF programs are able to get the availability of V for itself by reading }(hjhhhNhNubh)}(h:c:macro:`COMPAT_HWCAP_ISA_V`h]h)}(hjh]hCOMPAT_HWCAP_ISA_V}(hjhhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhjubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnjCOMPAT_HWCAP_ISA_Vuh1hhhhK^hjubh bit of }(hjhhhNhNubh)}(h:c:macro:`ELF_HWCAP`h]h)}(hj<h]h ELF_HWCAP}(hj>hhhNhNubah}(h]h ](jjc-macroeh"]h$]h&]uh1hhj:ubah}(h]h ]h"]h$]h&]refdocj refdomainjreftypemacro refexplicitrefwarnj ELF_HWCAPuh1hhhhK^hjubh in the auxiliary vector.}(hjhhhNhNubeh}(h]h ]h"]h$]h&]uh1hhhhK^hjubj)}(hhh]j )}(hPReturn value: * a nonnegative value on success; * EINVAL: Vector not supported. h](j)}(h Return value:h]h Return value:}(hjjhhhNhNubah}(h]h ]h"]h$]h&]uh1jhhhKdhjfubj)}(hhh]jE)}(hhh](jJ)}(ha nonnegative value on success;h]h)}(hjh]ha nonnegative value on success;}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKchj~ubah}(h]h ]h"]h$]h&]uh1jIhj{ubjJ)}(hEINVAL: Vector not supported. h]h)}(hEINVAL: Vector not supported.h]hEINVAL: Vector not supported.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKdhjubah}(h]h ]h"]h$]h&]uh1jIhj{ubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhKchjxubah}(h]h ]h"]h$]h&]uh1jhjfubeh}(h]h ]h"]h$]h&]uh1jhhhKdhjcubah}(h]h ]h"]h$]h&]uh1jhjubeh}(h]h ]h"]h$]h&]uh1j]hhhK[hjubeh}(h]h ]h"]h$]h&]uh1jIhjFhhhhhNubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhKhhhhubeh}(h]prctl-interfaceah ]h"]1. prctl() interfaceah$]h&]uh1hhhhhhhhK ubh)}(hhh](h)}(h)2. System runtime configuration (sysctl)h]h)2. System runtime configuration (sysctl)}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKgubh)}(hTo mitigate the ABI impact of expansion of the signal stack, a policy mechanism is provided to the administrators, distro maintainers, and developers to control the default Vector enablement status for userspace processes in form of sysctl knob:h]hTo mitigate the ABI impact of expansion of the signal stack, a policy mechanism is provided to the administrators, distro maintainers, and developers to control the default Vector enablement status for userspace processes in form of sysctl knob:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKihjhhubjE)}(hhh]jJ)}(hX/proc/sys/abi/riscv_v_default_allow Writing the text representation of 0 or 1 to this file sets the default system enablement status for new starting userspace programs. Valid values are: * 0: Do not allow Vector code to be executed as the default for new processes. * 1: Allow Vector code to be executed as the default for new processes. Reading this file returns the current system default enablement status. At every execve() call, a new enablement status of the new process is set to the system default, unless: * PR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or, * The setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Modifying the system default enablement status does not affect the enablement status of any existing process of thread that do not make an execve() call. h](h)}(h#/proc/sys/abi/riscv_v_default_allowh]h#/proc/sys/abi/riscv_v_default_allow}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKnhjubj^)}(hXWriting the text representation of 0 or 1 to this file sets the default system enablement status for new starting userspace programs. Valid values are: * 0: Do not allow Vector code to be executed as the default for new processes. * 1: Allow Vector code to be executed as the default for new processes. Reading this file returns the current system default enablement status. At every execve() call, a new enablement status of the new process is set to the system default, unless: * PR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or, * The setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Modifying the system default enablement status does not affect the enablement status of any existing process of thread that do not make an execve() call. h](h)}(hWriting the text representation of 0 or 1 to this file sets the default system enablement status for new starting userspace programs. Valid values are:h]hWriting the text representation of 0 or 1 to this file sets the default system enablement status for new starting userspace programs. Valid values are:}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKphjubjE)}(hhh](jJ)}(hL0: Do not allow Vector code to be executed as the default for new processes.h]h)}(hj*h]hL0: Do not allow Vector code to be executed as the default for new processes.}(hj,hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKthj(ubah}(h]h ]h"]h$]h&]uh1jIhj%ubjJ)}(hF1: Allow Vector code to be executed as the default for new processes. h]h)}(hE1: Allow Vector code to be executed as the default for new processes.h]hE1: Allow Vector code to be executed as the default for new processes.}(hjChhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKuhj?ubah}(h]h ]h"]h$]h&]uh1jIhj%ubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhKthjubh)}(hGReading this file returns the current system default enablement status.h]hGReading this file returns the current system default enablement status.}(hj]hhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKwhjubh)}(hhAt every execve() call, a new enablement status of the new process is set to the system default, unless:h]hhAt every execve() call, a new enablement status of the new process is set to the system default, unless:}(hjkhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKyhjubj^)}(hX* PR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or, * The setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. h]jE)}(hhh](jJ)}(hPR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or, h]h)}(hPR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or,h]hPR_RISCV_V_VSTATE_CTRL_INHERIT is set for the calling process, and the setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. Or,}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhK|hjubah}(h]h ]h"]h$]h&]uh1jIhj}ubjJ)}(hWThe setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT. h]h)}(hVThe setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT.h]hVThe setting in PR_RISCV_V_VSTATE_CTRL_NEXT_MASK is not PR_RISCV_V_VSTATE_CTRL_DEFAULT.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubah}(h]h ]h"]h$]h&]uh1jIhj}ubeh}(h]h ]h"]h$]h&]j-j.uh1jDhhhK|hjyubah}(h]h ]h"]h$]h&]uh1j]hhhK|hjubh)}(hModifying the system default enablement status does not affect the enablement status of any existing process of thread that do not make an execve() call.h]hModifying the system default enablement status does not affect the enablement status of any existing process of thread that do not make an execve() call.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjubeh}(h]h ]h"]h$]h&]uh1j]hhhKphjubeh}(h]h ]h"]h$]h&]uh1jIhjhhhhhNubah}(h]h ]h"]h$]h&]j-j.uh1jDhhhKnhjhhubeh}(h]#system-runtime-configuration-sysctlah ]h"](2. system runtime configuration (sysctl)ah$]h&]uh1hhhhhhhhKgubh)}(hhh](h)}(h-3. Vector Register State Across System Callsh]h-3. Vector Register State Across System Calls}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhjhhhhhKubh)}(hcAs indicated by version 1.0 of the V extension [1], vector registers are clobbered by system calls.h]hcAs indicated by version 1.0 of the V extension [1], vector registers are clobbered by system calls.}(hjhhhNhNubah}(h]h ]h"]h$]h&]uh1hhhhKhjhhubh)}(hL1: https://github.com/riscv/riscv-v-spec/blob/master/calling-convention.adoch](h1: }(hjhhhNhNubh reference)}(hIhttps://github.com/riscv/riscv-v-spec/blob/master/calling-convention.adoch]hIhttps://github.com/riscv/riscv-v-spec/blob/master/calling-convention.adoc}(hj hhhNhNubah}(h]h ]h"]h$]h&]refurijuh1j hjubeh}(h]h ]h"]h$]h&]uh1hhhhKhjhhubeh}(h])vector-register-state-across-system-callsah ]h"],3. vector register state across system callsah$]h&]uh1hhhhhhhhKubeh}(h])vector-extension-support-for-risc-v-linuxah ]h"])vector extension support for risc-v linuxah$]h&]uh1hhhhhhhhKubeh}(h]h ]h"]h$]h&]sourcehuh1hcurrent_sourceN current_lineNsettingsdocutils.frontendValues)}(hN generatorN datestampN source_linkN source_urlN toc_backlinksentryfootnote_backlinksK sectnum_xformKstrip_commentsNstrip_elements_with_classesN strip_classesN report_levelK halt_levelKexit_status_levelKdebugNwarning_streamN tracebackinput_encoding utf-8-siginput_encoding_error_handlerstrictoutput_encodingutf-8output_encoding_error_handlerjUerror_encodingutf-8error_encoding_error_handlerbackslashreplace language_codeenrecord_dependenciesNconfigN id_prefixhauto_id_prefixid dump_settingsNdump_internalsNdump_transformsNdump_pseudo_xmlNexpose_internalsNstrict_visitorN_disable_configN_sourceh _destinationN _config_files]7/var/lib/git/docbuild/linux/Documentation/docutils.confafile_insertion_enabled raw_enabledKline_length_limitM'pep_referencesN pep_base_urlhttps://peps.python.org/pep_file_url_templatepep-%04drfc_referencesN rfc_base_url&https://datatracker.ietf.org/doc/html/ tab_widthKtrim_footnote_reference_spacesyntax_highlightlong smart_quotessmartquotes_locales]character_level_inline_markupdoctitle_xform docinfo_xformKsectsubtitle_xform image_loadinglinkembed_stylesheetcloak_email_addressessection_self_linkenvNubreporterNindirect_targets]substitution_defs}substitution_names}refnames}refids}nameids}(j/j,jjjjj'j$u nametypes}(j/jjj'uh}(j,hjhjjj$ju footnote_refs} citation_refs} autofootnotes]autofootnote_refs]symbol_footnotes]symbol_footnote_refs] footnotes] citations]autofootnote_startKsymbol_footnote_startK id_counter collectionsCounter}Rparse_messages]transform_messages] transformerN include_log] decorationNhhub.