[PATCH v2 2/2] riscv: hwprobe: Add LeapRise vendor extension framework support

From: lv.yating

Date: Fri Nov 20 2026 - 02:05:00 EST


From: Lv Yating <lv.yating@xxxxxxxxxx>

Add RISCV_HWPROBE_KEY_VENDOR_EXT_LEAPRISE_0 (key 17) and the
supporting vendor extension framework entries for Beijing LeapRise
Technology Co., Ltd.

The key is recognized by riscv_hwprobe() and reports an empty
bitmask for now: no LeapRise vendor extensions are defined yet.
Recognizing the key allows userspace to distinguish a kernel that
supports LeapRise vendor extension probing (empty bitmask) from an
older kernel that does not know the key at all (key set to -1), so
LeapRise userspace libraries can be prepared ahead of the first
hardware shipping vendor extensions.

Follow-up patches will register extensions as they are defined.

Signed-off-by: Lv Yating <lv.yating@xxxxxxxxxx>
---
Documentation/arch/riscv/hwprobe.rst | 4 ++++
arch/riscv/Kconfig.vendor | 14 +++++++++++++
arch/riscv/include/asm/hwprobe.h | 3 ++-
.../include/asm/vendor_extensions/leaprise.h | 17 ++++++++++++++++
.../asm/vendor_extensions/leaprise_hwprobe.h | 20 +++++++++++++++++++
arch/riscv/include/uapi/asm/hwprobe.h | 1 +
arch/riscv/include/uapi/asm/vendor/leaprise.h | 3 +++
arch/riscv/kernel/sys_hwprobe.c | 4 ++++
arch/riscv/kernel/vendor_extensions.c | 10 ++++++++++
arch/riscv/kernel/vendor_extensions/Makefile | 2 ++
.../riscv/kernel/vendor_extensions/leaprise.c | 12 +++++++++++
.../vendor_extensions/leaprise_hwprobe.c | 19 ++++++++++++++++++
12 files changed, 108 insertions(+), 1 deletion(-)
create mode 100644 arch/riscv/include/asm/vendor_extensions/leaprise.h
create mode 100644 arch/riscv/include/asm/vendor_extensions/leaprise_hwprobe.h
create mode 100644 arch/riscv/include/uapi/asm/vendor/leaprise.h
create mode 100644 arch/riscv/kernel/vendor_extensions/leaprise.c
create mode 100644 arch/riscv/kernel/vendor_extensions/leaprise_hwprobe.c

diff --git a/Documentation/arch/riscv/hwprobe.rst b/Documentation/arch/riscv/hwprobe.rst
index 8454a6ae6fd1..336a2c5b05d9 100644
--- a/Documentation/arch/riscv/hwprobe.rst
+++ b/Documentation/arch/riscv/hwprobe.rst
@@ -431,3 +431,7 @@ The following keys are defined:
* :c:macro:`RISCV_HWPROBE_EXT_ZIC64B`: The Zic64b extension is supported,
as defined in the RISC-V Profiles specification starting from commit
b1d80660 ("Updated to ratified state.")
+
+* :c:macro:`RISCV_HWPROBE_KEY_VENDOR_EXT_LEAPRISE_0`: A bitmask containing the
+ leaprise vendor extensions that are compatible with the
+ :c:macro:`RISCV_HWPROBE_BASE_BEHAVIOR_IMA`: base system behavior.
diff --git a/arch/riscv/Kconfig.vendor b/arch/riscv/Kconfig.vendor
index 3c1f92e406c3..03af8bc0f903 100644
--- a/arch/riscv/Kconfig.vendor
+++ b/arch/riscv/Kconfig.vendor
@@ -16,6 +16,20 @@ config RISCV_ISA_VENDOR_EXT_ANDES
If you don't know what to do here, say Y.
endmenu

+menu "LeapRise"
+config RISCV_ISA_VENDOR_EXT_LEAPRISE
+ bool "LeapRise vendor extension support"
+ select RISCV_ISA_VENDOR_EXT
+ default y
+ help
+ Say N here to disable detection of and support for all LeapRise vendor
+ extensions. Without this option enabled, LeapRise vendor extensions
+ will not be detected at boot and their presence not reported to
+ userspace.
+
+ If you don't know what to do here, say Y.
+endmenu
+
menu "MIPS"
config RISCV_ISA_VENDOR_EXT_MIPS
bool "MIPS vendor extension support"
diff --git a/arch/riscv/include/asm/hwprobe.h b/arch/riscv/include/asm/hwprobe.h
index 9b04377c0f98..e37e5a8afbb4 100644
--- a/arch/riscv/include/asm/hwprobe.h
+++ b/arch/riscv/include/asm/hwprobe.h
@@ -8,7 +8,7 @@

