Re: [RFC PATCH RESEND] riscv: sbi: expose firmware identity in sysfs
From: Conor Dooley
Date: Thu Nov 19 2026 - 11:22:47 EST
On Thu, Nov 19, 2026 at 03:57:19PM +0000, Conor Dooley wrote:
> 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.
FWIW I tested it with the polarfire hss.
Tested-by: Conor Dooley <conor.dooley@xxxxxxxxxxxxx>
>
> > 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:
signature.asc
Description: PGP signature