riscv: Add vector ISA support
Subsystems (5)
v14 cover riscv: Add vector ISA support
This patchset is implemented based on vector 1.0 spec to add vector support in riscv Linux kernel. There are some assumptions for this implementations.
1. We assume all harts has the same ISA in the system.
2. We disable vector in both kernel andy user space [1] by default. Only enable an user's vector after an illegal instruction trap where it actually starts executing vector (the first-use trap [2]).
3. We detect "riscv,isa" to determine whether vector is support or not.
We defined a new structure __riscv_v_ext_state in struct thread_struct to save/restore the vector related registers. It is used for both kernel space and user space.
- In kernel space, the datap pointer in __riscv_v_ext_state will be allocated to save vector registers.
- In user space,
- In signal handler of user space, the structure is placed right after __riscv_ctx_hdr, which is embedded in fp reserved aera. This is required to avoid ABI break [2]. And datap points to the end of __riscv_v_ext_state.
- In ptrace, the data will be put in ubuf in which we use riscv_vr_get()/riscv_vr_set() to get or set the __riscv_v_ext_state data structure from/to it, datap pointer would be zeroed and vector registers will be copied to the address right after the __riscv_v_ext_state structure in ubuf.
This patchset is rebased to v6.2-rc6 and it is tested by running several vector programs simultaneously. It delivers signals correctly in a test where we can see a valid ucontext_t in a signal handler, and a correct V context returing back from it. And the ptrace interface is tested by PTRACE_{GET,SET}REGSET. Lastly, KVM is tested by running above tests in a guest using the same kernel image. All tests are done on a rv64gcv virt QEMU.
Specail thanks to Conor and Vineet for kindly giving help on- and off-list.
Source tree: https://github.com/sifive/riscv-linux/tree/riscv/for-next/vector-v14
Links:
- [1] https://lore.kernel.org/all/20220921214439.1491510-17-stillson at rivosinc.com/
- [2] https://lore.kernel.org/all/73c0124c-4794-6e40-460c-b26df407f322 at rivosinc.com/T/#u
- [3] https://lore.kernel.org/all/20230128082847.3055316-1-apatel at ventanamicro.com/
---
Changelog V14
- Rebase to risc-v -next (v6.2-rc7)
- Use TOOLCHAIN_HAS_V to detect if we can enable Vector. And refine KBUILD_CFLAGS to remove v from default compile option.
- Drop illegal instruction handling patch in kvm and leave it to a independent series[3]. The series is currently queued for 6.3
- Move KVM_RISCV_ISA_EXT_V to the end of enum to prevent potential ABI breaks.
- Use PT_SIZE_ON_STACK instead of PT_SIZE to fit alignment. Also,
remove panic log from v13 (15/19) because it is no longer relevant.
- Rewrite insn_is_vector for better structuring (change if-else chain to
a switch)
- Fix compilation error in the middle of the series
- Validate size of the alternative signal frame if V is enabled
whenever:
- The user call sigaltstack to update altstack
- A signal is being delivered
- Rename __riscv_v_state to __riscv_v_ext_state.
- Add riscv_v_ prefix and rename rvv appropriately
- Organize riscv_v_vsize setup code into vector.c
- Address the issue mentioned by Heiko on !FPU case
- Honor orignal authors that got changed accidentally in v13 4,5,6
Changelog V13
- Rebase to latest risc-v next (v6.2-rc1)
- Re-organize the series to comply with bisect-ability
- Improve task switch with inline assembly
- Re-structure the signal frame to avoid user ABI break.
- Implemnt first-use trap and drop prctl for per-task V state enablement. Also, redirect this trap from hs to vs for kvm setup.
- Do not expose V context in ptrace/sigframe until the task start using V. But still reserve V context for size ofsigframe reported by auxv.
- Drop the kernel mode vector and leave it to another (future) series.
Changelog V12 (Chris)
- rebases to some point after v5.18-rc6
- add prctl to control per-process V state
Chnagelog V10
- Rebase to v5.18-rc6
- Merge several patches
- Refine codes
- Fix bugs
- Add kvm vector support
Changelog V9
- Rebase to v5.15
- Merge several patches
- Refine codes
- Fix a kernel panic issue
Changelog V8
- Rebase to v5.14
- Refine struct __riscv_v_ext_state with struct __riscv_ctx_hdr
- Refine has_vector into a static key
- Defined __reserved space in struct sigcontext for vector and future extensions
Changelog V7
- Add support for kernel mode vector
- Add vector extension XOR implementation
- Optimize task switch codes of vector
- Allocate space for vector registers in start_thread()
- Fix an illegal instruction exception when accessing vlenb
- Optimize vector registers initialization
- Initialize vector registers with proper vsetvli then it can work normally
- Refine ptrace porting due to generic API changed
- Code clean up
Changelog V6
- Replace vle.v/vse.v instructions with vle8.v/vse8.v based on 0.9 spec
- Add comments based on mailinglist feedback
- Fix rv32 build error
Changelog V5
- Using regset_size() correctly in generic ptrace
- Fix the ptrace porting
- Fix compile warning
Changelog V4
- Support dynamic vlen
- Fix bugs: lazy save/resotre, not saving vtype
- Update VS bit offset based on latest vector spec
- Add new vector csr based on latest vector spec
- Code refine and removed unused macros
Changelog V3
- Rebase linux-5.6-rc3 and tested with qemu
- Seperate patches with Anup's advice
- Give out a ABI puzzle with unlimited vlen
Changelog V2
- Fixup typo "vecotr, fstate_save->vstate_save".
- Fixup wrong saved registers' length in vector.S.
- Seperate unrelated patches from this one.
Andy Chiu (3):
riscv: Allocate user's vector context in the first-use trap
riscv: signal: check fp-reserved words unconditionally
riscv: signal: validate altstack to reflect Vector
Greentime Hu (9):
riscv: Add new csr defines related to vector extension
riscv: Clear vector regfile on bootup
riscv: Introduce Vector enable/disable helpers
riscv: Introduce riscv_v_vsize to record size of Vector context
riscv: Introduce struct/helpers to save/restore per-task Vector state
riscv: Add task switch support for vector
riscv: Add ptrace vector support
riscv: signal: Add sigcontext save/restore for vector
riscv: prevent stack corruption by reserving task_pt_regs(p) early
Guo Ren (4):
riscv: Rename __switch_to_aux -> fpu
riscv: Extending cpufeature.c to detect V-extension
riscv: Disable Vector Instructions for kernel itself
riscv: Enable Vector code to be built
Vincent Chen (3):
riscv: signal: Report signal frame size to userspace via auxv
riscv: kvm: Add V extension to KVM ISA
riscv: KVM: Add vector lazy save/restore support
arch/riscv/Kconfig | 18 ++ arch/riscv/Makefile | 3 +- arch/riscv/include/asm/csr.h | 18 +- arch/riscv/include/asm/elf.h | 9 + arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/insn.h | 29 +++ arch/riscv/include/asm/kvm_host.h | 2 + arch/riscv/include/asm/kvm_vcpu_vector.h | 77 ++++++++ arch/riscv/include/asm/processor.h | 3 + arch/riscv/include/asm/switch_to.h | 9 +- arch/riscv/include/asm/thread_info.h | 3 + arch/riscv/include/asm/vector.h | 167 +++++++++++++++++ arch/riscv/include/uapi/asm/auxvec.h | 1 + arch/riscv/include/uapi/asm/hwcap.h | 1 + arch/riscv/include/uapi/asm/kvm.h | 8 + arch/riscv/include/uapi/asm/ptrace.h | 39 ++++ arch/riscv/include/uapi/asm/sigcontext.h | 16 +- arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/cpufeature.c | 13 ++ arch/riscv/kernel/entry.S | 6 +- arch/riscv/kernel/head.S | 41 ++++- arch/riscv/kernel/process.c | 18 ++ arch/riscv/kernel/ptrace.c | 71 ++++++++ arch/riscv/kernel/setup.c | 3 + arch/riscv/kernel/signal.c | 221 ++++++++++++++++++++--- arch/riscv/kernel/traps.c | 14 +- arch/riscv/kernel/vector.c | 112 ++++++++++++ arch/riscv/kvm/Makefile | 1 + arch/riscv/kvm/vcpu.c | 31 ++++ arch/riscv/kvm/vcpu_vector.c | 177 ++++++++++++++++++ include/uapi/linux/elf.h | 1 + 31 files changed, 1066 insertions(+), 48 deletions(-) create mode 100644 arch/riscv/include/asm/kvm_vcpu_vector.h create mode 100644 arch/riscv/include/asm/vector.h create mode 100644 arch/riscv/kernel/vector.c create mode 100644 arch/riscv/kvm/vcpu_vector.c
Signature · 1 line
2.17.1
PATCH v14 1/19 riscv: Rename __switch_to_aux -> fpu
From: Guo Ren <[email protected]>
The name of __switch_to_aux is not clear and rename it with the determine function: __switch_to_fpu. Next we could add other regs' switch.
--- arch/riscv/include/asm/switch_to.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
arch/riscv/include/asm/switch_to.h +3 -3
@@ -46,7 +46,7 @@ static inline void fstate_restore(struct task_struct *task, } } -static inline void __switch_to_aux (struct task_struct *prev, +static inline void __switch_to_fpu (struct task_struct *prev,struct task_struct *next) {struct pt_regs *regs;
@@ -66,7 +66,7 @@ static __always_inline bool has_fpu(void) static __always_inline bool has_fpu(void) { return false; }#define fstate_save (task, regs) do { } while (0)#define fstate_restore (task, regs) do { } while (0) -#define __switch_to_aux (__prev, __next) do { } while (0) +#define __switch_to_fpu (__prev, __next) do { } while (0)#endif extern struct task_struct *__switch_to(struct task_struct *,
@@ -77,7 +77,7 @@ do { \struct task_struct *__prev = (prev); \struct task_struct *__next = (next); \if (has_fpu ()) \ -__switch_to_aux (__prev, __next); \ +__switch_to_fpu (__prev, __next); \ ((last) =__switch_to (__prev, __next)); \ }while (0 )
Signature · 1 line
2.17.1
Re: [PATCH -next v14 01/19] riscv: Rename __switch_to_aux -> fpu
Quoted 6 lines · Andy Chiu
From: Guo Ren <[email protected]>
The name of
__switch_to_auxis not clear and rename it with the determine function:__switch_to_fpu. Next we could add other regs' switch.
Quoted 8 lines
Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Signed-off-by Greentime Hu <[email protected]>Reviewed-by Anup Patel <[email protected]>Reviewed-by Palmer Dabbelt <[email protected]>Signed-off-by Andy Chiu <[email protected]>Tested-by Heiko Stuebner <[email protected]>Reviewed-by Heiko Stuebner <[email protected]>
Suppose I shall tack myself onto the end of this list...
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230228/972708b2/attachment-0001.sig>
PATCH v14 2/19 riscv: Extending cpufeature.c to detect V-extension
In reply to Andy ChiuFrom: Guo Ren <[email protected]>
Add V-extension into riscv_isa_ext_keys array and detect it with isa string parsing.
--- arch/riscv/include/asm/hwcap.h | 1 + arch/riscv/include/asm/vector.h | 26 ++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/hwcap.h | 1 + arch/riscv/kernel/cpufeature.c | 11 +++++++++++ 4 files changed, 39 insertions(+) create mode 100644 arch/riscv/include/asm/vector.h
arch/riscv/include/asm/hwcap.h +1 -0
@@ -22,6 +22,7 @@#define RISCV_ISA_EXT_m ('m' - 'a')#define RISCV_ISA_EXT_s ('s' - 'a')#define RISCV_ISA_EXT_u ('u' - 'a') +#define RISCV_ISA_EXT_v ('v' - 'a')/* * These macros represent the logical IDs of each multi-letter RISC-V ISA
arch/riscv/include/asm/vector.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ +/* +* Copyright (C) 2020 SiFive +*/ + +#ifndef __ASM_RISCV_VECTOR_H +#define __ASM_RISCV_VECTOR_H + +#include <linux/types.h> + +#ifdef CONFIG_RISCV_ISA_V + +#include <asm/hwcap.h> + +static __always_inline bool has_vector(void) +{ +return riscv_has_extension_likely (RISCV_ISA_EXT_v); +} + +#else /* ! CONFIG_RISCV_ISA_V */ + +static __always_inline bool has_vector(void) { return false; } + +#endif /* CONFIG_RISCV_ISA_V */ + +#endif /* ! __ASM_RISCV_VECTOR_H */
arch/riscv/include/uapi/asm/hwcap.h +1 -0
@@ -21,5 +21,6 @@#define COMPAT_HWCAP_ISA_F (1 << ('F' - 'A'))#define COMPAT_HWCAP_ISA_D (1 << ('D' - 'A'))#define COMPAT_HWCAP_ISA_C (1 << ('C' - 'A')) +#define COMPAT_HWCAP_ISA_V (1 << ('V' - 'A'))#endif /* _UAPI_ASM_RISCV_HWCAP_H */
arch/riscv/kernel/cpufeature.c +11 -0
@@ -99,6 +99,7 @@ void __init riscv_fill_hwcap(void) isa2hwcap['f' -'a' ] =COMPAT_HWCAP_ISA_F ; isa2hwcap['d' -'a' ] =COMPAT_HWCAP_ISA_D ; isa2hwcap['c' -'a' ] =COMPAT_HWCAP_ISA_C ; + isa2hwcap['v' -'a' ] =COMPAT_HWCAP_ISA_V ; elf_hwcap =0 ;
@@ -255,6 +256,16 @@ void __init riscv_fill_hwcap(void) elf_hwcap &= ~COMPAT_HWCAP_ISA_F ; } +if (elf_hwcap &COMPAT_HWCAP_ISA_V ) { +/* +* ISA string in device tree might have 'v' flag, but +* CONFIG_RISCV_ISA_V is disabled in kernel. +* Clear V flag in elf_hwcap if CONFIG_RISCV_ISA_V is disabled. +*/ +if (!IS_ENABLED (CONFIG_RISCV_ISA_V )) + elf_hwcap &= ~COMPAT_HWCAP_ISA_V ; + } +memset (print_str,0 ,sizeof (print_str));for (i =0 , j =0 ; i <NUM_ALPHA_EXTS ; i++)if (riscv_isa[0 ] &BIT_MASK (i))
Signature · 1 line
2.17.1
Re: [PATCH -next v14 02/19] riscv: Extending cpufeature.c to detect V-extension
Quoted 10 lines · Andy Chiu
From: Guo Ren <[email protected]>
Add V-extension into
riscv_isa_ext_keysarray and detect it with isa string parsing.Signed-off-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Signed-off-by Greentime Hu <[email protected]>Suggested-by Vineet Gupta <[email protected]>Signed-off-by Andy Chiu <[email protected]>
Looks grand, and thanks for switching to IS_ENABLED().
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230228/9c2560e5/attachment-0001.sig>
PATCH v14 3/19 riscv: Add new csr defines related to vector extension
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
Follow the riscv vector spec to add new csr numbers.
--- arch/riscv/include/asm/csr.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)
arch/riscv/include/asm/csr.h +16 -2
@@ -24,16 +24,24 @@#define SR_FS_CLEAN _AC(0x00004000, UL)#define SR_FS_DIRTY _AC(0x00006000, UL) +#define SR_VS _AC(0x00000600, UL)/* Vector Status */ +#define SR_VS_OFF _AC(0x00000000, UL) +#define SR_VS_INITIAL _AC(0x00000200, UL) +#define SR_VS_CLEAN _AC(0x00000400, UL) +#define SR_VS_DIRTY _AC(0x00000600, UL) +#define SR_XS _AC(0x00018000, UL)/* Extension Status */ #define SR_XS_OFF _AC(0x00000000, UL)#define SR_XS_INITIAL _AC(0x00008000, UL)#define SR_XS_CLEAN _AC(0x00010000, UL)#define SR_XS_DIRTY _AC(0x00018000, UL) +#define SR_FS_VS (SR_FS | SR_VS)/* Vector and Floating-Point Unit */ +#ifndef CONFIG_64BIT -#define SR_SD _AC(0x80000000, UL)/* FS/XS dirty */ +#define SR_SD _AC(0x80000000, UL)/* FS/VS/XS dirty */ #else -#define SR_SD _AC(0x8000000000000000, UL)/* FS/XS dirty */ +#define SR_SD _AC(0x8000000000000000, UL)/* FS/VS/XS dirty */ #endif #ifdef CONFIG_64BIT
@@ -297,6 +305,12 @@#define CSR_MIMPID 0xf13#define CSR_MHARTID 0xf14 +#define CSR_VSTART 0x8 +#define CSR_VCSR 0xf +#define CSR_VL 0xc20 +#define CSR_VTYPE 0xc21 +#define CSR_VLENB 0xc22 +#ifdef CONFIG_RISCV_M_MODE # define CSR_STATUS CSR_MSTATUS# define CSR_IE CSR_MIE
Signature · 1 line
2.17.1
Re: [PATCH -next v14 03/19] riscv: Add new csr defines related to vector extension
Quoted 26 lines · Andy Chiu
From: Greentime Hu <[email protected]>
Follow the riscv vector spec to add new csr numbers.
[[email protected]: first porting for new vector related csr]Acked-by Guo Ren <[email protected]>Co-developed-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Reviewed-by Palmer Dabbelt <[email protected]>Suggested-by Vineet Gupta <[email protected]>Signed-off-by Andy Chiu <[email protected]>[andyc: added SR_FS_VS]Reviewed-by Conor Dooley <[email protected]>Reviewed-by Heiko Stuebner <[email protected]>--- arch/riscv/include/asm/csr.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-)arch/riscv/include/asm/csr.h +0
-0
arch/riscv/include/asm/csr.h line 31
Quoted 8 lines
arch/riscv/include/asm/csr.h +5
-0@@ -24,16 +24,24 @@#define SR_FS_CLEAN _AC(0x00004000, UL)#define SR_FS_DIRTY _AC(0x00006000, UL) +#define SR_VS _AC(0x00000600, UL)/* Vector Status */ +#define SR_VS_OFF _AC(0x00000000, UL) +#define SR_VS_INITIAL _AC(0x00000200, UL) +#define SR_VS_CLEAN _AC(0x00000400, UL) +#define SR_VS_DIRTY _AC(0x00000600, UL)
I just noticed that these are space-aligned, while the file uses tabs. Could you please fix that up when you resubmit?
Thanks,
Conor.
PATCH v14 4/19 riscv: Clear vector regfile on bootup
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
clear vector registers on boot if kernel supports V.
--- arch/riscv/kernel/head.S | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-)
arch/riscv/kernel/head.S +25 -2
@@ -392,7 +392,7 @@ ENTRY(reset_regs) #ifdef CONFIG_FPU csrr t0, CSR_MISA andi t0, t0, (COMPAT_HWCAP_ISA_F | COMPAT_HWCAP_ISA_D) - beqz t0, .Lreset_regs_done + beqz t0, .Lreset_regs_done_fpu li t1, SR_FS csrs CSR_STATUS, t1
@@ -430,8 +430,31 @@ ENTRY(reset_regs) fmv.s.x f31, zero csrw fcsr, 0 /* note that the caller must clear SR_FS */ +.Lreset_regs_done_fpu: #endif /* CONFIG_FPU */ -.Lreset_regs_done: + +#ifdef CONFIG_RISCV_ISA_V + csrr t0, CSR_MISA + li t1, COMPAT_HWCAP_ISA_V + and t0, t0, t1 + beqz t0, .Lreset_regs_done_vector + + /* + * Clear vector registers and reset vcsr + * VLMAX has a defined value, VLEN is a constant, + * and this form of vsetvli is defined to set vl to VLMAX. + */ + li t1, SR_VS + csrs CSR_STATUS, t1 + csrs CSR_VCSR, x0 + vsetvli t1, x0, e8, m8, ta, ma + vmv.v.i v0, 0 + vmv.v.i v8, 0 + vmv.v.i v16, 0 + vmv.v.i v24, 0 + /* note that the caller must clear SR_VS */ +.Lreset_regs_done_vector: +#endif /* CONFIG_RISCV_ISA_V */ ret END(reset_regs) #endif /* CONFIG_RISCV_M_MODE */
Signature · 1 line
2.17.1
Re: [PATCH -next v14 04/19] riscv: Clear vector regfile on bootup
Quoted 8 lines · Andy Chiu
From: Greentime Hu <[email protected]>
clear vector registers on boot if kernel supports V.
Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vineet Gupta <[email protected]>[vineetg: broke this out to a seperate patch]Signed-off-by Andy Chiu <[email protected]>
PATCH v14 5/19 riscv: Disable Vector Instructions for kernel itself
In reply to Andy ChiuFrom: Guo Ren <[email protected]>
Disable vector instructions execution for kernel mode at its entrances.
--- arch/riscv/kernel/entry.S | 6 +++--- arch/riscv/kernel/head.S | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-)
arch/riscv/kernel/entry.S +3 -3
@@ -77,10 +77,10 @@ _save_context: * Disable user-mode memory access as it should only be set in the * actual user copy routines. * - * Disable the FPU to detect illegal usage of floating point in kernel - * space. + * Disable the FPU/Vector to detect illegal usage of floating point + * or vector in kernel space. */ - li t0, SR_SUM | SR_FS + li t0, SR_SUM | SR_FS_VS REG_L s0, TASK_TI_USER_SP(tp) csrrc s1, CSR_STATUS, t0
arch/riscv/kernel/head.S +6 -6
@@ -140,10 +140,10 @@ secondary_start_sbi: .option pop /* - * Disable FPU to detect illegal usage of - * floating point in kernel space + * Disable FPU & VECTOR to detect illegal usage of + * floating point or vector in kernel space */ - li t0, SR_FS + li t0, SR_FS_VS csrc CSR_STATUS, t0 /* Set trap vector to spin forever to help debug */
@@ -234,10 +234,10 @@ pmp_done: .option pop /* - * Disable FPU to detect illegal usage of - * floating point in kernel space + * Disable FPU & VECTOR to detect illegal usage of + * floating point or vector in kernel space */ - li t0, SR_FS + li t0, SR_FS_VS csrc CSR_STATUS, t0 #ifdef CONFIG_RISCV_BOOT_SPINWAIT
Signature · 1 line
2.17.1
PATCH v14 6/19 riscv: Introduce Vector enable/disable helpers
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
These are small and likely to be frequently called so implement as inline routines (vs. function call).
--- arch/riscv/include/asm/vector.h | 11 +++++++++++ 1 file changed, 11 insertions(+)
arch/riscv/include/asm/vector.h +11 -0
@@ -11,12 +11,23 @@#ifdef CONFIG_RISCV_ISA_V #include <asm/hwcap.h> +#include <asm/csr.h> static __always_inline bool has_vector(void) {return riscv_has_extension_likely (RISCV_ISA_EXT_v); } +static __always_inline void riscv_v_enable(void) +{ +csr_set (CSR_SSTATUS ,SR_VS ); +} + +static __always_inline void riscv_v_disable(void) +{ +csr_clear (CSR_SSTATUS ,SR_VS ); +} +#else /* ! CONFIG_RISCV_ISA_V */ static __always_inline bool has_vector(void) { return false; }
Signature · 1 line
2.17.1
Re: [PATCH -next v14 06/19] riscv: Introduce Vector enable/disable helpers
Quoted 5 lines · Andy Chiu
From: Greentime Hu <[email protected]>
These are small and likely to be frequently called so implement as inline routines (vs. function call).
Quoted 9 lines
Co-developed-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vineet Gupta <[email protected]>[vineetg: create new patch from meshup, introduced asm variant]Signed-off-by Andy Chiu <[email protected]>[andy.chiu: remove calls from asm thus remove asm vaiant]
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230228/bc2760a8/attachment-0001.sig>
PATCH v14 7/19 riscv: Introduce riscv_v_vsize to record size of Vector context
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
This patch is used to detect the size of CPU vector registers and use riscv_v_vsize to save the size of all the vector registers. It assumes all harts has the same capabilities in a SMP system.
--- arch/riscv/include/asm/vector.h | 5 +++++ arch/riscv/kernel/Makefile | 1 + arch/riscv/kernel/cpufeature.c | 2 ++ arch/riscv/kernel/vector.c | 21 +++++++++++++++++++++ 4 files changed, 29 insertions(+) create mode 100644 arch/riscv/kernel/vector.c
arch/riscv/include/asm/vector.h +5 -0
@@ -13,6 +13,9 @@#include <asm/hwcap.h> #include <asm/csr.h> +extern unsigned long riscv_v_vsize; +void riscv_v_setup_vsize (void ); + static __always_inline bool has_vector(void) {return riscv_has_extension_likely (RISCV_ISA_EXT_v);
@@ -31,6 +34,8 @@ static __always_inline void riscv_v_disable(void)#else /* ! CONFIG_RISCV_ISA_V */ static __always_inline bool has_vector(void) { return false; } +#define riscv_v_vsize (0) +#define riscv_v_setup_vsize () do {} while (0)#endif /* CONFIG_RISCV_ISA_V */
arch/riscv/kernel/Makefile +1 -0
@@ -55,6 +55,7 @@ obj-$(CONFIG_MMU) += vdso.o vdso/ obj-$(CONFIG_RISCV_M_MODE) += traps_misaligned.o obj-$(CONFIG_FPU) += fpu.o +obj-$(CONFIG_RISCV_ISA_V) += vector.o obj-$(CONFIG_SMP) += smpboot.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SMP) += cpu_ops.o
arch/riscv/kernel/cpufeature.c +2 -0
@@ -22,6 +22,7 @@#include <asm/processor.h> #include <asm/smp.h> #include <asm/switch_to.h> +#include <asm/vector.h> #define NUM_ALPHA_EXTS ('z' - 'a' + 1)
@@ -257,6 +258,7 @@ void __init riscv_fill_hwcap(void) }if (elf_hwcap &COMPAT_HWCAP_ISA_V ) { +riscv_v_setup_vsize ();/* * ISA string in device tree might have 'v' flag, but * CONFIG_RISCV_ISA_V is disabled in kernel.
arch/riscv/kernel/vector.c new file +21 -0
@@ -0,0 +1,21 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (C) 2023 SiFive +* Author: Andy Chiu <[email protected]> +*/ +#include <linux/export.h> + +#include <asm/vector.h> +#include <asm/csr.h> + +unsigned long riscv_v_vsize__read_mostly ; +EXPORT_SYMBOL_GPL (riscv_v_vsize); + +void riscv_v_setup_vsize (void ) +{ +/* There are 32 vector registers with vlenb length. */ +riscv_v_enable (); + riscv_v_vsize =csr_read (CSR_VLENB ) *32 ; +riscv_v_disable (); +} +
Signature · 1 line
2.17.1
Re: [PATCH -next v14 07/19] riscv: Introduce riscv_v_vsize to record size of Vector context
Quoted 6 lines · Andy Chiu
From: Greentime Hu <[email protected]>
This patch is used to detect the size of CPU vector registers and use
riscv_v_vsizeto save the size of all the vector registers. It assumes all harts has the same capabilities in a SMP system.
Quoted 7 lines
[guoren at linux.alibaba.com: add has_vector checking]Co-developed-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Andy Chiu <[email protected]>
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230228/0563a2f5/attachment-0001.sig>
PATCH v14 8/19 riscv: Introduce struct/helpers to save/restore per-task Vector state
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
Add vector state context struct to be added later in thread_struct. And prepare low-level helper functions to save/restore vector contexts.
This include Vector Regfile and CSRs holding dynamic configuration state (vstart, vl, vtype, vcsr). The Vec Register width could be implementation defined, but same for all processes, so that is saved separately.
This is not yet wired into final thread_struct - will be done when __switch_to actually starts doing this in later patches.
Given the variable (and potentially large) size of regfile, they are saved in dynamically allocated memory, pointed to by datap pointer in __riscv_v_ext_state.
--- arch/riscv/include/asm/vector.h | 84 ++++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/ptrace.h | 17 ++++++ 2 files changed, 101 insertions(+)
arch/riscv/include/asm/vector.h +84 -0
@@ -12,6 +12,9 @@#include <asm/hwcap.h> #include <asm/csr.h> +#include <asm/asm.h> + +#define CSR_STR (x) __ASM_STR(x)extern unsigned long riscv_v_vsize;void riscv_v_setup_vsize (void );
@@ -21,6 +24,26 @@ static __always_inline bool has_vector(void)return riscv_has_extension_likely (RISCV_ISA_EXT_v); } +static inline void __riscv_v_vstate_clean (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_CLEAN ; +} + +static inline void riscv_v_vstate_off (struct pt_regs *regs) +{ + regs->status = (regs->status & ~SR_VS ) |SR_VS_OFF ; +} + +static inline void riscv_v_vstate_on (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_INITIAL ; +} + +static inline bool riscv_v_vstate_query (struct pt_regs *regs) +{ +return (regs->status &SR_VS ) !=0 ; +} + static __always_inline void riscv_v_enable(void) {csr_set (CSR_SSTATUS ,SR_VS );
@@ -31,11 +54,72 @@ static __always_inline void riscv_v_disable(void)csr_clear (CSR_SSTATUS ,SR_VS ); } +static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest) +{ + asmvolatile ( + "csrr %0, " CSR_STR(CSR_VSTART) "\n\t" + "csrr %1, " CSR_STR(CSR_VTYPE) "\n\t" + "csrr %2, " CSR_STR(CSR_VL) "\n\t" + "csrr %3, " CSR_STR(CSR_VCSR) "\n\t" + : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), + "=r" (dest->vcsr) : :); +} + +static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src) +{ + asmvolatile ( +"vsetvl x0, %2, %1\n\t" + "csrw " CSR_STR(CSR_VSTART) ", %0\n\t" + "csrw " CSR_STR(CSR_VCSR) ", %3\n\t" + : : "r" (src->vstart), "r" (src->vtype), "r" (src->vl), + "r" (src->vcsr) :); +} + +static inline void __riscv_v_vstate_save (struct __riscv_v_ext_state *save_to,void *datap) +{ +riscv_v_enable (); +__vstate_csr_save (save_to); + asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vse8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v8, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v16, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v24, (%0)\n\t" + : :"r" (datap) :"t4" ,"memory" ); +riscv_v_disable (); +} + +static inline void __riscv_v_vstate_restore (struct __riscv_v_ext_state *restore_from, +void *datap) +{ +riscv_v_enable (); + asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vle8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v8, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v16, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v24, (%0)\n\t" + : :"r" (datap) :"t4" ); +__vstate_csr_restore (restore_from); +riscv_v_disable (); +} +#else /* ! CONFIG_RISCV_ISA_V */ +struct pt_regs ; + static __always_inline bool has_vector(void) { return false; } +static inline bool riscv_v_vstate_query (struct pt_regs *regs) {return false; }#define riscv_v_vsize (0)#define riscv_v_setup_vsize () do {} while (0) +#define riscv_v_vstate_off (regs) do {} while (0) +#define riscv_v_vstate_on (regs) do {} while (0)#endif /* CONFIG_RISCV_ISA_V */
arch/riscv/include/uapi/asm/ptrace.h +17 -0
@@ -77,6 +77,23 @@ union __riscv_fp_state {struct __riscv_q_ext_state q; }; +struct __riscv_v_ext_state { +unsigned long vstart; +unsigned long vl; +unsigned long vtype; +unsigned long vcsr; +void *datap; +/* +* In signal handler, datap will be set a correct user stack offset +* and vector registers will be copied to the address of datap +* pointer. +* +* In ptrace syscall, datap will be set to zero and the vector +* registers will be copied to the address right after this +* structure. +*/ +}; +#endif /* __ASSEMBLY__ */ #endif /* _UAPI_ASM_RISCV_PTRACE_H */
Signature · 1 line
2.17.1
Re: [PATCH -next v14 08/19] riscv: Introduce struct/helpers to save/restore per-task Vector state
Quoted 33 lines · Andy Chiu
From: Greentime Hu <[email protected]>
Add vector state context struct to be added later in
thread_struct. And prepare low-level helper functions to save/restore vector contexts.This include Vector Regfile and CSRs holding dynamic configuration state (vstart, vl, vtype, vcsr). The Vec Register width could be implementation defined, but same for all processes, so that is saved separately.
This is not yet wired into final
thread_struct- will be done when__switch_toactually starts doing this in later patches.Given the variable (and potentially large) size of regfile, they are saved in dynamically allocated memory, pointed to by datap pointer in
__riscv_v_ext_state.Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vineet Gupta <[email protected]>[vineetg: merged bits from 2 different patches]Signed-off-by Andy Chiu <[email protected]>[andy.chiu: use inline asm to save/restore context, remove asm vaiant]--- arch/riscv/include/asm/vector.h | 84 ++++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/ptrace.h | 17 ++++++ 2 files changed, 101 insertions(+)arch/riscv/include/asm/vector.h +0
-0
arch/riscv/include/asm/vector.h line 17
Quoted 6 lines
arch/riscv/include/asm/vector.h +3
-0@@ -12,6 +12,9 @@#include <asm/hwcap.h> #include <asm/csr.h> +#include <asm/asm.h> + +#define CSR_STR (x) __ASM_STR(x)
TBH, I'm not really sure what this definition adds.
Quoted 4 lines
arch/riscv/include/asm/vector.h +0
-0extern unsigned long riscv_v_vsize;void riscv_v_setup_vsize (void );@@ -21,6 +24,26 @@ static __always_inline bool has_vector(void)return riscv_has_extension_likely (RISCV_ISA_EXT_v);
arch/riscv/include/asm/vector.h static __always_inline bool has_vector(void) · line 34
Quoted 10 lines
arch/riscv/include/asm/vector.h +8
-0} +static inline void __riscv_v_vstate_clean (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_CLEAN ; +} + +static inline void riscv_v_vstate_off (struct pt_regs *regs) +{ + regs->status = (regs->status & ~SR_VS ) |SR_VS_OFF ;
Inconsistent use of brackets here compared to the other items. They're not actually needed anywhere here, are they?
arch/riscv/include/asm/vector.h static __always_inline bool has_vector(void) · line 40
Quoted 6 lines
arch/riscv/include/asm/vector.h +6
-0+} + +static inline void riscv_v_vstate_on (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_INITIAL ; +}
Other than that, this seems fine? I only really had a quick check of the asm though, so with the brackets thing fixed up:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230228/fbe9a099/attachment-0001.sig>
Re: [PATCH -next v14 08/19] riscv: Introduce struct/helpers to save/restore per-task Vector state
Quoted 36 lines · On Wed, Mar 1, 2023 at 7:00?AM Conor Dooley <[email protected]> wrote:
Quoted 34 lines · Andy Chiu
From: Greentime Hu <[email protected]>
Add vector state context struct to be added later in
thread_struct. And prepare low-level helper functions to save/restore vector contexts.This include Vector Regfile and CSRs holding dynamic configuration state (vstart, vl, vtype, vcsr). The Vec Register width could be implementation defined, but same for all processes, so that is saved separately.
This is not yet wired into final
thread_struct- will be done when__switch_toactually starts doing this in later patches.Given the variable (and potentially large) size of regfile, they are saved in dynamically allocated memory, pointed to by datap pointer in
__riscv_v_ext_state.Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vineet Gupta <[email protected]>[vineetg: merged bits from 2 different patches]Signed-off-by Andy Chiu <[email protected]>[andy.chiu: use inline asm to save/restore context, remove asm vaiant]--- arch/riscv/include/asm/vector.h | 84 ++++++++++++++++++++++++++++ arch/riscv/include/uapi/asm/ptrace.h | 17 ++++++ 2 files changed, 101 insertions(+)arch/riscv/include/asm/vector.h +0
-0@@ -12,6 +12,9 @@
Quoted 8 lines
arch/riscv/include/asm/vector.h line 17
Quoted 5 lines
arch/riscv/include/asm/vector.h +3
-0#include <asm/hwcap.h> #include <asm/csr.h> +#include <asm/asm.h> + +#define CSR_STR (x) __ASM_STR(x)TBH, I'm not really sure what this definition adds.
Agree, I'm going to drop this #define and use __ASM_STR directly. However, we should not replace the inline asm to csr_read because csr_read clobbers memory and we don't.
Quoted 6 lines
Quoted 6 lines
arch/riscv/include/asm/vector.h +0
-0extern unsigned long riscv_v_vsize;void riscv_v_setup_vsize (void );@@ -21,6 +24,26 @@ static __always_inline bool has_vector(void)return riscv_has_extension_likely (RISCV_ISA_EXT_v); }
Quoted 12 lines
arch/riscv/include/asm/vector.h static __always_inline bool has_vector(void) · line 34
Quoted 8 lines
arch/riscv/include/asm/vector.h +8
-0+static inline void __riscv_v_vstate_clean (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_CLEAN ; +} + +static inline void riscv_v_vstate_off (struct pt_regs *regs) +{ + regs->status = (regs->status & ~SR_VS ) |SR_VS_OFF ;Inconsistent use of brackets here compared to the other items. They're not actually needed anywhere here, are they?
Yes, there is no need for brackets at SR_VS because it expands to one constant value.
Quoted 10 lines
arch/riscv/include/asm/vector.h static __always_inline bool has_vector(void) · line 40
Quoted 6 lines
arch/riscv/include/asm/vector.h +6
-0+} + +static inline void riscv_v_vstate_on (struct pt_regs *regs) +{ + regs->status = (regs->status & ~(SR_VS )) |SR_VS_INITIAL ; +}Other than that, this seems fine? I only really had a quick check of the asm though, so with the brackets thing fixed up:
Acked-by Conor Dooley <[email protected]>
Re: [PATCH -next v14 08/19] riscv: Introduce struct/helpers to save/restore per-task Vector state
In reply to Andy ChiuQuoted 50 lines · Andy Chiu
arch/riscv/include/asm/vector.h +42
-0@@ -31,11 +54,72 @@ static __always_inline void riscv_v_disable(void)csr_clear (CSR_SSTATUS ,SR_VS ); } +static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest) +{ + asmvolatile ( + "csrr %0, " CSR_STR(CSR_VSTART) "\n\t" + "csrr %1, " CSR_STR(CSR_VTYPE) "\n\t" + "csrr %2, " CSR_STR(CSR_VL) "\n\t" + "csrr %3, " CSR_STR(CSR_VCSR) "\n\t" + : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), + "=r" (dest->vcsr) : :); +} + +static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src) +{ + asmvolatile ( +"vsetvl x0, %2, %1\n\t" + "csrw " CSR_STR(CSR_VSTART) ", %0\n\t" + "csrw " CSR_STR(CSR_VCSR) ", %3\n\t" + : : "r" (src->vstart), "r" (src->vtype), "r" (src->vl), + "r" (src->vcsr) :); +} + +static inline void __riscv_v_vstate_save (struct __riscv_v_ext_state *save_to,void *datap) +{ +riscv_v_enable (); +__vstate_csr_save (save_to); + asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vse8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v8, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v16, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v24, (%0)\n\t" + : :"r" (datap) :"t4" ,"memory" ); +riscv_v_disable (); +} + +static inline void __riscv_v_vstate_restore (struct __riscv_v_ext_state *restore_from, +void *datap) +{ +riscv_v_enable ();
arch/riscv/include/asm/vector.h static __always_inline void riscv_v_disable(void) · line 108
Quoted 10 lines
arch/riscv/include/asm/vector.h +10
-0+ asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vle8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v8, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v16, (%0)\n\t" +"add %0, %0, t4\n\t" +"vle8.v v24, (%0)\n\t" + : :"r" (datap) :"t4" );
Nit/question: For both enable/disable; Any reason to clobber t4, instead of using a scratch reg?
Bj?rn
Re: [PATCH -next v14 08/19] riscv: Introduce struct/helpers to save/restore per-task Vector state
Quoted 58 lines · On Thu, Mar 2, 2023 at 7:13?PM Bj?rn T?pel <[email protected]> wrote:
Quoted 55 lines · Andy Chiu
arch/riscv/include/asm/vector.h +47
-0@@ -31,11 +54,72 @@ static __always_inline void riscv_v_disable(void)csr_clear (CSR_SSTATUS ,SR_VS ); } +static __always_inline void __vstate_csr_save(struct __riscv_v_ext_state *dest) +{ + asmvolatile ( + "csrr %0, " CSR_STR(CSR_VSTART) "\n\t" + "csrr %1, " CSR_STR(CSR_VTYPE) "\n\t" + "csrr %2, " CSR_STR(CSR_VL) "\n\t" + "csrr %3, " CSR_STR(CSR_VCSR) "\n\t" + : "=r" (dest->vstart), "=r" (dest->vtype), "=r" (dest->vl), + "=r" (dest->vcsr) : :); +} + +static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src) +{ + asmvolatile ( +"vsetvl x0, %2, %1\n\t" + "csrw " CSR_STR(CSR_VSTART) ", %0\n\t" + "csrw " CSR_STR(CSR_VCSR) ", %3\n\t" + : : "r" (src->vstart), "r" (src->vtype), "r" (src->vl), + "r" (src->vcsr) :); +} + +static inline void __riscv_v_vstate_save (struct __riscv_v_ext_state *save_to,void *datap) +{ +riscv_v_enable (); +__vstate_csr_save (save_to); + asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vse8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v8, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v16, (%0)\n\t" +"add %0, %0, t4\n\t" +"vse8.v v24, (%0)\n\t" + : :"r" (datap) :"t4" ,"memory" ); +riscv_v_disable (); +} + +static inline void __riscv_v_vstate_restore (struct __riscv_v_ext_state *restore_from, +void *datap) +{ +riscv_v_enable (); + asmvolatile ( +"vsetvli t4, x0, e8, m8, ta, ma\n\t" +"vle8.v v0, (%0)\n\t" +"add %0, %0, t4\n\t" + "vle8.v v8, (%0)\n\t"
Quoted 9 lines
arch/riscv/include/asm/vector.h static __always_inline void riscv_v_disable(void) · line 108
Quoted 5 lines
arch/riscv/include/asm/vector.h +5
-0+ "add %0, %0, t4\n\t" + "vle8.v v16, (%0)\n\t" + "add %0, %0, t4\n\t" + "vle8.v v24, (%0)\n\t" + : : "r" (datap) : "t4");Nit/question: For both enable/disable; Any reason to clobber t4, instead of using a scratch reg?
Yes, it is better to use a scratch register here in order to gain benefit from inline asm.
Quoted 1 line
Bj?rn
Andy
PATCH v14 9/19 riscv: Add task switch support for vector
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
This patch adds task switch support for vector. It also supports all lengths of vlen.
[guoren at linux.alibaba.com: First available porting to support vector context switching]
[nick.knight at sifive.com: Rewrite vector.S to support dynamic vlen, xlen and code refine]
[vincent.chen at sifive.com: Fix the might_sleep issue in riscv_v_vstate_save, riscv_v_vstate_restore]
[andrew at sifive.com: Optimize task switch codes of vector] [ruinland.tsai at sifive.com: Fix the arch_release_task_struct free wrong datap issue]
[vineetg: Fixed lkp warning with W=1 build]
[andy.chiu: Use inline asm for task switches]
--- arch/riscv/include/asm/processor.h | 1 + arch/riscv/include/asm/switch_to.h | 3 ++ arch/riscv/include/asm/thread_info.h | 3 ++ arch/riscv/include/asm/vector.h | 43 ++++++++++++++++++++++++++-- arch/riscv/kernel/process.c | 18 ++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-)
arch/riscv/include/asm/processor.h +1 -0
@@ -39,6 +39,7 @@ struct thread_struct {unsigned long s[12 ];/* s[0]: frame pointer */ struct __riscv_d_ext_state fstate;unsigned long bad_cause; +struct __riscv_v_ext_state vstate; };/* Whitelist the fstate from the task_struct for hardened usercopy */
arch/riscv/include/asm/switch_to.h +3 -0
@@ -8,6 +8,7 @@#include <linux/jump_label.h> #include <linux/sched/task_stack.h> +#include <asm/vector.h> #include <asm/hwcap.h> #include <asm/processor.h> #include <asm/ptrace.h>
@@ -78,6 +79,8 @@ do { \struct task_struct *__next = (next); \if (has_fpu ()) \__switch_to_fpu (__prev, __next); \ +if (has_vector ()) \ +__switch_to_vector (__prev, __next); \ ((last) =__switch_to (__prev, __next)); \ }while (0 )
arch/riscv/include/asm/thread_info.h +3 -0
@@ -80,6 +80,9 @@ struct thread_info { .preempt_count = INIT_PREEMPT_COUNT, \ } +void arch_release_task_struct (struct task_struct *tsk); +int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +#endif /* !__ASSEMBLY__ */ /*
arch/riscv/include/asm/vector.h +41 -2
73 lines not on this page · raw message
arch/riscv/kernel/process.c +18 -0
@@ -24,6 +24,7 @@#include <asm/switch_to.h> #include <asm/thread_info.h> #include <asm/cpuidle.h> +#include <asm/vector.h> registerunsigned long gp_in_global __asm__("gp" );
@@ -148,12 +149,28 @@ void flush_thread(void)fstate_off (current,task_pt_regs (current));memset (¤t->thread.fstate,0 ,sizeof (current->thread.fstate));#endif +#ifdef CONFIG_RISCV_ISA_V +/* Reset vector state */ +riscv_v_vstate_off (task_pt_regs (current)); +kfree (current->thread.vstate.datap); +memset (¤t->thread.vstate,0 ,sizeof (struct __riscv_v_ext_state )); +#endif +} + +void arch_release_task_struct (struct task_struct *tsk) +{ +/* Free the vector context of datap. */ +if (has_vector () && tsk->thread.vstate.datap) +kfree (tsk->thread.vstate.datap); }int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src) {fstate_save (src,task_pt_regs (src)); *dst = *src; +/* clear entire V context, including datap for a new task */ +memset (&dst->thread.vstate,0 ,sizeof (struct __riscv_v_ext_state )); +return 0 ; }
@@ -186,6 +203,7 @@ int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) childregs->a0 =0 ;/* Return value of fork() */ p->thread.ra = (unsigned long )ret_from_fork; } +riscv_v_vstate_off (childregs); p->thread.sp = (unsigned long )childregs;/* kernel sp */ return 0 ; }
Signature · 1 line
2.17.1
Re: [PATCH -next v14 09/19] riscv: Add task switch support for vector
Hey Andy,
Quoted 5 lines · Andy Chiu
From: Greentime Hu <[email protected]>
This patch adds task switch support for vector. It also supports all lengths of vlen.
Quoted 11 lines
[guoren at linux.alibaba.com: First available porting to support vector context switching]
[nick.knight at sifive.com: Rewritevector.Sto support dynamic vlen, xlen and code refine]
[vincent.chen at sifive.com: Fix themight_sleepissue inriscv_v_vstate_save,riscv_v_vstate_restore]
[andrew at sifive.com: Optimize task switch codes of vector] [ruinland.tsai at sifive.com: Fix thearch_release_task_structfree wrong datap issue]
[vineetg: Fixed lkp warning with W=1 build]
[andy.chiu: Use inline asm for task switches]
Can we *please* get rid of these silly changelogs in the commit messages? Either someone did something worthy of being a co-developer on the patch, or this belongs under the --- line.
It's a bit ridiculous I think to have a 15 word commit message for the patch, but have like 8 different bits of per-version changelogs...
Quoted 21 lines
Suggested-by Andrew Waterman <[email protected]>Co-developed-by Nick Knight <[email protected]>Signed-off-by Nick Knight <[email protected]>Co-developed-by Guo Ren <[email protected]>Signed-off-by Guo Ren <[email protected]>Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Co-developed-by Ruinland Tsai <[email protected]>Signed-off-by Ruinland Tsai <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vineet Gupta <[email protected]>Signed-off-by Andy Chiu <[email protected]>--- arch/riscv/include/asm/processor.h | 1 + arch/riscv/include/asm/switch_to.h | 3 ++ arch/riscv/include/asm/thread_info.h | 3 ++ arch/riscv/include/asm/vector.h | 43 ++++++++++++++++++++++++++-- arch/riscv/kernel/process.c | 18 ++++++++++++ 5 files changed, 66 insertions(+), 2 deletions(-)
arch/riscv/include/asm/vector.h static __always_inline bool has_vector(void) { return false; } · line 161
Quoted 8 lines
arch/riscv/include/asm/vector.h +3
-0@@ -118,6 +154,9 @@ static __always_inline bool has_vector(void) { return false; }static inline bool riscv_v_vstate_query (struct pt_regs *regs) {return false; }#define riscv_v_vsize (0)#define riscv_v_setup_vsize () do {} while (0) +#define riscv_v_vstate_save (task, regs) do {} while (0) +#define riscv_v_vstate_restore (task, regs) do {} while (0) +#define __switch_to_vector (__prev, __next) do {} while (0)#define riscv_v_vstate_off (regs) do {} while (0)#define riscv_v_vstate_on (regs) do {} while (0)
While you're at it, you pay as well tab out all the do {} while (0) so that they align. That's my OCD showing though.
Other than my complaint about the changelogs, this looks grand.
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/6c64a154/attachment-0001.sig>
Re: [PATCH -next v14 09/19] riscv: Add task switch support for vector
Quoted 20 lines · Conor Dooley
Hey Andy,
Quoted 5 lines · Andy Chiu
From: Greentime Hu <[email protected]>
This patch adds task switch support for vector. It also supports all lengths of vlen.
Quoted 11 lines
[guoren at linux.alibaba.com: First available porting to support vector context switching]
[nick.knight at sifive.com: Rewritevector.Sto support dynamic vlen, xlen and code refine]
[vincent.chen at sifive.com: Fix themight_sleepissue inriscv_v_vstate_save,riscv_v_vstate_restore]
[andrew at sifive.com: Optimize task switch codes of vector] [ruinland.tsai at sifive.com: Fix thearch_release_task_structfree wrong datap issue]
[vineetg: Fixed lkp warning with W=1 build]
[andy.chiu: Use inline asm for task switches]
Quoted 5 lines
Can we *please* get rid of these silly changelogs in the commit messages? Either someone did something worthy of being a co-developer on the patch, or this belongs under the --- line.
It's a bit ridiculous I think to have a 15 word commit message for the patch, but have like 8 different bits of per-version changelogs...
Yes, please! And not only for this patch, but for the series in general. The series needs a respin for various reasons, so now would be a good opportunity to clean up the changelog.
Simply move it to the cover letter, or below --- as Conor suggests.
Re: [PATCH -next v14 09/19] riscv: Add task switch support for vector
In reply to Andy ChiuQuoted 29 lines · Andy Chiu
arch/riscv/include/asm/thread_info.h +3
-0@@ -80,6 +80,9 @@ struct thread_info { .preempt_count = INIT_PREEMPT_COUNT, \ } +void arch_release_task_struct (struct task_struct *tsk); +int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +#endif /* !__ASSEMBLY__ */ /* arch/riscv/include/asm/vector.h +3
-0@@ -10,6 +10,9 @@#ifdef CONFIG_RISCV_ISA_V +#include <linux/sched.h> +#include <linux/sched/task_stack.h> +#include <asm/ptrace.h> #include <asm/hwcap.h> #include <asm/csr.h> #include <asm/asm.h>
arch/riscv/include/asm/vector.h static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src · line 82
Quoted 6 lines
arch/riscv/include/asm/vector.h +2
-1@@ -75,7 +78,8 @@ static __always_inline void __vstate_csr_restore(struct __riscv_v_ext_state *src "r" (src->vcsr) :); } -static inline void __riscv_v_vstate_save (struct __riscv_v_ext_state *save_to,void *datap) +static inline void __riscv_v_vstate_save (struct __riscv_v_ext_state *save_to, +void *datap)
Please avoid code churn like this...
arch/riscv/include/asm/vector.h static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to, vo · line 100
Quoted 9 lines
arch/riscv/include/asm/vector.h +1
-1{riscv_v_enable ();__vstate_csr_save (save_to);@@ -93,7 +97,7 @@ static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to, vo }static inline void __riscv_v_vstate_restore (struct __riscv_v_ext_state *restore_from, -void *datap) +void *datap)
...and this.
Quoted 70 lines
arch/riscv/include/asm/vector.h +35
-0{riscv_v_enable (); asm volatile (@@ -110,6 +114,38 @@ static inline void __riscv_v_vstate_restore(struct __riscv_v_ext_state *restore_riscv_v_disable (); } +static inline void riscv_v_vstate_save (struct task_struct *task, +struct pt_regs *regs) +{ +if ((regs->status &SR_VS ) ==SR_VS_DIRTY ) { +struct __riscv_v_ext_state *vstate = &task->thread.vstate; + +__riscv_v_vstate_save (vstate, vstate->datap); +__riscv_v_vstate_clean (regs); + } +} + +static inline void riscv_v_vstate_restore (struct task_struct *task, +struct pt_regs *regs) +{ +if ((regs->status &SR_VS ) !=SR_VS_OFF ) { +struct __riscv_v_ext_state *vstate = &task->thread.vstate; + +__riscv_v_vstate_restore (vstate, vstate->datap); +__riscv_v_vstate_clean (regs); + } +} + +static inline void __switch_to_vector (struct task_struct *prev, +struct task_struct *next) +{ +struct pt_regs *regs; + + regs =task_pt_regs (prev); +riscv_v_vstate_save (prev, regs); +riscv_v_vstate_restore (next,task_pt_regs (next)); +} +#else /* ! CONFIG_RISCV_ISA_V */ struct pt_regs ;@@ -118,6 +154,9 @@ static __always_inline bool has_vector(void) { return false; }static inline bool riscv_v_vstate_query (struct pt_regs *regs) {return false; }#define riscv_v_vsize (0)#define riscv_v_setup_vsize () do {} while (0) +#define riscv_v_vstate_save (task, regs) do {} while (0) +#define riscv_v_vstate_restore (task, regs) do {} while (0) +#define __switch_to_vector (__prev, __next) do {} while (0)#define riscv_v_vstate_off (regs) do {} while (0)#define riscv_v_vstate_on (regs) do {} while (0)arch/riscv/kernel/process.c +3
-0@@ -24,6 +24,7 @@#include <asm/switch_to.h> #include <asm/thread_info.h> #include <asm/cpuidle.h> +#include <asm/vector.h> registerunsigned long gp_in_global __asm__("gp" );@@ -148,12 +149,28 @@ void flush_thread(void)fstate_off (current,task_pt_regs (current));memset (¤t->thread.fstate,0 ,sizeof (current->thread.fstate));#endif +#ifdef CONFIG_RISCV_ISA_V +/* Reset vector state */
arch/riscv/kernel/process.c void flush_thread(void) · line 163
Quoted 10 lines
arch/riscv/kernel/process.c +10
-0+riscv_v_vstate_off (task_pt_regs (current)); +kfree (current->thread.vstate.datap); +memset (¤t->thread.vstate,0 ,sizeof (struct __riscv_v_ext_state )); +#endif +} + +void arch_release_task_struct (struct task_struct *tsk) +{ +/* Free the vector context of datap. */ +if (has_vector () && tsk->thread.vstate.datap)
^^^^^^^^^^^^^^^^^^^^^^^^
No need to check for !NULL.
Bj?rn
PATCH v14 10/19 riscv: Allocate user's vector context in the first-use trap
In reply to Andy ChiuVector unit is disabled by default for all user processes. Thus, a process will take a trap (illegal instruction) into kernel at the first time when it uses Vector. Only after then, the kernel allocates V context and starts take care of the context for that user process.
--- arch/riscv/include/asm/insn.h | 29 +++++++++++ arch/riscv/include/asm/vector.h | 2 + arch/riscv/kernel/traps.c | 14 ++++- arch/riscv/kernel/vector.c | 91 +++++++++++++++++++++++++++++++++ 4 files changed, 134 insertions(+), 2 deletions(-)
arch/riscv/include/asm/insn.h +29 -0
@@ -137,6 +137,26 @@#define RVG_OPCODE_JALR 0x67#define RVG_OPCODE_JAL 0x6f#define RVG_OPCODE_SYSTEM 0x73 +#define RVG_SYSTEM_CSR_OFF 20 +#define RVG_SYSTEM_CSR_MASK GENMASK(12, 0) + +/* parts of opcode for RVF, RVD and RVQ */ +#define RVFDQ_FL_FS_WIDTH_OFF 12 +#define RVFDQ_FL_FS_WIDTH_MASK GENMASK(3, 0) +#define RVFDQ_FL_FS_WIDTH_W 2 +#define RVFDQ_FL_FS_WIDTH_D 3 +#define RVFDQ_LS_FS_WIDTH_Q 4 +#define RVFDQ_OPCODE_FL 0x07 +#define RVFDQ_OPCODE_FS 0x27 + +/* parts of opcode for RVV */ +#define RVV_OPCODE_VECTOR 0x57 +#define RVV_VL_VS_WIDTH_8 0 +#define RVV_VL_VS_WIDTH_16 5 +#define RVV_VL_VS_WIDTH_32 6 +#define RVV_VL_VS_WIDTH_64 7 +#define RVV_OPCODE_VL RVFDQ_OPCODE_FL +#define RVV_OPCODE_VS RVFDQ_OPCODE_FS/* parts of opcode for RVC*/ #define RVC_OPCODE_C0 0x0
@@ -304,6 +324,15 @@ static __always_inline bool riscv_insn_is_branch(u32 code) (RVC_X (x_,RVC_B_IMM_7_6_OPOFF ,RVC_B_IMM_7_6_MASK ) <<RVC_B_IMM_7_6_OFF ) | \ (RVC_IMM_SIGN(x_) << RVC_B_IMM_SIGN_OFF); }) +#define RVG_EXTRACT_SYSTEM_CSR (x) \ + ({typeof(x) x_ = (x); RV_X(x_, RVG_SYSTEM_CSR_OFF, RVG_SYSTEM_CSR_MASK); }) + +#define RVFDQ_EXTRACT_FL_FS_WIDTH (x) \ + ({typeof(x) x_ = (x); RV_X(x_, RVFDQ_FL_FS_WIDTH_OFF, \ + RVFDQ_FL_FS_WIDTH_MASK); }) + +#define RVV_EXRACT_VL_VS_WIDTH (x) RVFDQ_EXTRACT_FL_FS_WIDTH(x) +/* * Get the immediate from a J-type instruction. *
arch/riscv/include/asm/vector.h +2 -0
@@ -21,6 +21,7 @@extern unsigned long riscv_v_vsize;void riscv_v_setup_vsize (void ); +bool riscv_v_first_use_handler (struct pt_regs *regs); static __always_inline bool has_vector(void) {
@@ -151,6 +152,7 @@ static inline void __switch_to_vector(struct task_struct *prev,struct pt_regs ; static __always_inline bool has_vector(void) { return false; } +static inline bool riscv_v_first_use_handler (struct pt_regs *regs) {return false; }static inline bool riscv_v_vstate_query (struct pt_regs *regs) {return false; }#define riscv_v_vsize (0)#define riscv_v_setup_vsize () do {} while (0)
arch/riscv/kernel/traps.c +12 -2
@@ -24,6 +24,7 @@#include <asm/processor.h> #include <asm/ptrace.h> #include <asm/thread_info.h> +#include <asm/vector.h> int show_unhandled_signals =1 ;
@@ -135,8 +136,17 @@ DO_ERROR_INFO(do_trap_insn_misaligned, SIGBUS, BUS_ADRALN, "instruction address misaligned");DO_ERROR_INFO (do_trap_insn_fault,SIGSEGV ,SEGV_ACCERR ,"instruction access fault" ); -DO_ERROR_INFO (do_trap_insn_illegal, -SIGILL ,ILL_ILLOPC ,"illegal instruction" ); + +asmlinkage __visible __trap_section void do_trap_insn_illegal(struct pt_regs *regs) +{ +if (has_vector () &&user_mode (regs)) { +if (riscv_v_first_use_handler (regs)) +return ; + } +do_trap_error (regs,SIGILL ,ILL_ILLOPC , regs->epc, +"Oops - illegal instruction" ); +} +DO_ERROR_INFO (do_trap_load_fault,SIGSEGV ,SEGV_ACCERR ,"load access fault" );#ifndef CONFIG_RISCV_M_MODE
arch/riscv/kernel/vector.c +91 -0
103 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH -next v14 10/19] riscv: Allocate user's vector context in the first-use trap
Hey Andy,
Quoted 61 lines · Andy Chiu
Vector unit is disabled by default for all user processes. Thus, a process will take a trap (illegal instruction) into kernel at the first time when it uses Vector. Only after then, the kernel allocates V context and starts take care of the context for that user process.
Suggested-by Richard Henderson <[email protected]>Link https://lore.kernel.org/r/3923eeee-e4dc-0911-40bf-84c34aee962d at linaro.orgSigned-off-by Andy Chiu <[email protected]>---
arch/riscv/kernel/vector.c +32
-0@@ -4,9 +4,19 @@* Author: Andy Chiu <[email protected]> */ #include <linux/export.h> +#include <linux/sched/signal.h> +#include <linux/types.h> +#include <linux/slab.h> +#include <linux/sched.h> +#include <linux/uaccess.h> +#include <asm/thread_info.h> +#include <asm/processor.h> +#include <asm/insn.h> #include <asm/vector.h> #include <asm/csr.h> +#include <asm/ptrace.h> +#include <asm/bug.h> unsigned long riscv_v_vsize__read_mostly ;EXPORT_SYMBOL_GPL (riscv_v_vsize);@@ -19,3 +29,84 @@ void riscv_v_setup_vsize(void)riscv_v_disable (); } +static bool insn_is_vector (u32 insn_buf) +{ +u32 opcode = insn_buf & __INSN_OPCODE_MASK; +bool is_vector = false; + +/* +* All V-related instructions, including CSR operations are 4-Byte. So, +* do not handle if the instruction length is not 4-Byte. +*/ +if (unlikely (GET_INSN_LENGTH (insn_buf) !=4 )) +return false; + +switch (opcode) { +case RVV_OPCODE_VECTOR : + is_vector = true; +break ; +case RVV_OPCODE_VL : +case RVV_OPCODE_VS : +u32 width =RVV_EXRACT_VL_VS_WIDTH (insn_buf); + +if (width ==RVV_VL_VS_WIDTH_8 || width ==RVV_VL_VS_WIDTH_16 || + width ==RVV_VL_VS_WIDTH_32 || width ==RVV_VL_VS_WIDTH_64 )
arch/riscv/kernel/vector.c void riscv_v_setup_vsize(void) · line 63
Quoted 10 lines
arch/riscv/kernel/vector.c +10
-0+ is_vector = true; +break ; +case RVG_OPCODE_SYSTEM : +u32 csr =RVG_EXTRACT_SYSTEM_CSR (insn_buf); + +if ((csr >=CSR_VSTART && csr <=CSR_VCSR ) || + (csr >=CSR_VL && csr <=CSR_VLENB )) + is_vector = true; +break ; + }
Unfortunately, this is not valid code:
/stuff/linux/arch/riscv/kernel/vector.c:50:3: error: expected expression
u32 width = RVV_EXRACT_VL_VS_WIDTH(insn_buf);
^
/stuff/linux/arch/riscv/kernel/vector.c:52:7: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
/stuff/linux/arch/riscv/kernel/vector.c:52:37: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
/stuff/linux/arch/riscv/kernel/vector.c:53:7: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
/stuff/linux/arch/riscv/kernel/vector.c:53:38: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
/stuff/linux/arch/riscv/kernel/vector.c:57:3: error: expected expression
u32 csr = RVG_EXTRACT_SYSTEM_CSR(insn_buf);
^
/stuff/linux/arch/riscv/kernel/vector.c:59:8: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
/stuff/linux/arch/riscv/kernel/vector.c:59:29: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
/stuff/linux/arch/riscv/kernel/vector.c:60:8: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^
/stuff/linux/arch/riscv/kernel/vector.c:60:25: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^10 errors generated.
make[5]: *** [/stuff/linux/scripts/Makefile.build:252: arch/riscv/kernel/vector.o] Error 1
:/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/82b9b561/attachment-0001.sig>
PATCH v14 11/19 riscv: Add ptrace vector support
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
This patch adds ptrace support for riscv vector. The vector registers will be saved in datap pointer of __riscv_v_ext_state. This pointer will be set right after the __riscv_v_ext_state data structure then it will be put in ubuf for ptrace system call to get or set. It will check if the datap got from ubuf is set to the correct address or not when the ptrace system call is trying to set the vector registers.
--- arch/riscv/include/uapi/asm/ptrace.h | 7 +++ arch/riscv/kernel/ptrace.c | 71 ++++++++++++++++++++++++++++ include/uapi/linux/elf.h | 1 + 3 files changed, 79 insertions(+)
arch/riscv/include/uapi/asm/ptrace.h +7 -0
@@ -94,6 +94,13 @@ struct __riscv_v_ext_state {*/ }; +/* +* According to spec: The number of bits in a single vector register, +* VLEN >= ELEN, which must be a power of 2, and must be no greater than +* 2^16 = 65536bits = 8192bytes +*/ +#define RISCV_MAX_VLENB (8192) +#endif /* __ASSEMBLY__ */ #endif /* _UAPI_ASM_RISCV_PTRACE_H */
arch/riscv/kernel/ptrace.c +71 -0
95 lines not on this page · raw message
include/uapi/linux/elf.h +1 -0
@@ -439,6 +439,7 @@ typedef struct elf64_shdr {#define NT_MIPS_DSP 0x800/* MIPS DSP ASE registers */ #define NT_MIPS_FP_MODE 0x801/* MIPS floating-point mode */ #define NT_MIPS_MSA 0x802/* MIPS SIMD registers */ +#define NT_RISCV_VECTOR 0x900/* RISC-V vector registers */ #define NT_LOONGARCH_CPUCFG 0xa00/* LoongArch CPU config registers */ #define NT_LOONGARCH_CSR 0xa01/* LoongArch control and status registers */ #define NT_LOONGARCH_LSX 0xa02/* LoongArch Loongson SIMD Extension registers */
Signature · 1 line
2.17.1
Re: [PATCH -next v14 11/19] riscv: Add ptrace vector support
Quoted 15 lines · Andy Chiu
From: Greentime Hu <[email protected]>
This patch adds ptrace support for riscv vector. The vector registers will be saved in datap pointer of
__riscv_v_ext_state. This pointer will be set right after the__riscv_v_ext_statedata structure then it will be put in ubuf for ptrace system call to get or set. It will check if the datap got from ubuf is set to the correct address or not when the ptrace system call is trying to set the vector registers.Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Andy Chiu <[email protected]>---
arch/riscv/kernel/ptrace.c static int riscv_fpr_set(struct task_struct *target, · line 99
Quoted 9 lines
arch/riscv/kernel/ptrace.c +9
-0+static int riscv_vr_get (struct task_struct *target, +const struct user_regset *regset, +struct membuf to) +{ +struct __riscv_v_ext_state *vstate = &target->thread.vstate; + +if (!riscv_v_vstate_query (task_pt_regs (target))) +return -EINVAL ; +/*
With the tiny nit of a missing newline after the return, both here and in _get(), this looks grand to me.
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/423c47ea/attachment-0001.sig>
Re: [PATCH -next v14 11/19] riscv: Add ptrace vector support
In reply to Andy ChiuQuoted 20 lines · Andy Chiu
arch/riscv/kernel/ptrace.c +12
-0@@ -83,6 +87,62 @@ static int riscv_fpr_set(struct task_struct *target, }#endif +#ifdef CONFIG_RISCV_ISA_V +static int riscv_vr_get (struct task_struct *target, +const struct user_regset *regset, +struct membuf to) +{ +struct __riscv_v_ext_state *vstate = &target->thread.vstate; + +if (!riscv_v_vstate_query (task_pt_regs (target))) +return -EINVAL ; +/* +* Ensure the vector registers have been saved to the memory before +* copying them to membuf.
arch/riscv/kernel/ptrace.c static int riscv_fpr_set(struct task_struct *target, · line 111
Quoted 10 lines
arch/riscv/kernel/ptrace.c +10
-0+*/ +if (target == current) +riscv_v_vstate_save (current,task_pt_regs (current)); + +/* Copy vector header from vstate. */ +membuf_write (&to, vstate, offsetof(struct __riscv_v_ext_state , datap)); +membuf_zero (&to,sizeof (void *)); +#if __riscv_xlen ==32 +membuf_zero (&to,sizeof (__u32)); +#endif
Remind me why the extra care is needed for 32b?
Bj?rn
Re: [PATCH -next v14 11/19] riscv: Add ptrace vector support
Quoted 27 lines · On Thu, Mar 2, 2023 at 7:27?PM Bj?rn T?pel <[email protected]> wrote:
Quoted 24 lines · Andy Chiu
arch/riscv/kernel/ptrace.c +16
-0@@ -83,6 +87,62 @@ static int riscv_fpr_set(struct task_struct *target, }#endif +#ifdef CONFIG_RISCV_ISA_V +static int riscv_vr_get (struct task_struct *target, +const struct user_regset *regset, +struct membuf to) +{ +struct __riscv_v_ext_state *vstate = &target->thread.vstate; + +if (!riscv_v_vstate_query (task_pt_regs (target))) +return -EINVAL ; +/* +* Ensure the vector registers have been saved to the memory before +* copying them to membuf. +*/ +if (target == current) +riscv_v_vstate_save (current,task_pt_regs (current)); +
Quoted 9 lines
arch/riscv/kernel/ptrace.c static int riscv_fpr_set(struct task_struct *target, · line 111
Quoted 6 lines
arch/riscv/kernel/ptrace.c +6
-0+/* Copy vector header from vstate. */ +membuf_write (&to, vstate, offsetof(struct __riscv_v_ext_state , datap)); +membuf_zero (&to,sizeof (void *)); +#if __riscv_xlen ==32 +membuf_zero (&to,sizeof (__u32)); +#endif Remind me why the extra care is needed for 32b?
That is from the old version of the code and I agree we should remove that. Hey Conor, does your Rb still hold after removing this #if, #endif section?
Quoted 2 lines
Bj?rn
Andy
Re: [PATCH -next v14 11/19] riscv: Add ptrace vector support
Quoted 38 lines · Andy Chiu
Quoted 27 lines · On Thu, Mar 2, 2023 at 7:27?PM Bj?rn T?pel <[email protected]> wrote:
Quoted 24 lines · Andy Chiu
arch/riscv/kernel/ptrace.c +16
-0@@ -83,6 +87,62 @@ static int riscv_fpr_set(struct task_struct *target, }#endif +#ifdef CONFIG_RISCV_ISA_V +static int riscv_vr_get (struct task_struct *target, +const struct user_regset *regset, +struct membuf to) +{ +struct __riscv_v_ext_state *vstate = &target->thread.vstate; + +if (!riscv_v_vstate_query (task_pt_regs (target))) +return -EINVAL ; +/* +* Ensure the vector registers have been saved to the memory before +* copying them to membuf. +*/ +if (target == current) +riscv_v_vstate_save (current,task_pt_regs (current)); +Quoted 9 lines
arch/riscv/kernel/ptrace.c static int riscv_fpr_set(struct task_struct *target, · line 111
Quoted 6 lines
arch/riscv/kernel/ptrace.c +6
-0+/* Copy vector header from vstate. */ +membuf_write (&to, vstate, offsetof(struct __riscv_v_ext_state , datap)); +membuf_zero (&to,sizeof (void *)); +#if __riscv_xlen ==32 +membuf_zero (&to,sizeof (__u32)); +#endif Remind me why the extra care is needed for 32b?
Quoted 5 lines
That is from the old version of the code and I agree we should remove that.
Hey Conor, does your Rb still hold after removing this #if, #endif section?
Sure.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230314/b6771807/attachment.sig>
PATCH v14 12/19 riscv: signal: check fp-reserved words unconditionally
In reply to Andy ChiuIn order to let kernel/user locate and identify an extension context on the existing sigframe, we are going to utilize reserved space of fp and encode the information there. And since the sigcontext has already preserved a space for fp context w or w/o CONFIG_FPU, we move those reserved words checking/setting routine back into generic code.
This commit also undone an additional logical change carried by the refactor commit 007f5c3589578
("Refactor FPU code in signal setup/return procedures"). Originally we did not restore fp context if restoring of gpr have failed. And it was fine on the other side. In such way the kernel could keep the regfiles intact, and potentially react at the failing point of restore.
--- arch/riscv/kernel/signal.c | 53 +++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 27 deletions(-)
arch/riscv/kernel/signal.c +26 -27
@@ -38,26 +38,13 @@ static long restore_fp_state(struct pt_regs *regs, {long err;struct __riscv_d_ext_state __user *state = &sc_fpregs->d; -size_t i; err =__copy_from_user (¤t->thread.fstate, state,sizeof (*state));if (unlikely (err))return err;fstate_restore (current, regs); - -/* We support no other extension state at this time. */ -for (i =0 ; i <ARRAY_SIZE (sc_fpregs->q.reserved); i++) { -u32 value; - - err =__get_user (value, &sc_fpregs->q.reserved[i]); -if (unlikely (err)) -break ; -if (value !=0 ) -return -EINVAL ; - } - -return err; +return 0 ; } static long save_fp_state(struct pt_regs *regs,
@@ -65,20 +52,9 @@ static long save_fp_state(struct pt_regs *regs, {long err;struct __riscv_d_ext_state __user *state = &sc_fpregs->d; -size_t i;fstate_save (current, regs); err =__copy_to_user (state, ¤t->thread.fstate,sizeof (*state)); -if (unlikely (err)) -return err; - -/* We support no other extension state at this time. */ -for (i =0 ; i <ARRAY_SIZE (sc_fpregs->q.reserved); i++) { - err =__put_user (0 , &sc_fpregs->q.reserved[i]); -if (unlikely (err)) -break ; - } -return err; }#else
@@ -90,11 +66,29 @@ static long restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) {long err; +size_t i; +/* sc_regs is structured the same as the start of pt_regs */ err =__copy_from_user (regs, &sc->sc_regs,sizeof (sc->sc_regs)); +if (unlikely (err)) +return err;/* Restore the floating-point state. */ -if (has_fpu ()) - err |=restore_fp_state (regs, &sc->sc_fpregs); +if (has_fpu ()) { + err =restore_fp_state (regs, &sc->sc_fpregs); +if (unlikely (err)) +return err; + } + +/* We support no other extension state at this time. */ +for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) { +u32 value; + + err =__get_user (value, &sc->sc_fpregs.q.reserved[i]); +if (unlikely (err)) +break ; +if (value !=0 ) +return -EINVAL ; + }return err; }
@@ -145,11 +139,16 @@ static long setup_sigcontext(struct rt_sigframe __user *frame, {struct sigcontext __user *sc = &frame->uc.uc_mcontext;long err; +size_t i; +/* sc_regs is structured the same as the start of pt_regs */ err =__copy_to_user (&sc->sc_regs, regs,sizeof (sc->sc_regs));/* Save the floating-point state. */ if (has_fpu ()) err |=save_fp_state (regs, &sc->sc_fpregs); +/* We support no other extension state at this time. */ +for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) + err |=__put_user (0 , &sc->sc_fpregs.q.reserved[i]);return err; }
Signature · 1 line
2.17.1
Re: [PATCH -next v14 12/19] riscv: signal: check fp-reserved words unconditionally
Quoted 17 lines · Andy Chiu
In order to let kernel/user locate and identify an extension context on the existing sigframe, we are going to utilize reserved space of fp and encode the information there. And since the sigcontext has already preserved a space for fp context w or w/o
CONFIG_FPU, we move those reserved words checking/setting routine back into generic code.This commit also undone an additional logical change carried by the refactor commit
007f5c3589578
("Refactor FPU code in signal setup/return procedures"). Originally we did not restore fp context if restoring of gpr have failed. And it was fine on the other side. In such way the kernel could keep the regfiles intact, and potentially react at the failing point of restore.Signed-off-by Andy Chiu <[email protected]>---
arch/riscv/kernel/signal.c static long restore_sigcontext(struct pt_regs *regs, · line 75
Quoted 10 lines
arch/riscv/kernel/signal.c +4
-0@@ -90,11 +66,29 @@ static long restore_sigcontext(struct pt_regs *regs, struct sigcontext __user *sc) {long err; +size_t i; +/* sc_regs is structured the same as the start of pt_regs */ err =__copy_from_user (regs, &sc->sc_regs,sizeof (sc->sc_regs)); +if (unlikely (err)) +return err;/* Restore the floating-point state. */
Please preserve the newline after return from where you moved this from.
Quoted 13 lines
arch/riscv/kernel/signal.c +6
-2-if (has_fpu ()) - err |=restore_fp_state (regs, &sc->sc_fpregs); +if (has_fpu ()) { + err =restore_fp_state (regs, &sc->sc_fpregs); +if (unlikely (err)) +return err; + }@@ -145,11 +139,16 @@ static long setup_sigcontext(struct rt_sigframe __user *frame, {struct sigcontext __user *sc = &frame->uc.uc_mcontext;long err; +size_t i;
arch/riscv/kernel/signal.c static long setup_sigcontext(struct rt_sigframe __user *frame, · line 152
Quoted 10 lines
arch/riscv/kernel/signal.c +4
-0+/* sc_regs is structured the same as the start of pt_regs */ err =__copy_to_user (&sc->sc_regs, regs,sizeof (sc->sc_regs));/* Save the floating-point state. */ if (has_fpu ()) err |=save_fp_state (regs, &sc->sc_fpregs); +/* We support no other extension state at this time. */ +for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) + err |=__put_user (0 , &sc->sc_fpregs.q.reserved[i]);return err;
And one before the return here would not go amiss. Those are nitpick bits though, so:
Cheers,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/8f551d7f/attachment-0001.sig>
PATCH v14 13/19 riscv: signal: Add sigcontext save/restore for vector
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
This patch facilitates the existing fp-reserved words for placement of the first extension's context header on the user's sigframe. A context header consists of a distinct magic word and the size, including the header itself, of an extension on the stack. Then, the frame is followed by the context of that extension, and then a header + context body for another extension if exists. If there is no more extension to come, then the frame must be ended with a null context header. A special case is rv64gc, where the kernel support no extensions requiring to expose additional regfile to the user. In such case the kernel would place the null context header right after the first reserved word of __riscv_q_ext_state when saving sigframe. And the kernel would check if all reserved words are zeros when a signal handler returns.
__riscv_q_ext_state---->| |<-__riscv_extra_ext_header
~ ~ .reserved[0]--->|0 |<- .reserved <-------|magic |<- .hdr | |size |_______ end of sc_fpregs | |ext-bdy| | ~ ~ +)size ------->|magic |<- another context header |size | |ext-bdy| ~ ~ |magic:0|<- null context header |size:0 |
The vector registers will be saved in datap pointer. The datap pointer will be allocated dynamically when the task needs in kernel space. On the other hand, datap pointer on the sigframe will be set right after the __riscv_v_ext_state data structure.
--- arch/riscv/include/uapi/asm/ptrace.h | 15 ++ arch/riscv/include/uapi/asm/sigcontext.h | 16 +- arch/riscv/kernel/setup.c | 3 + arch/riscv/kernel/signal.c | 186 ++++++++++++++++++++--- 4 files changed, 200 insertions(+), 20 deletions(-)
arch/riscv/include/uapi/asm/ptrace.h +15 -0
@@ -71,6 +71,21 @@ struct __riscv_q_ext_state {__u32 reserved[3 ]; }; +struct __riscv_ctx_hdr { +__u32 magic; +__u32 size; +}; + +struct __riscv_extra_ext_header { +__u32 __padding[129 ] __attribute__((aligned (16 ))); +/* +* Reserved for expansion of sigcontext structure. Currently zeroed +* upon signal, and must be zero upon sigreturn. +*/ +__u32 reserved; +struct __riscv_ctx_hdr hdr; +}; +union __riscv_fp_state {struct __riscv_f_ext_state f;struct __riscv_d_ext_state d;
arch/riscv/include/uapi/asm/sigcontext.h +15 -1
@@ -8,6 +8,17 @@#include <asm/ptrace.h> +/* The Magic number for signal context frame header. */ +#define RISCV_V_MAGIC 0x53465457 +#define END_MAGIC 0x0 + +/* The size of END signal context header. */ +#define END_HDR_SIZE 0x0 + +struct __sc_riscv_v_state { +struct __riscv_v_ext_state v_state; +} __attribute__((aligned (16 ))); +/* * Signal context structure *
@@ -16,7 +27,10 @@*/ struct sigcontext {struct user_regs_struct sc_regs; -union __riscv_fp_state sc_fpregs; +union { +union __riscv_fp_state sc_fpregs; +struct __riscv_extra_ext_header sc_extdesc; + }; };#endif /* _UAPI_ASM_RISCV_SIGCONTEXT_H */
arch/riscv/kernel/setup.c +3 -0
@@ -262,6 +262,8 @@ static void __init parse_dtb(void)#endif } +extern void __init init_rt_signal_env (void ); +void __init setup_arch (char **cmdline_p) {parse_dtb ();
@@ -299,6 +301,7 @@ void __init setup_arch(char **cmdline_p)riscv_init_cbom_blocksize ();riscv_fill_hwcap (); +init_rt_signal_env ();apply_boot_alternatives ();if (IS_ENABLED (CONFIG_RISCV_ISA_ZICBOM ) &&riscv_isa_extension_available (NULL ,ZICBOM ))
arch/riscv/kernel/signal.c +167 -19
258 lines not on this page · raw message
Signature · 1 line
2.17.1
Re: [PATCH -next v14 13/19] riscv: signal: Add sigcontext save/restore for vector
Quoted 42 lines · Andy Chiu
From: Greentime Hu <[email protected]>
This patch facilitates the existing fp-reserved words for placement of the first extension's context header on the user's sigframe. A context header consists of a distinct magic word and the size, including the header itself, of an extension on the stack. Then, the frame is followed by the context of that extension, and then a header + context body for another extension if exists. If there is no more extension to come, then the frame must be ended with a null context header. A special case is rv64gc, where the kernel support no extensions requiring to expose additional regfile to the user. In such case the kernel would place the null context header right after the first reserved word of
__riscv_q_ext_statewhen saving sigframe. And the kernel would check if all reserved words are zeros when a signal handler returns.__riscv_q_ext_state---->| |<-__riscv_extra_ext_header
~ ~ .reserved[0]--->|0 |<- .reserved <-------|magic |<- .hdr | |size |_______ end of sc_fpregs | |ext-bdy| | ~ ~ +)size ------->|magic |<- another context header |size | |ext-bdy| ~ ~ |magic:0|<- null context header |size:0 |The vector registers will be saved in datap pointer. The datap pointer will be allocated dynamically when the task needs in kernel space. On the other hand, datap pointer on the sigframe will be set right after the
__riscv_v_ext_statedata structure.Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Suggested-by Vineet Gupta <[email protected]>Suggested-by Richard Henderson <[email protected]>Signed-off-by Andy Chiu <[email protected]>---
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 75
Quoted 7 lines
arch/riscv/kernel/signal.c +7
-0+static long save_v_state (struct pt_regs *regs,void **sc_vec) +{ +/* +* Put __sc_riscv_v_state to the user's signal context space pointed +* by sc_vec and the datap point the address right +* after __sc_riscv_v_state. +*/
AFAIU, this comment describes the assignments here. I think it would be significantly clearer if you defined the variables here & moved the assignment and comment further down the function.
Quoted 51 lines
arch/riscv/kernel/signal.c +30
-8+struct __riscv_ctx_hdr __user *hdr = (struct __riscv_ctx_hdr *)(*sc_vec); +struct __sc_riscv_v_state __user *state = (struct __sc_riscv_v_state *)(hdr +1 ); +void __user *datap = state +1 ; +long err; + +/* datap is designed to be 16 byte aligned for better performance */ +WARN_ON (unlikely (!IS_ALIGNED ((unsigned long )datap,16 ))); + +riscv_v_vstate_save (current, regs); +/* Copy everything of vstate but datap. */ + err =__copy_to_user (&state->v_state, ¤t->thread.vstate, + offsetof(struct __riscv_v_ext_state , datap)); +/* Copy the pointer datap itself. */ + err |=__put_user (datap, &state->v_state.datap); +/* Copy the whole vector content to user space datap. */ + err |=__copy_to_user (datap, current->thread.vstate.datap, riscv_v_vsize); +/* Copy magic to the user space after saving all vector conetext */ + err |=__put_user (RISCV_V_MAGIC , &hdr->magic); + err |=__put_user (riscv_v_sc_size, &hdr->size); +if (unlikely (err)) +return err; + +/* Only progress the sv_vec if everything has done successfully */ + *sc_vec += riscv_v_sc_size; +return 0 ; +}static long restore_sigcontext (struct pt_regs *regs,struct sigcontext __user *sc) { +void *sc_ext_ptr = &sc->sc_extdesc.hdr; +__u32 rsvd;long err; -size_t i; -/* sc_regs is structured the same as the start of pt_regs */ err =__copy_from_user (regs, &sc->sc_regs,sizeof (sc->sc_regs));if (unlikely (err)) -return err; + goto done;/* Restore the floating-point state. */ if (has_fpu ()) { err =restore_fp_state (regs, &sc->sc_fpregs);if (unlikely (err)) -return err; + goto done; } -/* We support no other extension state at this time. */ -for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) { -u32 value; -
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 165
Quoted 10 lines
arch/riscv/kernel/signal.c +8
-2- err =__get_user (value, &sc->sc_fpregs.q.reserved[i]); -if (unlikely (err)) +/* Check the reserved word before extensions parsing */ + err =__get_user (rsvd, &sc->sc_extdesc.reserved); +if (unlikely (err)) + goto done; +if (unlikely (rsvd)) + goto invalid; + +while (1 && !err) {
This is just while (!err), no?
Quoted 15 lines
arch/riscv/kernel/signal.c +15
-0+__u32 magic, size; +struct __riscv_ctx_hdr *head = (struct __riscv_ctx_hdr *)sc_ext_ptr; + + err |=__get_user (magic, &head->magic); + err |=__get_user (size, &head->size); +if (err) + goto done; + + sc_ext_ptr +=sizeof (struct __riscv_ctx_hdr ); +switch (magic) { +case END_MAGIC : +if (size !=END_HDR_SIZE ) + goto invalid; + goto done; +case RISCV_V_MAGIC :
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 188
Quoted 10 lines
arch/riscv/kernel/signal.c +7
-2+if (!has_vector () || !riscv_v_vstate_query (regs)) + goto invalid; +if (size != riscv_v_sc_size) + goto invalid; + err =__restore_v_state (regs, sc_ext_ptr);break ; -if (value !=0 ) -return -EINVAL ; +default : + goto invalid;
Why does this need a goto, rather than returning -EINVAL directly?
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 196
Quoted 8 lines
arch/riscv/kernel/signal.c +6
-0+ } + sc_ext_ptr = ((void *)(head) + size); } +done:return err; +invalid: +return -EINVAL ; +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/77380d28/attachment-0001.sig>
Re: [PATCH -next v14 13/19] riscv: signal: Add sigcontext save/restore for vector
In reply to Andy ChiuQuoted 26 lines · Andy Chiu
arch/riscv/kernel/setup.c +3
-0@@ -262,6 +262,8 @@ static void __init parse_dtb(void)#endif } +extern void __init init_rt_signal_env (void ); +void __init setup_arch (char **cmdline_p) {parse_dtb ();@@ -299,6 +301,7 @@ void __init setup_arch(char **cmdline_p)riscv_init_cbom_blocksize ();riscv_fill_hwcap (); +init_rt_signal_env ();apply_boot_alternatives ();if (IS_ENABLED (CONFIG_RISCV_ISA_ZICBOM ) &&riscv_isa_extension_available (NULL ,ZICBOM ))arch/riscv/kernel/signal.c +0
-0
arch/riscv/kernel/signal.c line 25
Quoted 8 lines
arch/riscv/kernel/signal.c +2
-0@@ -18,9 +18,11 @@#include <asm/signal.h> #include <asm/signal32.h> #include <asm/switch_to.h> +#include <asm/vector.h> #include <asm/csr.h> extern u32 __user_rt_sigreturn[2 ]; +static size_t riscv_v_sc_size;
__ro_after_init?
Quoted 7 lines
arch/riscv/kernel/signal.c +0
-0#define DEBUG_SIG 0@@ -62,34 +64,159 @@ static long save_fp_state(struct pt_regs *regs,#define restore_fp_state (task, regs) (0)#endif
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 76
Quoted 10 lines
arch/riscv/kernel/signal.c +10
-0+#ifdef CONFIG_RISCV_ISA_V + +static long save_v_state (struct pt_regs *regs,void **sc_vec) +{ +/* +* Put __sc_riscv_v_state to the user's signal context space pointed +* by sc_vec and the datap point the address right +* after __sc_riscv_v_state. +*/ +struct __riscv_ctx_hdr __user *hdr = (struct __riscv_ctx_hdr *)(*sc_vec);
^^^
Remove unneccery cast and parenthesis.
Quoted 25 lines
arch/riscv/kernel/signal.c +25
-0+struct __sc_riscv_v_state __user *state = (struct __sc_riscv_v_state *)(hdr +1 ); +void __user *datap = state +1 ; +long err; + +/* datap is designed to be 16 byte aligned for better performance */ +WARN_ON (unlikely (!IS_ALIGNED ((unsigned long )datap,16 ))); + +riscv_v_vstate_save (current, regs); +/* Copy everything of vstate but datap. */ + err =__copy_to_user (&state->v_state, ¤t->thread.vstate, + offsetof(struct __riscv_v_ext_state , datap)); +/* Copy the pointer datap itself. */ + err |=__put_user (datap, &state->v_state.datap); +/* Copy the whole vector content to user space datap. */ + err |=__copy_to_user (datap, current->thread.vstate.datap, riscv_v_vsize); +/* Copy magic to the user space after saving all vector conetext */ + err |=__put_user (RISCV_V_MAGIC , &hdr->magic); + err |=__put_user (riscv_v_sc_size, &hdr->size); +if (unlikely (err)) +return err; + +/* Only progress the sv_vec if everything has done successfully */ + *sc_vec += riscv_v_sc_size; +return 0 ; +}
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 111
Quoted 10 lines
arch/riscv/kernel/signal.c +10
-0+ +/* +* Restore Vector extension context from the user's signal frame. This function +* assumes a valid extension header. So magic and size checking must be done by +* the caller. +*/ +static long __restore_v_state (struct pt_regs *regs,void *sc_vec) +{ +long err; +struct __sc_riscv_v_state __user *state = (struct __sc_riscv_v_state *)(sc_vec);
^^^
Remove unneccery cast and parenthesis.
Quoted 21 lines
arch/riscv/kernel/signal.c +21
-0+void __user *datap; + +/* Copy everything of __sc_riscv_v_state except datap. */ + err =__copy_from_user (¤t->thread.vstate, &state->v_state, + offsetof(struct __riscv_v_ext_state , datap)); +if (unlikely (err)) +return err; + +/* Copy the pointer datap itself. */ + err =__get_user (datap, &state->v_state.datap); +if (unlikely (err)) +return err; +/* +* Copy the whole vector content from user space datap. Use +* copy_from_user to prevent information leak. +*/ + err =copy_from_user (current->thread.vstate.datap, datap, riscv_v_vsize); +if (unlikely (err)) +return err; + +riscv_v_vstate_restore (current, regs);
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 142
Quoted 10 lines
arch/riscv/kernel/signal.c +8
-0+ + return err; +} +#else +#define save_v_state (task, regs) (0) +#define __restore_v_state (task, regs) (0) +#endif +static long restore_sigcontext (struct pt_regs *regs,struct sigcontext __user *sc)
This whole function; return in favor of goto, and remove the labels at the bottom.
Quoted 25 lines
arch/riscv/kernel/signal.c +4
-10{ +void *sc_ext_ptr = &sc->sc_extdesc.hdr; +__u32 rsvd;long err; -size_t i; -/* sc_regs is structured the same as the start of pt_regs */ err =__copy_from_user (regs, &sc->sc_regs,sizeof (sc->sc_regs));if (unlikely (err)) -return err; + goto done;/* Restore the floating-point state. */ if (has_fpu ()) { err =restore_fp_state (regs, &sc->sc_fpregs);if (unlikely (err)) -return err; + goto done; } -/* We support no other extension state at this time. */ -for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) { -u32 value; - - err =__get_user (value, &sc->sc_fpregs.q.reserved[i]); -if (unlikely (err))
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 167
Quoted 10 lines
arch/riscv/kernel/signal.c +10
-0+/* Check the reserved word before extensions parsing */ + err =__get_user (rsvd, &sc->sc_extdesc.reserved); +if (unlikely (err)) + goto done; +if (unlikely (rsvd)) + goto invalid; + +while (1 && !err) { +__u32 magic, size; +struct __riscv_ctx_hdr *head = (struct __riscv_ctx_hdr *)sc_ext_ptr;
Remove unneccery cast.
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 174
Quoted 7 lines
arch/riscv/kernel/signal.c +7
-0+ + err |=__get_user (magic, &head->magic); + err |=__get_user (size, &head->size); +if (err) + goto done; + + sc_ext_ptr +=sizeof (struct __riscv_ctx_hdr );
sizeof(*head);
Quoted 8 lines
arch/riscv/kernel/signal.c +8
-0+switch (magic) { +case END_MAGIC : +if (size !=END_HDR_SIZE ) + goto invalid; + goto done; +case RISCV_V_MAGIC : +if (!has_vector () || !riscv_v_vstate_query (regs)) + goto invalid;
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 190
Quoted 10 lines
arch/riscv/kernel/signal.c +7
-2+if (size != riscv_v_sc_size) + goto invalid; + err =__restore_v_state (regs, sc_ext_ptr);break ; -if (value !=0 ) -return -EINVAL ; +default : + goto invalid; + } + sc_ext_ptr = ((void *)(head) + size);
Unneccery parenthesis. "(void *)head + size" is enough
Quoted 15 lines
arch/riscv/kernel/signal.c +13
-0} +done:return err; +invalid: +return -EINVAL ; +} + +static size_t cal_rt_frame_size (void ) +{ +struct rt_sigframe __user *frame; +size_t frame_size; +size_t total_context_size =0 ; + + frame_size =sizeof (*frame); +
arch/riscv/kernel/signal.c static long save_fp_state(struct pt_regs *regs, · line 215
Quoted 10 lines
arch/riscv/kernel/signal.c +10
-0+if (has_vector () &&riscv_v_vstate_query (task_pt_regs (current))) + total_context_size += riscv_v_sc_size; +/* +* Preserved a __riscv_ctx_hdr for END signal context header if an +* extension uses __riscv_extra_ext_header +*/ +if (total_context_size) + total_context_size +=sizeof (struct __riscv_ctx_hdr ); + + frame_size += (total_context_size);
Remove unneccery parenthesis.
Quoted 24 lines
arch/riscv/kernel/signal.c +6
-1+ + frame_size =round_up (frame_size,16 ); +return frame_size; + }SYSCALL_DEFINE0 (rt_sigreturn)@@ -98,13 +225,14 @@ SYSCALL_DEFINE0(rt_sigreturn)struct rt_sigframe __user *frame;struct task_struct *task;sigset_t set; +size_t frame_size =cal_rt_frame_size ();/* Always make any pending restarted system calls return -EINTR */ current->restart_block.fn = do_no_restart_syscall; frame = (struct rt_sigframe __user *)regs->sp; -if (!access_ok (frame,sizeof (*frame))) +if (!access_ok (frame, frame_size)) goto badframe;if (__copy_from_user (&set, &frame->uc.uc_sigmask,sizeof (set)))
arch/riscv/kernel/signal.c static long setup_sigcontext(struct rt_sigframe __user *frame, · line 269
Quoted 4 lines
arch/riscv/kernel/signal.c +1
-0@@ -138,17 +266,22 @@ static long setup_sigcontext(struct rt_sigframe __user *frame, struct pt_regs *regs) {struct sigcontext __user *sc = &frame->uc.uc_mcontext; +void *sc_ext_ptr = &sc->sc_extdesc.hdr;
All the casts and parenthesis makes it hard to read. Change to
struct __riscv_ctx_hdr *sc_ext_ptr = &sc->sc_extdesc.hdr;
Quoted 4 lines
arch/riscv/kernel/signal.c +0
-1long err; -size_t i;/* sc_regs is structured the same as the start of pt_regs */
arch/riscv/kernel/signal.c static long setup_sigcontext(struct rt_sigframe __user *frame, · line 279
Quoted 10 lines
arch/riscv/kernel/signal.c +3
-3err =__copy_to_user (&sc->sc_regs, regs,sizeof (sc->sc_regs));/* Save the floating-point state. */ if (has_fpu ()) err |=save_fp_state (regs, &sc->sc_fpregs); -/* We support no other extension state at this time. */ -for (i =0 ; i <ARRAY_SIZE (sc->sc_fpregs.q.reserved); i++) - err |=__put_user (0 , &sc->sc_fpregs.q.reserved[i]); +/* Save the vector state. */ +if (has_vector () &&riscv_v_vstate_query (regs)) + err |=save_v_state (regs, &sc_ext_ptr);
...and cast to (void **) after the change above...
arch/riscv/kernel/signal.c static long setup_sigcontext(struct rt_sigframe __user *frame, · line 284
Quoted 5 lines
arch/riscv/kernel/signal.c +5
-0+/* Write zero to fp-reserved space and check it on restore_sigcontext */ + err |=__put_user (0 , &sc->sc_extdesc.reserved); +/* And put END __riscv_ctx_hdr at the end. */ + err |=__put_user (END_MAGIC , &((struct __riscv_ctx_hdr *)sc_ext_ptr)->magic); + err |=__put_user (END_HDR_SIZE , &((struct __riscv_ctx_hdr *)sc_ext_ptr)->size);
...and change to:
err |= __put_user(END_MAGIC, &sc_ext_ptr->magic); err |= __put_user(END_HDR_SIZE, &sc_ext_ptr->size);
arch/riscv/kernel/signal.c static inline void __user *get_sigframe(struct ksignal *ksig, · line 313
Quoted 13 lines
arch/riscv/kernel/signal.c +6
-0return err; }@@ -172,6 +305,13 @@ static inline void __user *get_sigframe(struct ksignal *ksig,/* Align the stack frame. */ sp &= ~0xfUL ; +/* +* Fail if the size of the altstack is not large enough for the +* sigframe construction. +*/ +if (current->sas_ss_size && sp < current->sas_ss_sp) +return (void __user __force *)(-1UL );
Nit: Remove unneccery parenthesis.
Bj?rn
PATCH v14 14/19 riscv: signal: Report signal frame size to userspace via auxv
In reply to Andy ChiuFrom: Vincent Chen <[email protected]>
The vector register belongs to the signal context. They need to be stored and restored as entering and leaving the signal handler. According to the V-extension specification, the maximum length of the vector registers can be 2^(XLEN-1). Hence, if userspace refers to the MINSIGSTKSZ to create a sigframe, it may not be enough. To resolve this problem, this patch refers to the commit 94b07c1f8c39c
("arm64: signal: Report signal frame size to userspace via auxv") to enable userspace to know the minimum required sigframe size through the auxiliary vector and use it to allocate enough memory for signal context.
Note that auxv always reports size of the sigframe as if V exists for all starting processes, whenever the kernel has CONFIG_RISCV_ISA_V. The reason is that users usually reference this value to allocate an alternative signal stack, and the user may use V anytime. So the user must reserve a space for V-context in sigframe in case that the signal handler invokes after the kernel allocating V.
--- arch/riscv/include/asm/elf.h | 9 +++++++++ arch/riscv/include/asm/processor.h | 2 ++ arch/riscv/include/uapi/asm/auxvec.h | 1 + arch/riscv/kernel/signal.c | 20 +++++++++++++++----- 4 files changed, 27 insertions(+), 5 deletions(-)
arch/riscv/include/asm/elf.h +9 -0
@@ -105,6 +105,15 @@ do { \ get_cache_size(3, CACHE_TYPE_UNIFIED)); \NEW_AUX_ENT (AT_L3_CACHEGEOMETRY , \get_cache_geometry (3 ,CACHE_TYPE_UNIFIED )); \ +/* \ +* Should always be nonzero unless there's a kernel bug. \ +* If we haven't determined a sensible value to give to \ +* userspace, omit the entry: \ +*/ \ +if (likely (signal_minsigstksz)) \ +NEW_AUX_ENT (AT_MINSIGSTKSZ , signal_minsigstksz); \ +else \ +NEW_AUX_ENT (AT_IGNORE ,0 ); \ } while (0)#define ARCH_HAS_SETUP_ADDITIONAL_PAGES struct linux_binprm ;
arch/riscv/include/asm/processor.h +2 -0
@@ -7,6 +7,7 @@#define _ASM_RISCV_PROCESSOR_H#include <linux/const.h> +#include <linux/cache.h> #include <vdso/processor.h>
@@ -81,6 +82,7 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid);extern void riscv_fill_hwcap (void );extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern unsigned long signal_minsigstksz__ro_after_init ;#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PROCESSOR_H */
arch/riscv/include/uapi/asm/auxvec.h +1 -0
@@ -35,5 +35,6 @@/* entries in ARCH_DLINFO */ #define AT_VECTOR_SIZE_ARCH 9 +#define AT_MINSIGSTKSZ 51#endif /* _UAPI_ASM_RISCV_AUXVEC_H */
arch/riscv/kernel/signal.c +15 -5
@@ -21,6 +21,8 @@#include <asm/vector.h> #include <asm/csr.h> +unsigned long __ro_after_init signal_minsigstksz; +extern u32 __user_rt_sigreturn[2 ];static size_t riscv_v_sc_size;
@@ -195,7 +197,7 @@ static long restore_sigcontext(struct pt_regs *regs,return -EINVAL ; } -static size_t cal_rt_frame_size (void ) +static size_t cal_rt_frame_size (bool cal_all) {struct rt_sigframe __user *frame;size_t frame_size;
@@ -203,8 +205,10 @@ static size_t cal_rt_frame_size(void) frame_size =sizeof (*frame); -if (has_vector () &&riscv_v_vstate_query (task_pt_regs (current))) - total_context_size += riscv_v_sc_size; +if (has_vector ()) { +if (cal_all ||riscv_v_vstate_query (task_pt_regs (current))) + total_context_size += riscv_v_sc_size; + }/* * Preserved a __riscv_ctx_hdr for END signal context header if an * extension uses __riscv_extra_ext_header
@@ -225,7 +229,7 @@ SYSCALL_DEFINE0(rt_sigreturn)struct rt_sigframe __user *frame;struct task_struct *task;sigset_t set; -size_t frame_size =cal_rt_frame_size (); +size_t frame_size =cal_rt_frame_size (false);/* Always make any pending restarted system calls return -EINTR */ current->restart_block.fn = do_no_restart_syscall;
@@ -320,7 +324,7 @@ static int setup_rt_frame(struct ksignal *ksig, sigset_t *set, {struct rt_sigframe __user *frame;long err =0 ; -size_t frame_size =cal_rt_frame_size (); +size_t frame_size =cal_rt_frame_size (false); frame =get_sigframe (ksig, regs, frame_size);if (!access_ok (frame, frame_size))
@@ -483,4 +487,10 @@ void __init init_rt_signal_env(void) { riscv_v_sc_size =sizeof (struct __riscv_ctx_hdr ) +sizeof (struct __sc_riscv_v_state ) + riscv_v_vsize; +/* +* Determine the stack space required for guaranteed signal delivery. +* The signal_minsigstksz will be populated into the AT_MINSIGSTKSZ entry +* in the auxiliary array at process startup. +*/ + signal_minsigstksz =cal_rt_frame_size (true); }
Signature · 1 line
2.17.1
Re: [PATCH -next v14 14/19] riscv: signal: Report signal frame size to userspace via auxv
Quoted 19 lines · Andy Chiu
From: Vincent Chen <[email protected]>
The vector register belongs to the signal context. They need to be stored and restored as entering and leaving the signal handler. According to the V-extension specification, the maximum length of the vector registers can be 2^(XLEN-1). Hence, if userspace refers to the MINSIGSTKSZ to create a sigframe, it may not be enough. To resolve this problem, this patch refers to the commit
94b07c1f8c39c
("arm64: signal: Report signal frame size to userspace via auxv") to enable userspace to know the minimum required sigframe size through the auxiliary vector and use it to allocate enough memory for signal context.Note that auxv always reports size of the sigframe as if V exists for all starting processes, whenever the kernel has
CONFIG_RISCV_ISA_V. The reason is that users usually reference this value to allocate an alternative signal stack, and the user may use V anytime. So the user must reserve a space for V-context in sigframe in case that the signal handler invokes after the kernel allocating V.
Quoted 3 lines
Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Andy Chiu <[email protected]>
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/27ad0c21/attachment-0001.sig>
Re: [PATCH -next v14 14/19] riscv: signal: Report signal frame size to userspace via auxv
In reply to Andy ChiuQuoted 74 lines · Andy Chiu
From: Vincent Chen <[email protected]>
The vector register belongs to the signal context. They need to be stored and restored as entering and leaving the signal handler. According to the V-extension specification, the maximum length of the vector registers can be 2^(XLEN-1). Hence, if userspace refers to the MINSIGSTKSZ to create a sigframe, it may not be enough. To resolve this problem, this patch refers to the commit
94b07c1f8c39c
("arm64: signal: Report signal frame size to userspace via auxv") to enable userspace to know the minimum required sigframe size through the auxiliary vector and use it to allocate enough memory for signal context.Note that auxv always reports size of the sigframe as if V exists for all starting processes, whenever the kernel has
CONFIG_RISCV_ISA_V. The reason is that users usually reference this value to allocate an alternative signal stack, and the user may use V anytime. So the user must reserve a space for V-context in sigframe in case that the signal handler invokes after the kernel allocating V.Signed-off-by Greentime Hu <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Andy Chiu <[email protected]>--- arch/riscv/include/asm/elf.h | 9 +++++++++ arch/riscv/include/asm/processor.h | 2 ++ arch/riscv/include/uapi/asm/auxvec.h | 1 + arch/riscv/kernel/signal.c | 20 +++++++++++++++----- 4 files changed, 27 insertions(+), 5 deletions(-)arch/riscv/include/asm/elf.h +9
-0@@ -105,6 +105,15 @@ do { \ get_cache_size(3, CACHE_TYPE_UNIFIED)); \NEW_AUX_ENT (AT_L3_CACHEGEOMETRY , \get_cache_geometry (3 ,CACHE_TYPE_UNIFIED )); \ +/* \ +* Should always be nonzero unless there's a kernel bug. \ +* If we haven't determined a sensible value to give to \ +* userspace, omit the entry: \ +*/ \ +if (likely (signal_minsigstksz)) \ +NEW_AUX_ENT (AT_MINSIGSTKSZ , signal_minsigstksz); \ +else \ +NEW_AUX_ENT (AT_IGNORE ,0 ); \ } while (0)#define ARCH_HAS_SETUP_ADDITIONAL_PAGES struct linux_binprm ;arch/riscv/include/asm/processor.h +2
-0@@ -7,6 +7,7 @@#define _ASM_RISCV_PROCESSOR_H#include <linux/const.h> +#include <linux/cache.h> #include <vdso/processor.h> @@ -81,6 +82,7 @@ int riscv_of_parent_hartid(struct device_node *node, unsigned long *hartid);extern void riscv_fill_hwcap (void );extern int arch_dup_task_struct (struct task_struct *dst,struct task_struct *src); +extern unsigned long signal_minsigstksz__ro_after_init ;#endif /* __ASSEMBLY__ */ #endif /* _ASM_RISCV_PROCESSOR_H */ arch/riscv/include/uapi/asm/auxvec.h +0
-0
arch/riscv/include/uapi/asm/auxvec.h line 38
Quoted 4 lines
arch/riscv/include/uapi/asm/auxvec.h +1
-0@@ -35,5 +35,6 @@/* entries in ARCH_DLINFO */ #define AT_VECTOR_SIZE_ARCH 9 +#define AT_MINSIGSTKSZ 51
Proper tab alignment missing.
arch/riscv/kernel/signal.c line 24
Quoted 11 lines
arch/riscv/include/uapi/asm/auxvec.h +0
-0#endif /* _UAPI_ASM_RISCV_AUXVEC_H */ arch/riscv/kernel/signal.c +1
-0@@ -21,6 +21,8 @@#include <asm/vector.h> #include <asm/csr.h> +unsigned long __ro_after_init signal_minsigstksz;
Nit: __ro_after_init placement insistent with the declaration above.
Bj?rn
PATCH v14 15/19 riscv: signal: validate altstack to reflect Vector
In reply to Andy ChiuMINSIGSTKSZ alone have become less informative by the time an user calls sigaltstack(), as the kernel starts to support extensions that dynamically introduce footprint on a signal frame. For example, an RV64V implementation with vlen = 512 may occupy 2K + 40 + 12 Bytes of a signal frame with the upcoming Vector support. And there is no need for reserving the extra sigframe for some processes that do not execute any V-instructions.
Thus, provide the function sigaltstack_size_valid() to validate its size based on current allocation status of supported extensions.
--- arch/riscv/kernel/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/riscv/kernel/signal.c +8 -0
@@ -494,3 +494,11 @@ void __init init_rt_signal_env(void)*/ signal_minsigstksz =cal_rt_frame_size (true); } + +#ifdef CONFIG_DYNAMIC_SIGFRAME +bool sigaltstack_size_valid (size_t ss_size) +{ +return ss_size >cal_rt_frame_size (false); +} +#endif /* CONFIG_DYNAMIC_SIGFRAME */ +
Signature · 1 line
2.17.1
Re: [PATCH -next v14 15/19] riscv: signal: validate altstack to reflect Vector
Quoted 3 lines · Andy Chiu
MINSIGSTKSZ alone have become less informative by the time an user calls
sigaltstack(), as the kernel starts to support extensions that dynamically introduce footprint on a signal frame.
This sentence is a bit difficult to understand. I find re-hashing the wording often helps me understand, so does the following mean the same thing:
"Some extensions, such as vector, dynamically change the footprint of a signal frame, so MINSIGSTKSZ is no longer accurate"
The wording "less informative" doesn't really mean anything, what could happen here is that the sigaltstack could be larger the MINSIGSTKSZ and would therefore be outright wrong?
Quoted 7 lines
For example, an RV64V
implementation with vlen = 512 may occupy 2K + 40 + 12 Bytes of a signal frame with the upcoming Vector support.And there is no need for
reserving the extra sigframe for some processes that do not execute any V-instructions.
Can you reword this sentence like the following, substituting for "so xyz" please?
"Processes that do not execute any vector instructions do not need to reserve the extra sigframe, so xyz".
Quoted 13 lines
Thus, provide the function
sigaltstack_size_valid()to validate its size based on current allocation status of supported extensions.Signed-off-by Andy Chiu <[email protected]>--- arch/riscv/kernel/signal.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/riscv/kernel/signal.c +0
-0
arch/riscv/kernel/signal.c void __init init_rt_signal_env(void) · line 501
Quoted 8 lines
arch/riscv/kernel/signal.c +5
-0@@ -494,3 +494,11 @@ void __init init_rt_signal_env(void)*/ signal_minsigstksz =cal_rt_frame_size (true); } + +#ifdef CONFIG_DYNAMIC_SIGFRAME +bool sigaltstack_size_valid (size_t ss_size) +{ +return ss_size >cal_rt_frame_size (false);
Seeing it here made me wonder, what does "cal" mean. I assume it is meant to be "calculate", but "cal" in my head is usually "calibrate". s/cal/get in the patch adding that function IMO.
arch/riscv/kernel/signal.c void __init init_rt_signal_env(void) · line 503
Quoted 2 lines
arch/riscv/kernel/signal.c +2
-0+} +#endif /* CONFIG_DYNAMIC_SIGFRAME */
The change itself, if my understanding is correct, looks fine...
Thanks,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/eb8d12bf/attachment.sig>
PATCH v14 16/19 riscv: prevent stack corruption by reserving task_pt_regs(p) early
In reply to Andy ChiuFrom: Greentime Hu <[email protected]>
Early function calls, such as setup_vm, relocate_enable_mmu, soc_early_init etc, are free to operate on stack. However, PT_SIZE_ON_STACK bytes at the head of the kernel stack are purposedly reserved for the placement of per-task register context pointed by task_pt_regs(p). Those functions may corrupt task_pt_regs if we overlap the $sp with it. In fact, we had accidentally corrupted sstatus.VS in some tests, treating the kernel to save V context before V was actually allocated, resulting in a kernel panic.
Thus, we should skip PT_SIZE_ON_STACK for $sp before making C function calls from the top-level assembly.
--- arch/riscv/kernel/head.S | 2 ++ 1 file changed, 2 insertions(+)
arch/riscv/kernel/head.S +2 -0
@@ -301,6 +301,7 @@ clear_bss_done: la tp, init_task la sp, init_thread_union + THREAD_SIZE XIP_FIXUP_OFFSET sp + addi sp, sp, -PT_SIZE_ON_STACK #ifdef CONFIG_BUILTIN_DTB la a0, __dtb_start XIP_FIXUP_OFFSET a0
@@ -318,6 +319,7 @@ clear_bss_done: /* Restore C environment */ la tp, init_task la sp, init_thread_union + THREAD_SIZE + addi sp, sp, -PT_SIZE_ON_STACK #ifdef CONFIG_KASAN call kasan_early_init
Signature · 1 line
2.17.1
Re: [PATCH -next v14 16/19] riscv: prevent stack corruption by reserving task_pt_regs(p) early
Hey Andy
Quoted 3 lines · Andy Chiu
From: Greentime Hu <[email protected]>
Early function calls, such as
setup_vm,relocate_enable_mmu,
Here, and elsewhere in the series, please append the () to functions in commit text.
Quoted 34 lines
soc_early_initetc, are free to operate on stack. However,PT_SIZE_ON_STACKbytes at the head of the kernel stack are purposedly reserved for the placement of per-task register context pointed bytask_pt_regs(p). Those functions may corrupttask_pt_regsif we overlap the $sp with it. In fact, we had accidentally corrupted sstatus.VS in some tests, treating the kernel to save V context before V was actually allocated, resulting in a kernel panic.Thus, we should skip
PT_SIZE_ON_STACKfor $sp before making C function calls from the top-level assembly.Co-developed-by ShihPo Hung <[email protected]>Signed-off-by ShihPo Hung <[email protected]>Co-developed-by Vincent Chen <[email protected]>Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Andy Chiu <[email protected]>--- arch/riscv/kernel/head.S | 2 ++ 1 file changed, 2 insertions(+)arch/riscv/kernel/head.S +1
-0@@ -301,6 +301,7 @@ clear_bss_done: la tp, init_task la sp, init_thread_union + THREAD_SIZE XIP_FIXUP_OFFSET sp + addi sp, sp, -PT_SIZE_ON_STACK #ifdef CONFIG_BUILTIN_DTB la a0, __dtb_start XIP_FIXUP_OFFSET a0
arch/riscv/kernel/head.S clear_bss_done: · line 322
Quoted 4 lines
arch/riscv/kernel/head.S +1
-0@@ -318,6 +319,7 @@ clear_bss_done: /* Restore C environment */ la tp, init_task la sp, init_thread_union + THREAD_SIZE + addi sp, sp, -PT_SIZE_ON_STACK
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/42d304db/attachment.sig>
PATCH v14 17/19 riscv: kvm: Add V extension to KVM ISA
In reply to Andy ChiuFrom: Vincent Chen <[email protected]>
Add V extension to KVM isa extension list to enable supporting of V extension on VCPUs.
--- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 1 + 2 files changed, 2 insertions(+)
arch/riscv/include/uapi/asm/kvm.h +1 -0
@@ -105,6 +105,7 @@ enum KVM_RISCV_ISA_EXT_ID {KVM_RISCV_ISA_EXT_SVINVAL ,KVM_RISCV_ISA_EXT_ZIHINTPAUSE ,KVM_RISCV_ISA_EXT_ZICBOM , +KVM_RISCV_ISA_EXT_V , KVM_RISCV_ISA_EXT_MAX, };
arch/riscv/kvm/vcpu.c +1 -0
@@ -57,6 +57,7 @@ static const unsigned long kvm_isa_ext_arr[] = { [KVM_RISCV_ISA_EXT_H] = RISCV_ISA_EXT_h, [KVM_RISCV_ISA_EXT_I] = RISCV_ISA_EXT_i, [KVM_RISCV_ISA_EXT_M] = RISCV_ISA_EXT_m, + [KVM_RISCV_ISA_EXT_V] = RISCV_ISA_EXT_v,KVM_ISA_EXT_ARR (SSTC ), KVM_ISA_EXT_ARR(SVINVAL),
Signature · 1 line
2.17.1
Re: [PATCH -next v14 17/19] riscv: kvm: Add V extension to KVM ISA
Quoted 8 lines · Andy Chiu
From: Vincent Chen <[email protected]>
Add V extension to KVM isa extension list to enable supporting of V extension on VCPUs.
Signed-off-by Vincent Chen <[email protected]>Signed-off-by Greentime Hu <[email protected]>Signed-off-by Andy Chiu <[email protected]>
Thanks,
Conor.
Quoted 32 lines
--- arch/riscv/include/uapi/asm/kvm.h | 1 + arch/riscv/kvm/vcpu.c | 1 + 2 files changed, 2 insertions(+)arch/riscv/include/uapi/asm/kvm.h +1
-0@@ -105,6 +105,7 @@ enum KVM_RISCV_ISA_EXT_ID {KVM_RISCV_ISA_EXT_SVINVAL ,KVM_RISCV_ISA_EXT_ZIHINTPAUSE ,KVM_RISCV_ISA_EXT_ZICBOM , +KVM_RISCV_ISA_EXT_V , KVM_RISCV_ISA_EXT_MAX, };arch/riscv/kvm/vcpu.c +1
-0@@ -57,6 +57,7 @@ static const unsigned long kvm_isa_ext_arr[] = { [KVM_RISCV_ISA_EXT_H] = RISCV_ISA_EXT_h, [KVM_RISCV_ISA_EXT_I] = RISCV_ISA_EXT_i, [KVM_RISCV_ISA_EXT_M] = RISCV_ISA_EXT_m, + [KVM_RISCV_ISA_EXT_V] = RISCV_ISA_EXT_v,KVM_ISA_EXT_ARR (SSTC ), KVM_ISA_EXT_ARR(SVINVAL),Signature · 1 line
2.17.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/2ff58693/attachment.sig>
PATCH v14 18/19 riscv: KVM: Add vector lazy save/restore support
In reply to Andy ChiuFrom: Vincent Chen <[email protected]>
This patch adds vector context save/restore for guest VCPUs. To reduce the impact on KVM performance, the implementation imitates the FP context switch mechanism to lazily store and restore the vector context only when the kernel enters/exits the in-kernel run loop and not during the KVM world switch.
--- arch/riscv/include/asm/kvm_host.h | 2 + arch/riscv/include/asm/kvm_vcpu_vector.h | 77 ++++++++++ arch/riscv/include/uapi/asm/kvm.h | 7 + arch/riscv/kvm/Makefile | 1 + arch/riscv/kvm/vcpu.c | 30 ++++ arch/riscv/kvm/vcpu_vector.c | 177 +++++++++++++++++++++++ 6 files changed, 294 insertions(+) create mode 100644 arch/riscv/include/asm/kvm_vcpu_vector.h create mode 100644 arch/riscv/kvm/vcpu_vector.c
arch/riscv/include/asm/kvm_host.h +2 -0
@@ -14,6 +14,7 @@#include <linux/kvm_types.h> #include <linux/spinlock.h> #include <asm/hwcap.h> +#include <asm/ptrace.h> #include <asm/kvm_vcpu_fp.h> #include <asm/kvm_vcpu_insn.h> #include <asm/kvm_vcpu_sbi.h>
@@ -140,6 +141,7 @@ struct kvm_cpu_context {unsigned long sstatus;unsigned long hstatus;union __riscv_fp_state fp; +struct __riscv_v_ext_state vector; };struct kvm_vcpu_csr {
arch/riscv/include/asm/kvm_vcpu_vector.h new file +77 -0
77 lines not on this page · raw message
arch/riscv/include/uapi/asm/kvm.h +7 -0
@@ -153,6 +153,13 @@ enum KVM_RISCV_ISA_EXT_ID {/* ISA Extension registers are mapped as type 7 */ #define KVM_REG_RISCV_ISA_EXT (0x07 << KVM_REG_RISCV_TYPE_SHIFT) +/* V extension registers are mapped as type 8 */ +#define KVM_REG_RISCV_VECTOR (0x08 << KVM_REG_RISCV_TYPE_SHIFT) +#define KVM_REG_RISCV_VECTOR_CSR_REG (name) \ + (offsetof(struct __riscv_v_ext_state, name) / sizeof(unsigned long)) +#define KVM_REG_RISCV_VECTOR_REG (n) \ + ((n) + sizeof(struct __riscv_v_ext_state) / sizeof(unsigned long)) +#endif #endif /* __LINUX_KVM_RISCV_H */
arch/riscv/kvm/Makefile +1 -0
@@ -17,6 +17,7 @@ kvm-y += mmu.o kvm-y += vcpu.o kvm-y += vcpu_exit.o kvm-y += vcpu_fp.o +kvm-y += vcpu_vector.o kvm-y += vcpu_insn.o kvm-y += vcpu_switch.o kvm-y += vcpu_sbi.o
arch/riscv/kvm/vcpu.c +30 -0
@@ -22,6 +22,8 @@#include <asm/cacheflush.h> #include <asm/hwcap.h> #include <asm/sbi.h> +#include <asm/vector.h> +#include <asm/kvm_vcpu_vector.h> const struct _kvm_stats_desc kvm_vcpu_stats_desc[] = {KVM_GENERIC_VCPU_STATS (),
@@ -134,6 +136,8 @@ static void kvm_riscv_reset_vcpu(struct kvm_vcpu *vcpu)kvm_riscv_vcpu_fp_reset (vcpu); +kvm_riscv_vcpu_vector_reset (vcpu); +kvm_riscv_vcpu_timer_reset (vcpu);WRITE_ONCE (vcpu->arch.irqs_pending,0 );
@@ -189,6 +193,15 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu) cntx->hstatus |=HSTATUS_SPVP ; cntx->hstatus |=HSTATUS_SPV ; +if (has_vector ()) { + cntx->vector.datap =kmalloc (riscv_v_vsize,GFP_KERNEL ); +if (!cntx->vector.datap) +return -ENOMEM ; + vcpu->arch.host_context.vector.datap =kzalloc (riscv_v_vsize,GFP_KERNEL ); +if (!vcpu->arch.host_context.vector.datap) +return -ENOMEM ; + } +/* By default, make CY, TM, and IR counters accessible in VU mode */ reset_csr->scounteren =0x7 ;
@@ -219,6 +232,9 @@ void kvm_arch_vcpu_destroy(struct kvm_vcpu *vcpu)/* Free unused pages pre-allocated for G-stage page table mappings */ kvm_mmu_free_memory_cache (&vcpu->arch.mmu_page_cache); + +/* Free vector context space for host and guest kernel */ +kvm_riscv_vcpu_free_vector_context (vcpu); }int kvm_cpu_has_pending_timer (struct kvm_vcpu *vcpu)
@@ -595,6 +611,9 @@ static int kvm_riscv_vcpu_set_reg(struct kvm_vcpu *vcpu, KVM_REG_RISCV_FP_D);case KVM_REG_RISCV_ISA_EXT :return kvm_riscv_vcpu_set_reg_isa_ext (vcpu, reg); +case KVM_REG_RISCV_VECTOR : +return kvm_riscv_vcpu_set_reg_vector (vcpu, reg, +KVM_REG_RISCV_VECTOR );default :break ; }
@@ -622,6 +641,9 @@ static int kvm_riscv_vcpu_get_reg(struct kvm_vcpu *vcpu, KVM_REG_RISCV_FP_D);case KVM_REG_RISCV_ISA_EXT :return kvm_riscv_vcpu_get_reg_isa_ext (vcpu, reg); +case KVM_REG_RISCV_VECTOR : +return kvm_riscv_vcpu_get_reg_vector (vcpu, reg, +KVM_REG_RISCV_VECTOR );default :break ; }
@@ -888,6 +910,9 @@ void kvm_arch_vcpu_load(struct kvm_vcpu *vcpu, int cpu)kvm_riscv_vcpu_host_fp_save (&vcpu->arch.host_context);kvm_riscv_vcpu_guest_fp_restore (&vcpu->arch.guest_context, vcpu->arch.isa); +kvm_riscv_vcpu_host_vector_save (&vcpu->arch.host_context); +kvm_riscv_vcpu_guest_vector_restore (&vcpu->arch.guest_context, + vcpu->arch.isa); vcpu->cpu = cpu; }
@@ -903,6 +928,11 @@ void kvm_arch_vcpu_put(struct kvm_vcpu *vcpu)kvm_riscv_vcpu_host_fp_restore (&vcpu->arch.host_context);kvm_riscv_vcpu_timer_save (vcpu); +kvm_riscv_vcpu_guest_vector_save (&vcpu->arch.guest_context, + vcpu->arch.isa); +kvm_riscv_vcpu_host_vector_restore (&vcpu->arch.host_context); + +csr_write (CSR_HGATP ,0 ); csr->vsstatus =csr_read (CSR_VSSTATUS ); csr->vsie =csr_read (CSR_VSIE );
arch/riscv/kvm/vcpu_vector.c new file +177 -0
177 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH v14 19/19 riscv: Enable Vector code to be built
In reply to Andy ChiuFrom: Guo Ren <[email protected]>
This patch adds a config which enables vector feature from the kernel space.
--- arch/riscv/Kconfig | 18 ++++++++++++++++++ arch/riscv/Makefile | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-)
arch/riscv/Kconfig +18 -0
@@ -418,6 +418,24 @@ config RISCV_ISA_SVPBMT If you don't know what to do here, say Y. +config TOOLCHAIN_HAS_V + bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) + depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + +config RISCV_ISA_V + bool "VECTOR extension support" + depends on TOOLCHAIN_HAS_V + select DYNAMIC_SIGFRAME + default y + help + Say N here if you want to disable all vector related procedure + in the kernel. + + If you don't know what to do here, say Y. + config TOOLCHAIN_HAS_ZBB bool default y
arch/riscv/Makefile +2 -1
@@ -56,6 +56,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c +riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v # Newer binutils versions default to ISA spec version 20191213 which moves some # instructions from the I extension to the Zicsr and Zifencei extensions.
@@ -65,7 +66,7 @@ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei # Check if the toolchain supports Zihintpause extension riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause -KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) +KBUILD_CFLAGS += -march=$(subst fdv,,$(riscv-march-y)) KBUILD_AFLAGS += -march=$(riscv-march-y) KBUILD_CFLAGS += -mno-save-restore
Signature · 1 line
2.17.1
kernel test robot
build botRe: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
I love your patch! Yet something to improve:
Hi Andy,
I love your patch! Yet something to improve:
[auto build test ERROR on next-20230224]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 patch link: https://lore.kernel.org/r/20230224170118.16766-20-andy.chiu%40sifive.com patch subject: [PATCH -next v14 19/19] riscv: Enable Vector code to be built config: riscv-buildonly-randconfig-r002-20230222 (https://download.01.org/0day-ci/archive/20230225/202302250511.yaHzCeR1-lkp at intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059
git checkout cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/202302250511.yaHzCeR1-lkp at intel.com/
All error/warnings (new ones prefixed by >>):
In file included from arch/riscv/kernel/ptrace.c:10:
>> arch/riscv/include/asm/vector.h:88:3: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:1:2: note: instantiated into assembly here
vsetvli t4, x0, e8, m8, ta, ma
^
In file included from arch/riscv/kernel/ptrace.c:10:
arch/riscv/include/asm/vector.h:88:36: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:2:2: note: instantiated into assembly here
vse8.v v0, (a1)
^
In file included from arch/riscv/kernel/ptrace.c:10:
arch/riscv/include/asm/vector.h:90:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:4:2: note: instantiated into assembly here
vse8.v v8, (a1)
^
In file included from arch/riscv/kernel/ptrace.c:10:
arch/riscv/include/asm/vector.h:92:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:6:2: note: instantiated into assembly here
vse8.v v16, (a1)
^
In file included from arch/riscv/kernel/ptrace.c:10:
arch/riscv/include/asm/vector.h:94:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:8:2: note: instantiated into assembly here
vse8.v v24, (a1)
^ 5 errors generated.
--
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:105:3: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:1:2: note: instantiated into assembly here
vsetvli t4, x0, e8, m8, ta, ma
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:105:36: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:2:2: note: instantiated into assembly here
vle8.v v0, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:107:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:4:2: note: instantiated into assembly here
vle8.v v8, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:109:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:6:2: note: instantiated into assembly here
vle8.v v16, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:111:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:8:2: note: instantiated into assembly here
vle8.v v24, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:75:3: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvl x0, %2, %1\n\t"
^
<inline asm>:1:2: note: instantiated into assembly here
vsetvl x0, a3, a2
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
>> arch/riscv/include/asm/vector.h:88:3: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:1:2: note: instantiated into assembly here
vsetvli t4, x0, e8, m8, ta, ma
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:88:36: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"vsetvli t4, x0, e8, m8, ta, ma\n\t"
^
<inline asm>:2:2: note: instantiated into assembly here
vse8.v v0, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:90:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:4:2: note: instantiated into assembly here
vse8.v v8, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:92:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:6:2: note: instantiated into assembly here
vse8.v v16, (a1)
^
In file included from arch/riscv/kernel/signal.c:20:
In file included from arch/riscv/include/asm/switch_to.h:11:
arch/riscv/include/asm/vector.h:94:21: error: instruction requires the following: 'V' (Vector Extension for Application Processors), 'Zve32x' or 'Zve64x' (Vector Extensions for Embedded Processors)
"add %0, %0, t4\n\t"
^
<inline asm>:8:2: note: instantiated into assembly here
vse8.v v24, (a1)
^
11 errors generated.
--
>> arch/riscv/kernel/vector.c:50:3: error: expected expression
u32 width = RVV_EXRACT_VL_VS_WIDTH(insn_buf);
^
>> arch/riscv/kernel/vector.c:52:7: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
arch/riscv/kernel/vector.c:52:37: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
arch/riscv/kernel/vector.c:53:7: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
arch/riscv/kernel/vector.c:53:38: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
arch/riscv/kernel/vector.c:57:3: error: expected expression
u32 csr = RVG_EXTRACT_SYSTEM_CSR(insn_buf);
^
>> arch/riscv/kernel/vector.c:59:8: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
arch/riscv/kernel/vector.c:59:29: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
arch/riscv/kernel/vector.c:60:8: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^
arch/riscv/kernel/vector.c:60:25: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^
>> arch/riscv/kernel/vector.c:67:5: warning: no previous prototype for function 'riscv_v_thread_zalloc' [-Wmissing-prototypes]
int riscv_v_thread_zalloc(void)
^ arch/riscv/kernel/vector.c:67:1: note: declare 'static' if the function is not intended to be used outside of this translation unit int riscv_v_thread_zalloc(void)
^
static
1 warning and 10 errors generated.
vim +88 arch/riscv/include/asm/vector.h
27038c69020be5 Greentime Hu 2023-02-24 81
e296a266de6c10 Greentime Hu 2023-02-24 82 static inline void __riscv_v_vstate_save(struct __riscv_v_ext_state *save_to,
e296a266de6c10 Greentime Hu 2023-02-24 83 void *datap)
27038c69020be5 Greentime Hu 2023-02-24 84 {
27038c69020be5 Greentime Hu 2023-02-24 85 riscv_v_enable();
27038c69020be5 Greentime Hu 2023-02-24 86 __vstate_csr_save(save_to);
27038c69020be5 Greentime Hu 2023-02-24 87 asm volatile (
27038c69020be5 Greentime Hu 2023-02-24 @88 "vsetvli t4, x0, e8, m8, ta, ma\n\t"
27038c69020be5 Greentime Hu 2023-02-24 89 "vse8.v v0, (%0)\n\t"
27038c69020be5 Greentime Hu 2023-02-24 90 "add %0, %0, t4\n\t"
27038c69020be5 Greentime Hu 2023-02-24 91 "vse8.v v8, (%0)\n\t"
27038c69020be5 Greentime Hu 2023-02-24 92 "add %0, %0, t4\n\t"
27038c69020be5 Greentime Hu 2023-02-24 93 "vse8.v v16, (%0)\n\t"
27038c69020be5 Greentime Hu 2023-02-24 94 "add %0, %0, t4\n\t"
27038c69020be5 Greentime Hu 2023-02-24 95 "vse8.v v24, (%0)\n\t"
27038c69020be5 Greentime Hu 2023-02-24 96 : : "r" (datap) : "t4", "memory");
27038c69020be5 Greentime Hu 2023-02-24 97 riscv_v_disable();
27038c69020be5 Greentime Hu 2023-02-24 98 }27038c69020be5 Greentime Hu 2023-02-24 99
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
kernel test robot
build botRe: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
In reply to Andy ChiuI love your patch! Perhaps something to improve:
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20230224]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 patch link: https://lore.kernel.org/r/20230224170118.16766-20-andy.chiu%40sifive.com patch subject: [PATCH -next v14 19/19] riscv: Enable Vector code to be built config: riscv-randconfig-r014-20230222 (https://download.01.org/0day-ci/archive/20230225/[email protected]/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 git checkout cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash lib/zstd/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All warnings (new ones prefixed by >>):
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
--
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
--
lib/zstd/compress/huf_compress.c:471:16: warning: unused function 'HUF_isSorted' [-Wunused-function]
MEM_STATIC int HUF_isSorted(nodeElt huffNode[], U32 const maxSymbolValue1) {
^
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
1 warning generated.
--
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
--
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
--
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
--
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` >> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
--
lib/zstd/compress/zstd_lazy.c:835:16: warning: unused function 'ZSTD_isAligned' [-Wunused-function]
MEM_STATIC int ZSTD_isAligned(void const* ptr, size_t align) {
^
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()`
>> warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in `TypeSize::operator ScalarTy()` warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy()
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in TypeSize::operator ScalarTy() 1 warning generated.
..
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
Hi Andy,
Quoted 25 lines · kernel test robot
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20230224]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 patch link: https://lore.kernel.org/r/20230224170118.16766-20-andy.chiu%40sifive.com patch subject: [PATCH -next v14 19/19] riscv: Enable Vector code to be built config: riscv-randconfig-r014-20230222 (https://download.01.org/0day-ci/archive/20230225/202302250924.ukv4ZxOc-lkp at intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 git checkoutcd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bashlib/zstd/
Quoted 7 lines
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/202302250924.ukv4ZxOc-lkp at intel.com/All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in
TypeSize::operator ScalarTy()
Please consider adding the following diff to patch 19 to avoid this issue (see the upstream bug report for more details):
arch/riscv/Kconfig +2 -0
@@ -423,6 +423,8 @@ config TOOLCHAIN_HAS_V depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + # https://github.com/llvm/llvm-project/issues/61096 + depends on !(CC_IS_CLANG && CLANG_VERSION >= 160000 && KASAN) config RISCV_ISA_V bool "VECTOR extension support"
---
Additionally, with older versions of clang 15.x and older, I see:
arch/riscv/kernel/vector.c:50:3: error: expected expression
u32 width = RVV_EXRACT_VL_VS_WIDTH(insn_buf);
^
arch/riscv/kernel/vector.c:52:7: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
arch/riscv/kernel/vector.c:52:37: error: use of undeclared identifier 'width'
if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 ||
^
arch/riscv/kernel/vector.c:53:7: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
arch/riscv/kernel/vector.c:53:38: error: use of undeclared identifier 'width'
width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64)
^
arch/riscv/kernel/vector.c:57:3: error: expected expression
u32 csr = RVG_EXTRACT_SYSTEM_CSR(insn_buf);
^
arch/riscv/kernel/vector.c:59:8: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
arch/riscv/kernel/vector.c:59:29: error: use of undeclared identifier 'csr'
if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
^
arch/riscv/kernel/vector.c:60:8: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^
arch/riscv/kernel/vector.c:60:25: error: use of undeclared identifier 'csr'
(csr >= CSR_VL && csr <= CSR_VLENB))
^
10 errors generated.which is fixed by:
arch/riscv/kernel/vector.c +4 -2
@@ -46,14 +46,15 @@ static bool insn_is_vector(u32 insn_buf) is_vector = true;break ;case RVV_OPCODE_VL : -case RVV_OPCODE_VS : +case RVV_OPCODE_VS : {u32 width =RVV_EXRACT_VL_VS_WIDTH (insn_buf);if (width ==RVV_VL_VS_WIDTH_8 || width ==RVV_VL_VS_WIDTH_16 || width ==RVV_VL_VS_WIDTH_32 || width ==RVV_VL_VS_WIDTH_64 ) is_vector = true;break ; -case RVG_OPCODE_SYSTEM : + } +case RVG_OPCODE_SYSTEM : {u32 csr =RVG_EXTRACT_SYSTEM_CSR (insn_buf); if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||
@@ -61,6 +62,7 @@ static bool insn_is_vector(u32 insn_buf) is_vector = true;break ; } + }return is_vector; }
---
Cheers,
Nathan
Re: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
Quoted 44 lines · Nathan Chancellor
Hi Andy,
Quoted 25 lines · kernel test robot
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20230224]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 patch link: https://lore.kernel.org/r/20230224170118.16766-20-andy.chiu%40sifive.com patch subject: [PATCH -next v14 19/19] riscv: Enable Vector code to be built config: riscv-randconfig-r014-20230222 (https://download.01.org/0day-ci/archive/20230225/202302250924.ukv4ZxOc-lkp at intel.com/config) compiler: clang version 17.0.0 (https://github.com/llvm/llvm-project db89896bbbd2251fff457699635acbbedeead27f)reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/intel-lab-lkp/linux/commit/cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 git checkoutcd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
# save the config file
mkdirbuild_dir&& cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bashlib/zstd/Quoted 7 lines
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/202302250924.ukv4ZxOc-lkp at intel.com/All warnings (new ones prefixed by >>):
Quoted 1 line
Quoted 1 line
warning: Invalid size request on a scalable vector; Cannot implicitly convert a scalable size to a fixed-width size in
TypeSize::operator ScalarTy()Please consider adding the following diff to patch 19 to avoid this issue (see the upstream bug report for more details):
arch/riscv/Kconfig +0
-0
arch/riscv/Kconfig config TOOLCHAIN_HAS_V · line 427
Quoted 5 lines
arch/riscv/Kconfig +2
-0@@ -423,6 +423,8 @@ config TOOLCHAIN_HAS_V depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + # https://github.com/llvm/llvm-project/issues/61096 + depends on !(CC_IS_CLANG && CLANG_VERSION >= 160000 && KASAN)
Please don't! As far as I can tell, this is what I was warning about in:
https://lore.kernel.org/linux-riscv/20230224170118.16766-1-andy.chiu at sifive.com/T/#m2c0e6128230d407c843e10406305da9ff5dca902
The randconfig has RISCV_ISA_C enabled, so you're getting an ISA string containing "fdcv" and fdv,,$(riscv-march-y) fails to remove either fd, or v.
The below is very much valid though, please test v15 with clang/llvm Andy!
Quoted 68 lines
Additionally, with older versions of clang 15.x and older, I see:
arch/riscv/kernel/vector.c:50:3: error: expected expression u32 width = RVV_EXRACT_VL_VS_WIDTH(insn_buf); ^ arch/riscv/kernel/vector.c:52:7: error: use of undeclared identifier 'width' if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 || ^ arch/riscv/kernel/vector.c:52:37: error: use of undeclared identifier 'width' if (width == RVV_VL_VS_WIDTH_8 || width == RVV_VL_VS_WIDTH_16 || ^ arch/riscv/kernel/vector.c:53:7: error: use of undeclared identifier 'width' width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64) ^ arch/riscv/kernel/vector.c:53:38: error: use of undeclared identifier 'width' width == RVV_VL_VS_WIDTH_32 || width == RVV_VL_VS_WIDTH_64) ^ arch/riscv/kernel/vector.c:57:3: error: expected expression u32 csr = RVG_EXTRACT_SYSTEM_CSR(insn_buf); ^ arch/riscv/kernel/vector.c:59:8: error: use of undeclared identifier 'csr' if ((csr >= CSR_VSTART && csr <= CSR_VCSR) || ^ arch/riscv/kernel/vector.c:59:29: error: use of undeclared identifier 'csr' if ((csr >= CSR_VSTART && csr <= CSR_VCSR) || ^ arch/riscv/kernel/vector.c:60:8: error: use of undeclared identifier 'csr' (csr >= CSR_VL && csr <= CSR_VLENB)) ^ arch/riscv/kernel/vector.c:60:25: error: use of undeclared identifier 'csr' (csr >= CSR_VL && csr <= CSR_VLENB)) ^ 10 errors generated.which is fixed by:
arch/riscv/kernel/vector.c +4
-3@@ -46,14 +46,15 @@ static bool insn_is_vector(u32 insn_buf) is_vector = true;break ;case RVV_OPCODE_VL : -case RVV_OPCODE_VS : +case RVV_OPCODE_VS : {u32 width =RVV_EXRACT_VL_VS_WIDTH (insn_buf);if (width ==RVV_VL_VS_WIDTH_8 || width ==RVV_VL_VS_WIDTH_16 || width ==RVV_VL_VS_WIDTH_32 || width ==RVV_VL_VS_WIDTH_64 ) is_vector = true;break ; -case RVG_OPCODE_SYSTEM : + } +case RVG_OPCODE_SYSTEM : {u32 csr =RVG_EXTRACT_SYSTEM_CSR (insn_buf); if ((csr >= CSR_VSTART && csr <= CSR_VCSR) ||@@ -61,6 +62,7 @@ static bool insn_is_vector(u32 insn_buf) is_vector = true;break ; } + }return is_vector; } ---
Quoted 2 lines
Cheers,
Nathan
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230301/06500313/attachment-0001.sig>
kernel test robot
build botRe: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
In reply to Andy ChiuI love your patch! Perhaps something to improve:
Hi Andy,
I love your patch! Perhaps something to improve:
[auto build test WARNING on next-20230224]
url: https://github.com/intel-lab-lkp/linux/commits/Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059 patch link: https://lore.kernel.org/r/20230224170118.16766-20-andy.chiu%40sifive.com patch subject: [PATCH -next v14 19/19] riscv: Enable Vector code to be built config: riscv-randconfig-r042-20230223 (https://download.01.org/0day-ci/archive/20230225/202302251633.Tsr3ebfs-lkp at intel.com/config) compiler: riscv32-linux-gcc (GCC) 12.1.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# https://github.com/intel-lab-lkp/linux/commit/cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Andy-Chiu/riscv-Rename-__switch_to_aux-fpu/20230225-011059
git checkout cd0ad21a9ef9d63f1eef80fd3b09ae6e0d884ce3
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv olddefconfig COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=riscv SHELL=/bin/bash arch/riscv/kernel/
If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/202302251633.Tsr3ebfs-lkp at intel.com/
All warnings (new ones prefixed by >>):
>> arch/riscv/kernel/vector.c:67:5: warning: no previous prototype for 'riscv_v_thread_zalloc' [-Wmissing-prototypes]
67 | int riscv_v_thread_zalloc(void)
| ^~~~~~~~~~~~~~~~~~~~~
vim +/riscv_v_thread_zalloc +67 arch/riscv/kernel/vector.c
b57b7b7279ef75 Andy Chiu 2023-02-24 66
b57b7b7279ef75 Andy Chiu 2023-02-24 @67 int riscv_v_thread_zalloc(void)
b57b7b7279ef75 Andy Chiu 2023-02-24 68 {
b57b7b7279ef75 Andy Chiu 2023-02-24 69 void *datap;
b57b7b7279ef75 Andy Chiu 2023-02-24 70
b57b7b7279ef75 Andy Chiu 2023-02-24 71 datap = kzalloc(riscv_v_vsize, GFP_KERNEL);
b57b7b7279ef75 Andy Chiu 2023-02-24 72 if (!datap)
b57b7b7279ef75 Andy Chiu 2023-02-24 73 return -ENOMEM;
b57b7b7279ef75 Andy Chiu 2023-02-24 74 current->thread.vstate.datap = datap;
b57b7b7279ef75 Andy Chiu 2023-02-24 75 memset(¤t->thread.vstate, 0, offsetof(struct __riscv_v_ext_state,
b57b7b7279ef75 Andy Chiu 2023-02-24 76 datap));
b57b7b7279ef75 Andy Chiu 2023-02-24 77 return 0;
b57b7b7279ef75 Andy Chiu 2023-02-24 78 }
b57b7b7279ef75 Andy Chiu 2023-02-24 79 Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests
Re: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
In reply to Andy ChiuHey Andy,
Quoted 11 lines · Andy Chiu
From: Guo Ren <[email protected]>
This patch adds a config which enables vector feature from the kernel space.
Signed-off-by Guo Ren <[email protected]>Co-developed-by Greentime Hu <[email protected]>Signed-off-by Greentime Hu <[email protected]>Suggested-by Vineet Gupta <[email protected]>Suggested-by Atish Patra <[email protected]>Signed-off-by Andy Chiu <[email protected]>
At this point, you've basically re-written this patch and should be listed as a co-author at the very least!
Quoted 14 lines
--- arch/riscv/Kconfig | 18 ++++++++++++++++++ arch/riscv/Makefile | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-)arch/riscv/Kconfig +1
-0@@ -418,6 +418,24 @@ config RISCV_ISA_SVPBMT If you don't know what to do here, say Y. +config TOOLCHAIN_HAS_V
arch/riscv/Kconfig config RISCV_ISA_SVPBMT · line 431
Quoted 10 lines
arch/riscv/Kconfig +10
-0+ bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) + depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + +config RISCV_ISA_V + bool "VECTOR extension support" + depends on TOOLCHAIN_HAS_V + select DYNAMIC_SIGFRAME
So, nothing here makes V depend on CONFIG_FPU...
Quoted 15 lines
arch/riscv/Kconfig +7
-0+ default y + help + Say N here if you want to disable all vector related procedure + in the kernel. + + If you don't know what to do here, say Y. + config TOOLCHAIN_HAS_ZBB bool default yarch/riscv/Makefile +0
-0
arch/riscv/Makefile riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima · line 57
Quoted 2 lines
arch/riscv/Makefile +0
-0@@ -56,6 +56,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
...but march only contains fd if CONFIG_FPU is enabled...
arch/riscv/Makefile riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei · line 69
Quoted 11 lines
arch/riscv/Makefile +2
-1riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c +riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v # Newer binutils versions default to ISA spec version 20191213 which moves some # instructions from the I extension to the Zicsr and Zifencei extensions.@@ -65,7 +66,7 @@ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei # Check if the toolchain supports Zihintpause extension riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause -KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) +KBUILD_CFLAGS += -march=$(subst fdv,,$(riscv-march-y))
...so I think this will not work if !CONFIG_FPU && RISCV_ISA_V. IIRC, vector uses some floating point opcodes, but does it (or Linux's implementation) actually depend on having floating point support in the kernel?
If not, this cannot be done in a oneliner. Otherwise, CONFIG_RISCV_ISA_V should explicitly depend on CONFIG_FPU.
Quoted 7 lines
arch/riscv/Makefile +0
-0KBUILD_AFLAGS += -march=$(riscv-march-y) KBUILD_CFLAGS += -mno-save-restoreSignature · 1 line
2.17.1
Re: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
Quoted 74 lines · Conor Dooley
Hey Andy,
Quoted 11 lines · Andy Chiu
From: Guo Ren <[email protected]>
This patch adds a config which enables vector feature from the kernel space.
Signed-off-by Guo Ren <[email protected]>Co-developed-by Greentime Hu <[email protected]>Signed-off-by Greentime Hu <[email protected]>Suggested-by Vineet Gupta <[email protected]>Suggested-by Atish Patra <[email protected]>Signed-off-by Andy Chiu <[email protected]>At this point, you've basically re-written this patch and should be listed as a co-author at the very least!
Quoted 14 lines
--- arch/riscv/Kconfig | 18 ++++++++++++++++++ arch/riscv/Makefile | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-)arch/riscv/Kconfig +1
-0@@ -418,6 +418,24 @@ config RISCV_ISA_SVPBMT If you don't know what to do here, say Y. +config TOOLCHAIN_HAS_Varch/riscv/Kconfig config RISCV_ISA_SVPBMT · line 431
Quoted 10 lines
arch/riscv/Kconfig +10
-0+ bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) + depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + +config RISCV_ISA_V + bool "VECTOR extension support" + depends on TOOLCHAIN_HAS_V + select DYNAMIC_SIGFRAMESo, nothing here makes V depend on
CONFIG_FPU...Quoted 15 lines
arch/riscv/Kconfig +7
-0+ default y + help + Say N here if you want to disable all vector related procedure + in the kernel. + + If you don't know what to do here, say Y. + config TOOLCHAIN_HAS_ZBB bool default yarch/riscv/Makefile +0
-0arch/riscv/Makefile riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima · line 57
Quoted 2 lines
arch/riscv/Makefile +0
-0@@ -56,6 +56,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd...but march only contains fd if
CONFIG_FPUis enabled...Quoted 9 lines
arch/riscv/Makefile +1
-0riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c +riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v # Newer binutils versions default to ISA spec version 20191213 which moves some # instructions from the I extension to the Zicsr and Zifencei extensions.@@ -65,7 +66,7 @@ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei # Check if the toolchain supports Zihintpause extension riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
Quoted 7 lines
arch/riscv/Makefile riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei · line 69
Quoted 2 lines
arch/riscv/Makefile +1
-1-KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) +KBUILD_CFLAGS += -march=$(subst fdv,,$(riscv-march-y))...so I think this will not work if !CONFIG_FPU &&
RISCV_ISA_V. IIRC, vector uses some floating point opcodes, but does it (or Linux's implementation) actually depend on having floating point support in the kernel?
Yes.
"The V extension requires the scalar processor implements the F and D extensions", RISC-V "V" Vector Extension, Section 18.3. V: Vector Extension for Application Processors.
Quoted 10 lines
If not, this cannot be done in a oneliner. Otherwise,
CONFIG_RISCV_ISA_Vshould explicitly depend onCONFIG_FPU.Quoted 7 lines
arch/riscv/Makefile +0
-0KBUILD_AFLAGS += -march=$(riscv-march-y) KBUILD_CFLAGS += -mno-save-restoreSignature · 1 line
2.17.1
Re: [PATCH -next v14 19/19] riscv: Enable Vector code to be built
Quoted 81 lines · Darius Rad
Quoted 72 lines · Conor Dooley
Quoted 11 lines · Andy Chiu
From: Guo Ren <[email protected]>
This patch adds a config which enables vector feature from the kernel space.
Signed-off-by Guo Ren <[email protected]>Co-developed-by Greentime Hu <[email protected]>Signed-off-by Greentime Hu <[email protected]>Suggested-by Vineet Gupta <[email protected]>Suggested-by Atish Patra <[email protected]>Signed-off-by Andy Chiu <[email protected]>At this point, you've basically re-written this patch and should be listed as a co-author at the very least!
Quoted 14 lines
--- arch/riscv/Kconfig | 18 ++++++++++++++++++ arch/riscv/Makefile | 3 ++- 2 files changed, 20 insertions(+), 1 deletion(-)arch/riscv/Kconfig +1
-0@@ -418,6 +418,24 @@ config RISCV_ISA_SVPBMT If you don't know what to do here, say Y. +config TOOLCHAIN_HAS_Varch/riscv/Kconfig config RISCV_ISA_SVPBMT · line 431
Quoted 10 lines
arch/riscv/Kconfig +10
-0+ bool + default y + depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv) + depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv) + depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800 + +config RISCV_ISA_V + bool "VECTOR extension support" + depends on TOOLCHAIN_HAS_V + select DYNAMIC_SIGFRAMESo, nothing here makes V depend on
CONFIG_FPU...Quoted 15 lines
arch/riscv/Kconfig +7
-0+ default y + help + Say N here if you want to disable all vector related procedure + in the kernel. + + If you don't know what to do here, say Y. + config TOOLCHAIN_HAS_ZBB bool default yarch/riscv/Makefile +0
-0arch/riscv/Makefile riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima · line 57
Quoted 2 lines
arch/riscv/Makefile +0
-0@@ -56,6 +56,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd...but march only contains fd if
CONFIG_FPUis enabled...Quoted 9 lines
arch/riscv/Makefile +1
-0riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c +riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v # Newer binutils versions default to ISA spec version 20191213 which moves some # instructions from the I extension to the Zicsr and Zifencei extensions.@@ -65,7 +66,7 @@ riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei # Check if the toolchain supports Zihintpause extension riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpauseQuoted 7 lines
arch/riscv/Makefile riscv-march-$(toolchain-need-zicsr-zifencei) := $(riscv-march-y)_zicsr_zifencei · line 69
Quoted 2 lines
arch/riscv/Makefile +1
-1-KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y)) +KBUILD_CFLAGS += -march=$(subst fdv,,$(riscv-march-y))...so I think this will not work if !CONFIG_FPU &&
RISCV_ISA_V. IIRC, vector uses some floating point opcodes, but does it (or Linux's implementation) actually depend on having floating point support in the kernel?
Quoted 5 lines
Yes.
"The V extension requires the scalar processor implements the F and D extensions", RISC-V "V" Vector Extension, Section 18.3. V: Vector Extension for Application Processors.
Thanks, I should probably just have gone and read the spec!
Quoted 2 lines
Quoted 2 lines
If not, this cannot be done in a oneliner. Otherwise,
CONFIG_RISCV_ISA_Vshould explicitly depend onCONFIG_FPU.
Since it does depend on F & D, the Kconfig symbol should explicitly depend on CONFIG_FPU.
The oneliner like that still doesn't work, as V is added to march after C, leading (for clang-15 allmodconfig) to: -march=rv64imafdcv_zihintpause Doing it as a oneline also breaks the case where CONFIG_FPU && !RISCV_ISA_VECTOR, which ends up with: -march=rv64imafdc_zihintpause.
Cheers,
Conor.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/kvm-riscv/attachments/20230227/0c480f84/attachment-0001.sig>