mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: lv.yating@zte.com.cn
Cc: pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
	alex@ghiti.fr, corbet@lwn.net, skhan@linuxfoundation.org,
	rdunlap@infradead.org, linux-riscv@lists.infradead.org,
	linux-kernel@vger.kernel.org, liu.qingtao2@zte.com.cn,
	he.yilin@zte.com.cn, ye.zhihao1@zte.com.cn,
	zhang.cheng35@zte.com.cn, hu.shengming@zte.com.cn,
	linux-doc@vger.kernel.org
Subject: Re: [PATCH v2 2/2] riscv: hwprobe: Add LeapRise vendor extension? framework support
Date: Fri, 20 Nov 2026 13:43:06 +0000	[thread overview]
Message-ID: <20261120-various-achiness-6c942b0c4803@spud> (raw)
In-Reply-To: <20261120150437672HnkUOWm6mhr5u-3Ha2pJQ@zte.com.cn>

[-- Attachment #1: Type: text/plain, Size: 12415 bytes --]

On Fri, Nov 20, 2026 at 03:04:37PM +0800, lv.yating@zte.com.cn wrote:
> From: Lv Yating <lv.yating@zte.com.cn>
> 
> 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.

I don't buy this argument really. You kernel will require out of tree
patches to report the extensions for your userspace to do anything with
them, so why can this not wait until then?
Empty bitmask versus an error is a much of a muchness, both mean no
support.

I fear this is being done to reserve a key without actually upstreaming
anything to do with these extensions, which I think sets a bad
precedent. Upstreaming a user (which really should be trivial, unless
all your extensions need kernel support) would assuage that fear.

> 
> Follow-up patches will register extensions as they are defined.
> 
> Signed-off-by: Lv Yating <lv.yating@zte.com.cn>
> ---
>  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.

This, for example, makes no sense when there are no extensions
detectable in the first place? A bunch of this is dead code without
anything actually using it right now.

Cheers,
Conor.

> +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
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

      reply	other threads:[~2026-11-20 13:43 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-20  6:51 [PATCH v2 0/2] riscv: Add Beijing LeapRise Technology vendor ID and vendor extension framework lv.yating
2026-11-20  7:02 ` [PATCH v2 1/2] riscv: Add LeapRise Technology to the vendor list lv.yating
2026-11-20  7:04 ` [PATCH v2 2/2] riscv: hwprobe: Add LeapRise vendor extension framework support lv.yating
2026-11-20 13:43   ` Conor Dooley [this message]

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=20261120-various-achiness-6c942b0c4803@spud \
    --to=conor@kernel.org \
    --cc=alex@ghiti.fr \
    --cc=aou@eecs.berkeley.edu \
    --cc=corbet@lwn.net \
    --cc=he.yilin@zte.com.cn \
    --cc=hu.shengming@zte.com.cn \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=liu.qingtao2@zte.com.cn \
    --cc=lv.yating@zte.com.cn \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=skhan@linuxfoundation.org \
    --cc=ye.zhihao1@zte.com.cn \
    --cc=zhang.cheng35@zte.com.cn \
    /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®