[PATCH RESEND 2/2] riscv: hwprobe: Add LeapRise vendor extension framework support
From: lv.yating
Date: Mon Nov 16 2026 - 20:06:22 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.
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 | 1 +
.../include/asm/vendor_extensions/leaprise.h | 11 ++++++++++
.../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/Makefile | 2 ++
.../riscv/kernel/vendor_extensions/leaprise.c | 7 +++++++
.../vendor_extensions/leaprise_hwprobe.c | 18 +++++++++++++++++
11 files changed, 85 insertions(+)
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..d8d7c4b39229 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..b153dedc8c10 100644
--- a/arch/riscv/include/asm/hwprobe.h
+++ b/arch/riscv/include/asm/hwprobe.h
@@ -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..abac6adc240c
--- /dev/null
+++ b/arch/riscv/include/asm/vendor_extensions/leaprise.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+
+#ifndef _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_H
+#define _ASM_RISCV_VENDOR_EXTENSIONS_LEAPRISE_H
+
+#include <linux/types.h>
+
+/* LeapRise vendor extensions: none defined yet */
+
+#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..d98a383cfb72
--- /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/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..08265f147092
--- /dev/null
+++ b/arch/riscv/kernel/vendor_extensions/leaprise.c
@@ -0,0 +1,7 @@
+// 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 */
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..e7ffa57db4ab
--- /dev/null
+++ b/arch/riscv/kernel/vendor_extensions/leaprise_hwprobe.c
@@ -0,0 +1,18 @@
+// 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)
+{
+ pair->value = 0;
+}
--
2.27.0