[v1, 6/6] riscv: vector: adjust minimum Vector requirement to ZVE32X
Joel Granados
j.granados at samsung.com
Wed Mar 13 02:53:02 PDT 2024
On Tue, Mar 12, 2024 at 08:36:27PM +0800, Andy Chiu wrote:
> Make has_vector take one argument. This argument represents the minimum
> Vector subextension that the following Vector actions assume.
>
> Also, change riscv_v_first_use_handler(), and boot code that calls
> riscv_v_setup_vsize() to accept the minimum Vector sub-extension,
> ZVE32X.
>
> Most kernel/user interfaces requires minimum of ZVE32X. Thus, programs
> compiled and run with ZVE32X should be supported by the kernel on most
> aspects. This includes context-switch, signal, ptrace, prctl, and
> hwprobe.
>
> One exception is that ELF_HWCAP returns 'V' only if full V is supported
> on the platform. This means that the system without a full V must not
> rely on ELF_HWCAP to tell whether it is allowable to execute Vector
> without first invoking a prctl() check.
>
> Signed-off-by: Andy Chiu <andy.chiu at sifive.com>
> ---
> arch/riscv/include/asm/switch_to.h | 2 +-
> arch/riscv/include/asm/vector.h | 21 ++++++++++++++-------
> arch/riscv/include/asm/xor.h | 2 +-
> arch/riscv/kernel/cpufeature.c | 5 ++++-
> arch/riscv/kernel/kernel_mode_vector.c | 4 ++--
> arch/riscv/kernel/process.c | 4 ++--
> arch/riscv/kernel/signal.c | 6 +++---
> arch/riscv/kernel/smpboot.c | 2 +-
> arch/riscv/kernel/sys_hwprobe.c | 5 +++--
> arch/riscv/kernel/vector.c | 15 +++++++++------
> arch/riscv/lib/uaccess.S | 2 +-
> 11 files changed, 41 insertions(+), 27 deletions(-)
>
> diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h
> index 7efdb0584d47..df1adf196c4f 100644
> --- a/arch/riscv/include/asm/switch_to.h
> +++ b/arch/riscv/include/asm/switch_to.h
<--- snip --->
>
> long riscv_v_vstate_ctrl_get_current(void)
> {
> - if (!has_vector())
> + if (!has_vector(ZVE32X))
> return -EINVAL;
>
> return current->thread.vstate_ctrl & PR_RISCV_V_VSTATE_CTRL_MASK;
> @@ -246,7 +249,7 @@ long riscv_v_vstate_ctrl_set_current(unsigned long arg)
> bool inherit;
> int cur, next;
>
> - if (!has_vector())
> + if (!has_vector(ZVE32X))
> return -EINVAL;
>
> if (arg & ~PR_RISCV_V_VSTATE_CTRL_MASK)
> @@ -296,7 +299,7 @@ static struct ctl_table riscv_v_default_vstate_table[] = {
>
> static int __init riscv_v_sysctl_init(void)
> {
> - if (has_vector())
> + if (has_vector(ZVE32X))
> if (!register_sysctl("abi", riscv_v_default_vstate_table))
> return -EINVAL;
> return 0;
Not really sure why I got this, it probably has to do with this line :)
I don't see any changes that can affect sysctl here.
Acked-by: Joel Granados <j.granados at samsung.com>
> diff --git a/arch/riscv/lib/uaccess.S b/arch/riscv/lib/uaccess.S
> index bc22c078aba8..bbe143bb32a0 100644
> --- a/arch/riscv/lib/uaccess.S
> +++ b/arch/riscv/lib/uaccess.S
> @@ -14,7 +14,7 @@
>
> SYM_FUNC_START(__asm_copy_to_user)
> #ifdef CONFIG_RISCV_ISA_V
> - ALTERNATIVE("j fallback_scalar_usercopy", "nop", 0, RISCV_ISA_EXT_v, CONFIG_RISCV_ISA_V)
> + ALTERNATIVE("j fallback_scalar_usercopy", "nop", 0, RISCV_ISA_EXT_ZVE32X, CONFIG_RISCV_ISA_V)
> REG_L t0, riscv_v_usercopy_threshold
> bltu a2, t0, fallback_scalar_usercopy
> tail enter_vector_usercopy
> --
> 2.17.1
>
--
Joel Granados
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20240313/5ed3c40d/attachment.sig>
More information about the linux-riscv
mailing list