Commit 9448d9ac authored by Charlie Jenkins's avatar Charlie Jenkins Committed by Palmer Dabbelt

riscv: Add vendor extensions to /proc/cpuinfo

All of the supported vendor extensions that have been listed in
riscv_isa_vendor_ext_list can be exported through /proc/cpuinfo.
Signed-off-by: default avatarCharlie Jenkins <charlie@rivosinc.com>
Reviewed-by: default avatarEvan Green <evan@rivosinc.com>
Reviewed-by: default avatarConor Dooley <conor.dooley@microchip.com>
Link: https://lore.kernel.org/r/20240719-support_vendor_extensions-v3-2-0af7587bbec0@rivosinc.comSigned-off-by: default avatarPalmer Dabbelt <palmer@rivosinc.com>
parent 23c996fc
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
#include <asm/sbi.h> #include <asm/sbi.h>
#include <asm/smp.h> #include <asm/smp.h>
#include <asm/pgtable.h> #include <asm/pgtable.h>
#include <asm/vendor_extensions.h>
bool arch_match_cpu_phys_id(int cpu, u64 phys_id) bool arch_match_cpu_phys_id(int cpu, u64 phys_id)
{ {
...@@ -235,7 +236,33 @@ arch_initcall(riscv_cpuinfo_init); ...@@ -235,7 +236,33 @@ arch_initcall(riscv_cpuinfo_init);
#ifdef CONFIG_PROC_FS #ifdef CONFIG_PROC_FS
static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap) #define ALL_CPUS -1
static void print_vendor_isa(struct seq_file *f, int cpu)
{
struct riscv_isavendorinfo *vendor_bitmap;
struct riscv_isa_vendor_ext_data_list *ext_list;
const struct riscv_isa_ext_data *ext_data;
for (int i = 0; i < riscv_isa_vendor_ext_list_size; i++) {
ext_list = riscv_isa_vendor_ext_list[i];
ext_data = riscv_isa_vendor_ext_list[i]->ext_data;
if (cpu == ALL_CPUS)
vendor_bitmap = &ext_list->all_harts_isa_bitmap;
else
vendor_bitmap = &ext_list->per_hart_isa_bitmap[cpu];
for (int j = 0; j < ext_list->ext_data_count; j++) {
if (!__riscv_isa_extension_available(vendor_bitmap->isa, ext_data[j].id))
continue;
seq_printf(f, "_%s", ext_data[j].name);
}
}
}
static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap, int cpu)
{ {
if (IS_ENABLED(CONFIG_32BIT)) if (IS_ENABLED(CONFIG_32BIT))
...@@ -254,6 +281,8 @@ static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap) ...@@ -254,6 +281,8 @@ static void print_isa(struct seq_file *f, const unsigned long *isa_bitmap)
seq_printf(f, "%s", riscv_isa_ext[i].name); seq_printf(f, "%s", riscv_isa_ext[i].name);
} }
print_vendor_isa(f, cpu);
seq_puts(f, "\n"); seq_puts(f, "\n");
} }
...@@ -316,7 +345,7 @@ static int c_show(struct seq_file *m, void *v) ...@@ -316,7 +345,7 @@ static int c_show(struct seq_file *m, void *v)
* line. * line.
*/ */
seq_puts(m, "isa\t\t: "); seq_puts(m, "isa\t\t: ");
print_isa(m, NULL); print_isa(m, NULL, ALL_CPUS);
print_mmu(m); print_mmu(m);
if (acpi_disabled) { if (acpi_disabled) {
...@@ -338,7 +367,7 @@ static int c_show(struct seq_file *m, void *v) ...@@ -338,7 +367,7 @@ static int c_show(struct seq_file *m, void *v)
* additional extensions not present across all harts. * additional extensions not present across all harts.
*/ */
seq_puts(m, "hart isa\t: "); seq_puts(m, "hart isa\t: ");
print_isa(m, hart_isa[cpu_id].isa); print_isa(m, hart_isa[cpu_id].isa, cpu_id);
seq_puts(m, "\n"); seq_puts(m, "\n");
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment