From: Charlie Jenkins <charlie@rivosinc.com>
To: "Paul Walmsley" <paul.walmsley@sifive.com>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Conor Dooley" <conor.dooley@microchip.com>,
"Song Liu" <song@kernel.org>, "Xi Wang" <xi.wang@gmail.com>,
"Björn Töpel" <bjorn@rivosinc.com>,
"Clément Léger" <cleger@rivosinc.com>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Charlie Jenkins <charlie@rivosinc.com>
Subject: [PATCH 7/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBC Kconfig option
Date: Mon, 06 May 2024 18:40:48 -0700 [thread overview]
Message-ID: <20240506-compile_kernel_with_extensions-v1-7-5c25c134c097@rivosinc.com> (raw)
In-Reply-To: <20240506-compile_kernel_with_extensions-v1-0-5c25c134c097@rivosinc.com>
Zbc can optimize kernel instruction sequences. Add a config option
PLATFORM_SUPPORTS_RISCV_ISA_ZBC that allows arbitrary Zbc instruction
sequences to be emitted by the compiler.
Signed-off-by: Charlie Jenkins <charlie@rivosinc.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 e7f28dc44137..b7399f236bba 100644
--- a/arch/riscv/Kconfig.isa
+++ b/arch/riscv/Kconfig.isa
@@ -289,3 +289,54 @@ config PLATFORM_SUPPORTS_RISCV_ISA_ZBB
systems that do not support the Zbb extension.
endchoice
+
+config TOOLCHAIN_HAS_ZBC
+ bool
+ default y
+ depends on !64BIT || $(cc-option,-mabi=lp64 -march=rv64ima_zbc)
+ depends on !32BIT || $(cc-option,-mabi=ilp32 -march=rv32ima_zbc)
+ depends on LLD_VERSION >= 150000 || LD_VERSION >= 23900
+ depends on AS_HAS_OPTION_ARCH
+
+config RISCV_ISA_ZBC
+ bool
+
+choice
+ prompt "Zbc extension for bit manipulation instructions support"
+ default PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBC
+ help
+ This selects the level of support for Zbc instructions to be
+ built into the Linux Kernel. This does not impact whether Zbc
+ instructions are allowed to be emitted by user-space code.
+
+ The Zbc extension provides instructions to accelerate carry-less
+ multiplication.
+
+config PROHIBIT_RISCV_ISA_ZBC
+ bool "Prohibit Zbc instruction sequences"
+ depends on NONPORTABLE
+ help
+ Regardless of if the platform supports Zbc instructions,
+ prohibit the kernel from emitting Zbc instructions.
+
+config PLATFORM_MAY_SUPPORT_RISCV_ISA_ZBC
+ bool "Allow Zbc instruction sequences if supported"
+ depends on TOOLCHAIN_HAS_ZBC
+ depends on RISCV_ALTERNATIVE
+ select RISCV_ISA_ZBC
+ help
+ Add support for enabling optimisations in the kernel when the
+ Zbc extension is detected at boot.
+
+config PLATFORM_SUPPORTS_RISCV_ISA_ZBC
+ bool "Emit Zbc instructions when building Linux"
+ depends on TOOLCHAIN_HAS_ZBC
+ depends on NONPORTABLE
+ select RISCV_ISA_ZBC
+ help
+ Adds "zbc" to the ISA subsets that the toolchain is allowed to emit
+ when building Linux, which results in Zbc instructions in the
+ Linux binary. This option produces a kernel that will not run on
+ systems that do not support the Zbc extension.
+
+endchoice
diff --git a/arch/riscv/Makefile b/arch/riscv/Makefile
index 0ab4cc5dfffb..30be0fec976a 100644
--- a/arch/riscv/Makefile
+++ b/arch/riscv/Makefile
@@ -69,6 +69,7 @@ riscv-march-$(CONFIG_PLATFORM_SUPPORTS_RISCV_ISA_C) := $(riscv-march-y)c
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
ifdef CONFIG_TOOLCHAIN_NEEDS_OLD_ISA_SPEC
KBUILD_CFLAGS += -Wa,-misa-spec=2.2
--
2.44.0
next prev parent reply other threads:[~2024-05-07 1:42 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-07 1:40 [PATCH 0/8] riscv: Support compiling the kernel with extensions Charlie Jenkins
2024-05-07 1:40 ` [PATCH 1/8] riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_C Kconfig option Charlie Jenkins
2024-05-07 1:40 ` [PATCH 2/8] riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_V " Charlie Jenkins
2024-05-07 1:40 ` [PATCH 3/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_SVNAPOT " Charlie Jenkins
2024-05-07 1:40 ` [PATCH 4/8] riscv: Add PLATFORM_MAY_SUPPORT_RISCV_ISA_SVPBMT " Charlie Jenkins
2024-05-07 5:40 ` Jessica Clarke
2024-05-07 20:39 ` Charlie Jenkins
2024-05-08 1:24 ` Charlie Jenkins
2024-05-07 1:40 ` [PATCH 5/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBB " Charlie Jenkins
2024-05-07 1:40 ` [PATCH 6/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBA " Charlie Jenkins
2024-05-07 1:40 ` Charlie Jenkins [this message]
2024-05-07 1:40 ` [PATCH 8/8] riscv: Add PLATFORM_SUPPORTS_RISCV_ISA_ZBS " Charlie Jenkins
2024-05-07 7:25 ` [PATCH 0/8] riscv: Support compiling the kernel with extensions Conor Dooley
2024-05-07 20:04 ` Charlie Jenkins
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240506-compile_kernel_with_extensions-v1-7-5c25c134c097@rivosinc.com \
--to=charlie@rivosinc.com \
--cc=aou@eecs.berkeley.edu \
--cc=bjorn@rivosinc.com \
--cc=cleger@rivosinc.com \
--cc=conor.dooley@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=song@kernel.org \
--cc=xi.wang@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®