Skip to content

Commit fa8e7cc

Browse files
guoren83palmer-dabbelt
authored andcommitted
riscv: Enable Vector code to be built
This patch adds configs for building Vector code. First it detects the reqired toolchain support for building the code. Then it provides an option setting whether Vector is implicitly enabled to userspace. Signed-off-by: Guo Ren <[email protected]> Co-developed-by: Greentime Hu <[email protected]> Signed-off-by: Greentime Hu <[email protected]> Co-developed-by: Andy Chiu <[email protected]> Signed-off-by: Andy Chiu <[email protected]> Reviewed-by: Conor Dooley <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Palmer Dabbelt <[email protected]>
1 parent e4bb020 commit fa8e7cc

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

arch/riscv/Kconfig

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,37 @@ config RISCV_ISA_SVPBMT
466466

467467
If you don't know what to do here, say Y.
468468

469+
config TOOLCHAIN_HAS_V
470+
bool
471+
default y
472+
depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64iv)
473+
depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32iv)
474+
depends on LLD_VERSION >= 140000 || LD_VERSION >= 23800
475+
depends on AS_HAS_OPTION_ARCH
476+
477+
config RISCV_ISA_V
478+
bool "VECTOR extension support"
479+
depends on TOOLCHAIN_HAS_V
480+
depends on FPU
481+
select DYNAMIC_SIGFRAME
482+
default y
483+
help
484+
Say N here if you want to disable all vector related procedure
485+
in the kernel.
486+
487+
If you don't know what to do here, say Y.
488+
489+
config RISCV_ISA_V_DEFAULT_ENABLE
490+
bool "Enable userspace Vector by default"
491+
depends on RISCV_ISA_V
492+
default y
493+
help
494+
Say Y here if you want to enable Vector in userspace by default.
495+
Otherwise, userspace has to make explicit prctl() call to enable
496+
Vector, or enable it via the sysctl interface.
497+
498+
If you don't know what to do here, say Y.
499+
469500
config TOOLCHAIN_HAS_ZBB
470501
bool
471502
default y

arch/riscv/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ riscv-march-$(CONFIG_ARCH_RV32I) := rv32ima
6060
riscv-march-$(CONFIG_ARCH_RV64I) := rv64ima
6161
riscv-march-$(CONFIG_FPU) := $(riscv-march-y)fd
6262
riscv-march-$(CONFIG_RISCV_ISA_C) := $(riscv-march-y)c
63+
riscv-march-$(CONFIG_RISCV_ISA_V) := $(riscv-march-y)v
6364

6465
ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC
6566
KBUILD_CFLAGS += -Wa,-misa-spec=2.2
@@ -71,7 +72,10 @@ endif
7172
# Check if the toolchain supports Zihintpause extension
7273
riscv-march-$(CONFIG_TOOLCHAIN_HAS_ZIHINTPAUSE) := $(riscv-march-y)_zihintpause
7374

74-
KBUILD_CFLAGS += -march=$(subst fd,,$(riscv-march-y))
75+
# Remove F,D,V from isa string for all. Keep extensions between "fd" and "v" by
76+
# matching non-v and non-multi-letter extensions out with the filter ([^v_]*)
77+
KBUILD_CFLAGS += -march=$(shell echo $(riscv-march-y) | sed -E 's/(rv32ima|rv64ima)fd([^v_]*)v?/\1\2/')
78+
7579
KBUILD_AFLAGS += -march=$(riscv-march-y)
7680

7781
KBUILD_CFLAGS += -mno-save-restore

0 commit comments

Comments
 (0)