#include <uapi/asm/hwprobe.h>

-#define RISCV_HWPROBE_MAX_KEY 16
+#define RISCV_HWPROBE_MAX_KEY 17

static inline bool riscv_hwprobe_key_is_valid(__s64 key)
{
@@ -25,6 +25,7 @@ static inline bool hwprobe_key_is_bitmask(__s64 key)
case RISCV_HWPROBE_KEY_VENDOR_EXT_THEAD_0:
case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
case RISCV_HWPROBE_KEY_VENDOR_EXT_SIFIVE_0:
+ case RISCV_HWPROBE_KEY_VENDOR_EXT_LEAPRISE_0:
return true;
}

diff --git a/arch/riscv/include/asm/vendor_extensions/leaprise.h b/arch/riscv/include/asm/vendor_extensions/leaprise.h
new file mode 100644
index 000000000000..0d4ab8f03983
--- /dev/null
+++ b/arch/riscv/include/asm/vendor_extensions/leaprise.h
@@ -0,0 +1,17 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_H
+#define _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_H
+
+#include <asm/vendor_extensions.h>
+#include <linux/types.h>
+
+/*
+ * Extension keys should be strictly less than max.
+ * It is safe to increment this when necessary.
+ */
+#define RISCV_ISA_VENDOR_EXT_MAX_LEAPRISE 32
+
+extern struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_leaprise;
+
+#endif
diff --git a/arch/riscv/include/asm/vendor_extensions/leaprise_hwprobe.h b/arch/riscv/include/asm/vendor_extensions/leaprise_hwprobe.h
new file mode 100644
index 000000000000..980402df0095
--- /dev/null
+++ b/arch/riscv/include/asm/vendor_extensions/leaprise_hwprobe.h
@@ -0,0 +1,20 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+
+#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_HWPROBE_H
+#define _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_HWPROBE_H
+
+#include <linux/cpumask.h>
+
+#include <uapi/asm/hwprobe.h>
+
+#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_LEAPRISE
+void hwprobe_isa_vendor_ext_leaprise_0(struct riscv_hwprobe *pair, const struct cpumask *cpus);
+#else
+static inline void hwprobe_isa_vendor_ext_leaprise_0(struct riscv_hwprobe *pair,
+ const struct cpumask *cpus)
+{
+ pair->value = 0;
+}
+#endif
+
+#endif
diff --git a/arch/riscv/include/uapi/asm/hwprobe.h b/arch/riscv/include/uapi/asm/hwprobe.h
index 9a121ee3b436..6907ca4648ef 100644
--- a/arch/riscv/include/uapi/asm/hwprobe.h
+++ b/arch/riscv/include/uapi/asm/hwprobe.h
@@ -124,6 +124,7 @@ struct riscv_hwprobe {
#define RISCV_HWPROBE_EXT_ZA64RS _BITULL(5)
#define RISCV_HWPROBE_EXT_B _BITULL(6)
#define RISCV_HWPROBE_EXT_ZIC64B _BITULL(7)
+#define RISCV_HWPROBE_KEY_VENDOR_EXT_LEAPRISE_0 17

/* Increase RISCV_HWPROBE_MAX_KEY when adding items. */

diff --git a/arch/riscv/include/uapi/asm/vendor/leaprise.h b/arch/riscv/include/uapi/asm/vendor/leaprise.h
new file mode 100644
index 000000000000..9ee13f1ca559
--- /dev/null
+++ b/arch/riscv/include/uapi/asm/vendor/leaprise.h
@@ -0,0 +1,3 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+
+/* LeapRise vendor extensions: none defined yet */
diff --git a/arch/riscv/kernel/sys_hwprobe.c b/arch/riscv/kernel/sys_hwprobe.c
index cd7cf272e6e1..e60facabdd86 100644
--- a/arch/riscv/kernel/sys_hwprobe.c
+++ b/arch/riscv/kernel/sys_hwprobe.c
@@ -15,6 +15,7 @@
#include <asm/uaccess.h>
#include <asm/unistd.h>
#include <asm/vector.h>
+#include <asm/vendor_extensions/leaprise_hwprobe.h>
#include <asm/vendor_extensions/mips_hwprobe.h>
#include <asm/vendor_extensions/sifive_hwprobe.h>
#include <asm/vendor_extensions/thead_hwprobe.h>
@@ -364,6 +365,9 @@ static void hwprobe_one_pair(struct riscv_hwprobe *pair,
case RISCV_HWPROBE_KEY_VENDOR_EXT_MIPS_0:
hwprobe_isa_vendor_ext_mips_0(pair, cpus);
break;
+ case RISCV_HWPROBE_KEY_VENDOR_EXT_LEAPRISE_0:
+ hwprobe_isa_vendor_ext_leaprise_0(pair, cpus);
+ break;

/*
* For forward compatibility, unknown keys don't fail the whole
diff --git a/arch/riscv/kernel/vendor_extensions.c b/arch/riscv/kernel/vendor_extensions.c
index bb4a75923685..e7372194096e 100644
--- a/arch/riscv/kernel/vendor_extensions.c
+++ b/arch/riscv/kernel/vendor_extensions.c
@@ -6,6 +6,7 @@
#include <asm/vendorid_list.h>
#include <asm/vendor_extensions.h>
#include <asm/vendor_extensions/andes.h>
+#include <asm/vendor_extensions/leaprise.h>
#include <asm/vendor_extensions/mips.h>
#include <asm/vendor_extensions/sifive.h>
#include <asm/vendor_extensions/thead.h>
@@ -17,6 +18,9 @@ struct riscv_isa_vendor_ext_data_list *riscv_isa_vendor_ext_list[] = {
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_ANDES
&riscv_isa_vendor_ext_list_andes,
#endif
+#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_LEAPRISE
+ &riscv_isa_vendor_ext_list_leaprise,
+#endif
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
&riscv_isa_vendor_ext_list_mips,
#endif
@@ -53,6 +57,12 @@ bool __riscv_isa_vendor_extension_available(int cpu, unsigned long vendor, unsig
cpu_bmap = riscv_isa_vendor_ext_list_andes.per_hart_isa_bitmap;
break;
#endif
+ #ifdef CONFIG_RISCV_ISA_VENDOR_EXT_LEAPRISE
+ case LEAPRISE_VENDOR_ID:
+ bmap = &riscv_isa_vendor_ext_list_leaprise.all_harts_isa_bitmap;
+ cpu_bmap = riscv_isa_vendor_ext_list_leaprise.per_hart_isa_bitmap;
+ break;
+ #endif
#ifdef CONFIG_RISCV_ISA_VENDOR_EXT_MIPS
case MIPS_VENDOR_ID:
bmap = &riscv_isa_vendor_ext_list_mips.all_harts_isa_bitmap;
diff --git a/arch/riscv/kernel/vendor_extensions/Makefile b/arch/riscv/kernel/vendor_extensions/Makefile
index bf116c82b6bd..1f76fd4050c7 100644
--- a/arch/riscv/kernel/vendor_extensions/Makefile
+++ b/arch/riscv/kernel/vendor_extensions/Makefile
@@ -1,6 +1,8 @@
# SPDX-License-Identifier: GPL-2.0-only

obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_ANDES) += andes.o
+obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_LEAPRISE) += leaprise.o
+obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_LEAPRISE) += leaprise_hwprobe.o
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_MIPS) += mips.o
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_MIPS) += mips_hwprobe.o
obj-$(CONFIG_RISCV_ISA_VENDOR_EXT_SIFIVE) += sifive.o
diff --git a/arch/riscv/kernel/vendor_extensions/leaprise.c b/arch/riscv/kernel/vendor_extensions/leaprise.c
new file mode 100644
index 000000000000..bdc2eed288ba
--- /dev/null
+++ b/arch/riscv/kernel/vendor_extensions/leaprise.c
@@ -0,0 +1,12 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <asm/cpufeature.h>
+#include <asm/vendor_extensions.h>
+#include <asm/vendor_extensions/leaprise.h>
+
+/* LeapRise vendor extensions: none defined yet */
+
+struct riscv_isa_vendor_ext_data_list riscv_isa_vendor_ext_list_leaprise = {
+ .ext_data_count = 0,
+ .ext_data = NULL,
+};
diff --git a/arch/riscv/kernel/vendor_extensions/leaprise_hwprobe.c b/arch/riscv/kernel/vendor_extensions/leaprise_hwprobe.c
new file mode 100644
index 000000000000..260a2b38e4d6
--- /dev/null
+++ b/arch/riscv/kernel/vendor_extensions/leaprise_hwprobe.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-2.0-only
+
+#include <asm/vendor_extensions.h>
+#include <asm/vendor_extensions/leaprise.h>
+#include <asm/vendor_extensions/leaprise_hwprobe.h>
+#include <asm/vendor_extensions/vendor_hwprobe.h>
+
+#include <linux/cpumask.h>
+#include <linux/types.h>
+
+#include <uapi/asm/hwprobe.h>
+#include <uapi/asm/vendor/leaprise.h>
+
+void hwprobe_isa_vendor_ext_leaprise_0(struct riscv_hwprobe *pair,
+ const struct cpumask *cpus)
+{
+ /* No LeapRise vendor extensions are defined yet. */
+ pair->value = 0;
+}
--
2.27.0