From: Charlie Jenkins <thecharlesjenkins@gmail.com>
To: Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Conor Dooley <conor.dooley@microchip.com>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Charlie Jenkins <thecharlesjenkins@gmail.com>
Subject: [PATCH] riscv: Add "g" as an instruction alias
Date: Fri, 26 Jun 2026 23:24:46 -0700 [thread overview]
Message-ID: <20260626-g_ext-v1-1-a9aa7ab9d109@gmail.com> (raw)
"G" is an official alias for "IMAFDZicsr_Zifencei" [1]. Many common
tools like LLVM, GCC, OpenSBI, QEMU support this alias so make Linux
follow the status quo and allow users to pass it in the isa string. In
the ISA string, "G" is expected to written lowercase as "g" like the
other extensions. Since "g" is a simple alias, follow what OpenSBI does
and expose "imafd_zicsr_zifencei" instead of "g".
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
This can be tested with a device tree that passes in "g" to the isa
string like:
riscv,isa-extensions = "gc";
or
riscv,isa = "rv64gc";
Example test case using qemu:
1. Run QEMU with the additional arg "-machine dumpdtb=qemu.dtb"
2. Decompile the dts "dtc -O dts -I dtb qemu.dtb -o qemu.dts"
3. Set riscv,isa-extensions to "gc"
4. Compile the dtb "dtc -O dtb -I dts qemu.dts -o qemu.dtb"
5. Boot qemu with "-dtc qemu.dtb"
6. Look at /proc/cpuinfo
---
arch/riscv/kernel/cpu.c | 7 ++++---
arch/riscv/kernel/cpufeature.c | 11 +++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 3dbc8cc557dd..0a2df97a1fd6 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -81,9 +81,10 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo
if (!of_property_present(node, "riscv,isa-extensions"))
return -ENODEV;
- if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
- of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
- of_property_match_string(node, "riscv,isa-extensions", "a") < 0) {
+ if (of_property_match_string(node, "riscv,isa-extensions", "g") < 0 &&
+ (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
+ of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
+ of_property_match_string(node, "riscv,isa-extensions", "a") < 0)) {
pr_warn("CPU with hartid=%lu does not support ima", *hart);
return -ENODEV;
}
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index f46aa5602d74..f78cbf5ade1e 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -322,6 +322,16 @@ static const unsigned int riscv_a_exts[] = {
RISCV_ISA_EXT_ZALRSC,
};
+static const unsigned int riscv_g_bundled_exts[] = {
+ RISCV_ISA_EXT_i,
+ RISCV_ISA_EXT_m,
+ RISCV_ISA_EXT_a,
+ RISCV_ISA_EXT_f,
+ RISCV_ISA_EXT_d,
+ RISCV_ISA_EXT_ZICSR,
+ RISCV_ISA_EXT_ZIFENCEI
+};
+
#define RISCV_ISA_EXT_ZKN \
RISCV_ISA_EXT_ZBKB, \
RISCV_ISA_EXT_ZBKC, \
@@ -495,6 +505,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_SUPERSET(a, RISCV_ISA_EXT_a, riscv_a_exts),
__RISCV_ISA_EXT_DATA_VALIDATE(f, RISCV_ISA_EXT_f, riscv_ext_f_validate),
__RISCV_ISA_EXT_DATA_VALIDATE(d, RISCV_ISA_EXT_d, riscv_ext_d_validate),
+ __RISCV_ISA_EXT_BUNDLE(g, riscv_g_bundled_exts),
__RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q),
__RISCV_ISA_EXT_SUPERSET(c, RISCV_ISA_EXT_c, riscv_c_exts),
__RISCV_ISA_EXT_SUPERSET_VALIDATE(v, RISCV_ISA_EXT_v, riscv_v_exts, riscv_ext_vector_float_validate),
---
base-commit: 5a66900afbd6b2a063eebad35294038a654de2b0
change-id: 20260626-g_ext-0ca7d6223ff8
Best regards,
--
- Charlie
WARNING: multiple messages have this Message-ID (diff)
From: Charlie Jenkins <thecharlesjenkins@gmail.com>
To: Paul Walmsley <pjw@kernel.org>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alexandre Ghiti <alex@ghiti.fr>,
Conor Dooley <conor.dooley@microchip.com>
Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
Charlie Jenkins <thecharlesjenkins@gmail.com>
Subject: [PATCH] riscv: Add "g" as an instruction alias
Date: Fri, 26 Jun 2026 23:24:46 -0700 [thread overview]
Message-ID: <20260626-g_ext-v1-1-a9aa7ab9d109@gmail.com> (raw)
"G" is an official alias for "IMAFDZicsr_Zifencei" [1]. Many common
tools like LLVM, GCC, OpenSBI, QEMU support this alias so make Linux
follow the status quo and allow users to pass it in the isa string. In
the ISA string, "G" is expected to written lowercase as "g" like the
other extensions. Since "g" is a simple alias, follow what OpenSBI does
and expose "imafd_zicsr_zifencei" instead of "g".
Signed-off-by: Charlie Jenkins <thecharlesjenkins@gmail.com>
---
This can be tested with a device tree that passes in "g" to the isa
string like:
riscv,isa-extensions = "gc";
or
riscv,isa = "rv64gc";
Example test case using qemu:
1. Run QEMU with the additional arg "-machine dumpdtb=qemu.dtb"
2. Decompile the dts "dtc -O dts -I dtb qemu.dtb -o qemu.dts"
3. Set riscv,isa-extensions to "gc"
4. Compile the dtb "dtc -O dtb -I dts qemu.dts -o qemu.dtb"
5. Boot qemu with "-dtc qemu.dtb"
6. Look at /proc/cpuinfo
---
arch/riscv/kernel/cpu.c | 7 ++++---
arch/riscv/kernel/cpufeature.c | 11 +++++++++++
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 3dbc8cc557dd..0a2df97a1fd6 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c
@@ -81,9 +81,10 @@ int __init riscv_early_of_processor_hartid(struct device_node *node, unsigned lo
if (!of_property_present(node, "riscv,isa-extensions"))
return -ENODEV;
- if (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
- of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
- of_property_match_string(node, "riscv,isa-extensions", "a") < 0) {
+ if (of_property_match_string(node, "riscv,isa-extensions", "g") < 0 &&
+ (of_property_match_string(node, "riscv,isa-extensions", "i") < 0 ||
+ of_property_match_string(node, "riscv,isa-extensions", "m") < 0 ||
+ of_property_match_string(node, "riscv,isa-extensions", "a") < 0)) {
pr_warn("CPU with hartid=%lu does not support ima", *hart);
return -ENODEV;
}
diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c
index f46aa5602d74..f78cbf5ade1e 100644
--- a/arch/riscv/kernel/cpufeature.c
+++ b/arch/riscv/kernel/cpufeature.c
@@ -322,6 +322,16 @@ static const unsigned int riscv_a_exts[] = {
RISCV_ISA_EXT_ZALRSC,
};
+static const unsigned int riscv_g_bundled_exts[] = {
+ RISCV_ISA_EXT_i,
+ RISCV_ISA_EXT_m,
+ RISCV_ISA_EXT_a,
+ RISCV_ISA_EXT_f,
+ RISCV_ISA_EXT_d,
+ RISCV_ISA_EXT_ZICSR,
+ RISCV_ISA_EXT_ZIFENCEI
+};
+
#define RISCV_ISA_EXT_ZKN \
RISCV_ISA_EXT_ZBKB, \
RISCV_ISA_EXT_ZBKC, \
@@ -495,6 +505,7 @@ const struct riscv_isa_ext_data riscv_isa_ext[] = {
__RISCV_ISA_EXT_SUPERSET(a, RISCV_ISA_EXT_a, riscv_a_exts),
__RISCV_ISA_EXT_DATA_VALIDATE(f, RISCV_ISA_EXT_f, riscv_ext_f_validate),
__RISCV_ISA_EXT_DATA_VALIDATE(d, RISCV_ISA_EXT_d, riscv_ext_d_validate),
+ __RISCV_ISA_EXT_BUNDLE(g, riscv_g_bundled_exts),
__RISCV_ISA_EXT_DATA(q, RISCV_ISA_EXT_q),
__RISCV_ISA_EXT_SUPERSET(c, RISCV_ISA_EXT_c, riscv_c_exts),
__RISCV_ISA_EXT_SUPERSET_VALIDATE(v, RISCV_ISA_EXT_v, riscv_v_exts, riscv_ext_vector_float_validate),
---
base-commit: 5a66900afbd6b2a063eebad35294038a654de2b0
change-id: 20260626-g_ext-0ca7d6223ff8
Best regards,
--
- Charlie
_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv
next reply other threads:[~2026-06-27 6:25 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-27 6:24 Charlie Jenkins [this message]
2026-06-27 6:24 ` [PATCH] riscv: Add "g" as an instruction alias Charlie Jenkins
2026-06-27 13:58 ` Conor Dooley
2026-06-27 13:58 ` Conor Dooley
2026-06-30 6:07 ` Charlie Jenkins
2026-06-30 6:07 ` 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=20260626-g_ext-v1-1-a9aa7ab9d109@gmail.com \
--to=thecharlesjenkins@gmail.com \
--cc=alex@ghiti.fr \
--cc=conor.dooley@microchip.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.