[RFC PATCH RESEND] riscv: sbi: expose firmware identity in sysfs

Conor Dooley conor at kernel.org
Thu Nov 19 07:57:19 PST 2026


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);
> +}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-riscv/attachments/20261119/79457284/attachment.sig>


More information about the linux-riscv mailing list