[PATCH v7 10/11] riscv: cpu: Output isa bases lines in cpuinfo
From: Guodong Xu <hidden>
Date: 2026-09-15 07:17:41
Also in:
linux-devicetree, linux-kselftest, linux-riscv, lkml, spacemit
Subsystem:
risc-v architecture, the rest · Maintainers:
Paul Walmsley, Palmer Dabbelt, Albert Ou, Linus Torvalds
The "isa" line in /proc/cpuinfo lists a hart's extensions as concatenated string, but not which profile base it satisfies. Add two lines that report them directly: isa bases : <bases that all harts conform to> hart isa bases : <bases that this specific hart conforms to> Example output on qemu booted with -cpu rva23s64,sv39=on,pmp=on: processor : 0 hart : 4 isa bases : rv64ima rva23u64 isa : rv64imafdcbvh_zicbom_zicbop_... ... hart isa bases : rv64ima rva23u64 hart isa : rv64imafdcbvh_zicbom_zicbop_... Signed-off-by: Andrew Jones <redacted> Signed-off-by: Guodong Xu <redacted> --- v7: Use riscv_isa_base_available(). v6: No change. v5: Simplified the commit message. v4: No change. v3: No change. v2: - Read from the cached riscv_isa_bases and hart_isa[cpu_id].isa_bases bitmaps populated by riscv_init_isa_bases() at init time. --- arch/riscv/kernel/cpu.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c
index 3dbc8cc557dd1..d06824048aa25 100644
--- a/arch/riscv/kernel/cpu.c
+++ b/arch/riscv/kernel/cpu.c@@ -305,6 +305,26 @@ static void print_mmu(struct seq_file *f) seq_printf(f, "mmu\t\t: %s\n", sv_type); } +static const char * const riscv_isa_base_names[] = { +#ifdef CONFIG_32BIT + [RISCV_ISA_BASE_IMA] = "rv32ima", +#else + [RISCV_ISA_BASE_IMA] = "rv64ima", +#endif + [RISCV_ISA_BASE_RVA23U64] = "rva23u64", +}; + +static void print_isa_bases(struct seq_file *m, const unsigned long *isa_bases) +{ + unsigned int i; + + for (i = 0; i < RISCV_NR_ISA_BASES; i++) { + if (riscv_isa_base_available(isa_bases, i)) + seq_printf(m, " %s", riscv_isa_base_names[i]); + } + seq_puts(m, "\n"); +} + static void *c_start(struct seq_file *m, loff_t *pos) { if (*pos == nr_cpu_ids)
@@ -336,6 +356,9 @@ static int c_show(struct seq_file *m, void *v) seq_printf(m, "processor\t: %lu\n", cpu_id); seq_printf(m, "hart\t\t: %lu\n", cpuid_to_hartid_map(cpu_id)); + seq_puts(m, "isa bases\t:"); + print_isa_bases(m, NULL); + /* * For historical raisins, the isa: line is limited to the lowest common * denominator of extensions supported across all harts. A true list of
@@ -360,6 +383,9 @@ static int c_show(struct seq_file *m, void *v) seq_printf(m, "marchid\t\t: 0x%lx\n", ci->marchid); seq_printf(m, "mimpid\t\t: 0x%lx\n", ci->mimpid); + seq_puts(m, "hart isa bases\t:"); + print_isa_bases(m, hart_isa[cpu_id].isa_bases); + /* * Print the ISA extensions specific to this hart, which may show * additional extensions not present across all harts.
--
2.43.0