Linux userland API discussions
 help / color / mirror / Atom feed
From: Conor Dooley <conor@kernel.org>
To: Zhouqi Jiang <luojia@rustsbi.com>
Cc: linux-riscv@lists.infradead.org, Paul Walmsley <pjw@kernel.org>,
	Palmer Dabbelt <palmer@dabbelt.com>,
	Albert Ou <aou@eecs.berkeley.edu>,
	Alexandre Ghiti <alex@ghiti.fr>, Dongliang Mu <dzm91@hust.edu.cn>,
	Anup Patel <anup@brainfault.org>, Andrew Davis <afd@ti.com>,
	Mayuresh Chitale <mchitale@ventanamicro.com>,
	linux-api@vger.kernel.org, linux-kernel@vger.kernel.org,
	Vivian Wang <wangruikang@iscas.ac.cn>,
	Alejandro Colomar <alx@kernel.org>,
	contact@rustsbi.com
Subject: Re: [RFC PATCH RESEND] riscv: sbi: expose firmware identity in sysfs
Date: Thu, 19 Nov 2026 15:57:19 +0000	[thread overview]
Message-ID: <20261119-borough-flap-6481c20b3013@spud> (raw)
In-Reply-To: <A039A2DE1DF8F274+20261119130356.1537-1-luojia@rustsbi.com>

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

On Thu, Nov 19, 2026 at 09:03:56PM +0800, Zhouqi Jiang wrote:
> Linux queries the SBI specification and implementation identity during
> boot. It caches the specification version, but discards the
> implementation ID and version after logging them. Userspace therefore
> has no structured interface for this immutable firmware metadata.
> 
> Cache the implementation ID and version and expose the available values
> as read-only attributes under /sys/firmware/sbi:
> 
>   spec_version
>   impl_id
>   impl_version
> 
> SBI v0.1 systems expose only spec_version because the implementation
> fields were introduced by the SBI Base extension in v0.2.
> 
> This gives tools such as lssbi a native source for basic SBI identity
> information and starts moving those queries away from out-of-tree
> kernel modules.
> 
> Codex was prompted to research lssbi's out-of-tree SBI probe and design
> a minimal in-kernel replacement. It assisted with the sysfs interface,
> implementation, ABI documentation, changelog, and QEMU test setup. The
> result was built with a RISC-V defconfig and boot-tested under QEMU
> virt with:
> 
>   OpenSBI v1.3
>   RustSBI v0.4.1

I like this idea.

> Assisted-by: Codex:GPT-5

FYI, these tags are now deprecated.

> +static ssize_t impl_id_show(struct kobject *kobj,
> +			    struct kobj_attribute *attr, char *buf)
> +{
> +	return sysfs_emit(buf, "0x%lx\n", sbi_impl_id);
> +}

Should this actually be printed as a decimal? It's a minor thing, but
the numbers in the spec are defined that way (see 4.9 SBI Implementation
IDs in the 3.0 spec).

> +
> +static ssize_t impl_version_show(struct kobject *kobj,
> +				 struct kobj_attribute *attr, char *buf)
> +{
> +	return sysfs_emit(buf, "0x%lx\n", sbi_impl_version);
> +}

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

  reply	other threads:[~2026-11-19 15:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 13:03 [RFC PATCH RESEND] riscv: sbi: expose firmware identity in sysfs Zhouqi Jiang
2026-11-19 15:57 ` Conor Dooley [this message]
2026-11-19 16:21   ` Conor Dooley

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=20261119-borough-flap-6481c20b3013@spud \
    --to=conor@kernel.org \
    --cc=afd@ti.com \
    --cc=alex@ghiti.fr \
    --cc=alx@kernel.org \
    --cc=anup@brainfault.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=contact@rustsbi.com \
    --cc=dzm91@hust.edu.cn \
    --cc=linux-api@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=luojia@rustsbi.com \
    --cc=mchitale@ventanamicro.com \
    --cc=palmer@dabbelt.com \
    --cc=pjw@kernel.org \
    --cc=wangruikang@iscas.ac.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