[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20240506-compile_kernel_with_extensions-v1-8-5c25c134c097@rivosinc.com>
Date: Mon, 06 May 2024 18:40:49 -0700
From: Charlie Jenkins <charlie@...osinc.com>
To: Paul Walmsley <paul.walmsley@...ive.com>,
Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
Conor Dooley <conor.dooley@...rochip.com>, Song Liu <song@...nel.org>,
Xi Wang <xi.wang@...il.com>,
Björn Töpel <bjorn@...osinc.com>,
Clément Léger <cleger@...osinc.com>
Cc: linux-riscv@...ts.infradead.org, linux-kernel@...r.kernel.org,
Charlie Jenkins <charlie@...osinc.com>
Subject: [PATCH 8/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS Kconfig
option
Zbs can optimize kernel instruction sequences. Add a config option
PLATFORM_SUPPORTS_RISCV_ISA_ZBS that allows arbitrary Zbs instruction
sequences to be emitted by the compiler.
Signed-off-by: Charlie Jenkins <charlie@...osinc.com>
---
arch/riscv/Kconfig.isa | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++
arch/riscv/Makefile | 1 +
2 files changed, 52 insertions(+)
diff --git a/arch/riscv/Kconfig.isa b/arch/riscv/Kconfig.isa
index b7399f236bba..60ae1bf71c70 100644
--- a/arch/riscv/Kconfig.isa
+++ b/arch/riscv/Kconfig.isa
@@ -340,3 +340,54 @@ config PLATFORM_SUPPORTS_RISCV_ISA_ZBC
systems that do not support the Zbc extension.
endchoice
+
+config TOOLCHAIN_HAS_ZBS
+ bool
+ default y
+ depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbs)
+ depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbs)
+ depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
+ depends on AS_HAS_OPTION_ARCH
+
+config RISCV_ISA_ZBS
+ bool
+
+choice
+ prompt "Zbs extension for bit manipulation instructions support"
+ default PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBS
+ help
+ This selects the level of support for Zbs instructions to be
+ built into the Linux Kernel. This does not impact whether Zbs
+ instructions are allowed to be emitted by user-space code.
+
+ The Zbs extension provides instructions to accelerate carry-less
+ multiplication.
+
+config PROHIBIT_RISCV_ISA_ZBS
+ bool "Prohibit Zbs instruction sequences"
+ depends on NONPORTABLE
+ help
+ Regardless of if the platform supports Zbs instructions,
+ prohibit the kernel from emitting Zbs instructions.
+
+config PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBS
+ bool "Allow Zbs instruction sequences if supported"
+ depends on TOOLCHAIN_HAS_ZBS
+ depends on RISCV_ALTERNATIVE
+ select RISCV_ISA_ZBS
+ help
+ Add support for enabling optimisations in the kernel when the
+ Zbs extension is detected at boot.
+
+config PLATFORM_SUPPORTS_RISCV_ISA_ZBS
+ bool "Emit Zbs instructions when building Linux"
+ depends on TOOLCHAIN_HAS_ZBS
+ depends on NONPORTABLE
+ select RISCV_ISA_ZBS
+ help
+ Adds "zbs" to the ISA subsets that the toolchain is allowed to emit
+ when building Linux, which results in Zbs instructions in the
+ Linux binary. This option produces a kernel that will not run on
+ systems that do not support the Zbs extension.
+
+endchoice
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 30be0fec976a..7519b68c3bd5 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -70,6 +70,7 @@ riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_V) := $(riscv-march-y)v
riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBA) := $(riscv-march-y)_zba
riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBB) := $(riscv-march-y)_zbb
riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBC) := $(riscv-march-y)_zbc
+riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_ZBS) := $(riscv-march-y)_zbs
ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC
KBUILD_CFLAGS += -Wa,-misa-spec=2.2
--
2.44.0
Powered by blists - more mailing lists