summaryrefslogtreecommitdiff
path: root/arch/riscv/include
diff options
context:
space:
mode:
authorGreentime Hu <greentime.hu@sifive.com>2023-06-05 14:07:05 +0300
committerPalmer Dabbelt <palmer@rivosinc.com>2023-06-08 17:16:41 +0300
commit7017858eb2d7ed7a295be02c71124049a6409295 (patch)
treee403b59432c0d41755b46320fc570dfe4ac67e9d /arch/riscv/include
parent0a3381a01dcc3d0537732794c007f32e4dfd1efc (diff)
downloadlinux-7017858eb2d7ed7a295be02c71124049a6409295.tar.xz
riscv: Introduce riscv_v_vsize to record size of Vector context
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. If a core detects VLENB that is different from the boot core, then it warns and turns off V support for user space. Co-developed-by: Guo Ren <guoren@linux.alibaba.com> Signed-off-by: Guo Ren <guoren@linux.alibaba.com> Co-developed-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Vincent Chen <vincent.chen@sifive.com> Signed-off-by: Greentime Hu <greentime.hu@sifive.com> Signed-off-by: Andy Chiu <andy.chiu@sifive.com> Reviewed-by: Conor Dooley <conor.dooley@microchip.com> Reviewed-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Tested-by: Heiko Stuebner <heiko.stuebner@vrull.eu> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com> Link: https://lore.kernel.org/r/20230605110724.21391-9-andy.chiu@sifive.com Signed-off-by: Palmer Dabbelt <palmer@rivosinc.com>
Diffstat (limited to 'arch/riscv/include')
-rw-r--r--arch/riscv/include/asm/vector.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/arch/riscv/include/asm/vector.h b/arch/riscv/include/asm/vector.h
index 51bb37232943..df3b5caecc87 100644
--- a/arch/riscv/include/asm/vector.h
+++ b/arch/riscv/include/asm/vector.h
@@ -7,12 +7,16 @@
#define __ASM_RISCV_VECTOR_H
#include <linux/types.h>
+#include <uapi/asm-generic/errno.h>
#ifdef CONFIG_RISCV_ISA_V
#include <asm/hwcap.h>
#include <asm/csr.h>
+extern unsigned long riscv_v_vsize;
+int riscv_v_setup_vsize(void);
+
static __always_inline bool has_vector(void)
{
return riscv_has_extension_unlikely(RISCV_ISA_EXT_v);
@@ -30,7 +34,11 @@ static __always_inline void riscv_v_disable(void)
#else /* ! CONFIG_RISCV_ISA_V */
+struct pt_regs;
+
+static inline int riscv_v_setup_vsize(void) { return -EOPNOTSUPP; }
static __always_inline bool has_vector(void) { return false; }
+#define riscv_v_vsize (0)
#endif /* CONFIG_RISCV_ISA_V */