[kvm-unit-tests PATCH v2 7/8] riscv: initialize ISA extensions for all harts in cpu_init
Andrew Jones
andrew.jones at linux.dev
Fri Nov 20 03:37:59 PST 2026
On Thu, Nov 05, 2026 at 04:20:34PM +0800, Xiang W wrote:
> Move `isa_init()` from `thread_info_init()` to `cpu_init()`.
>
> Previously it only ran for the current hart; now it is called for every
> hart so that ISA extensions are parsed for the whole system.
It was already run on every hart. The boot hart at boot time, the
secondaries at secondary start time. However, I see in the next patch
that you want to query ISA extensions on secondaries that haven't run
secondary start. Since we already initialize some thread info in cpu init
then I think it's reasonable to also init ISA there as you do, but let's
do it like in the following diff instead of anding the loop
diff --git a/lib/riscv/processor.c b/lib/riscv/processor.c
index b055acc94e41..ddecc25e940d 100644
--- a/lib/riscv/processor.c
+++ b/lib/riscv/processor.c
@@ -81,7 +81,6 @@ void thread_info_init(void)
unsigned long hartid = csr_read(CSR_SSCRATCH);
int cpu = hartid_to_cpu(hartid);
- isa_init(&cpus[cpu]);
csr_write(CSR_SSCRATCH, &cpus[cpu]);
}
diff --git a/lib/riscv/setup.c b/lib/riscv/setup.c
index f1121573e81c..547851f532c3 100644
--- a/lib/riscv/setup.c
+++ b/lib/riscv/setup.c
@@ -16,6 +16,7 @@
#include <on-cpus.h>
#include <vmalloc.h>
#include <asm/csr.h>
+#include <asm/isa.h>
#include <asm/mmu.h>
#include <asm/page.h>
#include <asm/processor.h>
@@ -61,6 +62,7 @@ static int cpu_set_acpi(struct acpi_subtable_header *header)
cpus[cpu].cpu = cpu;
cpus[cpu].hartid = intc->hart_id;
cpus[cpu].uid = intc->uid;
+ isa_init(&cpus[cpu]);
if (intc->flags & ACPI_MADT_ENABLED) {
if (!sbi_hart_get_status(cpus[cpu].hartid).error)
@@ -79,6 +81,7 @@ static void cpu_set_fdt(int fdtnode __unused, u64 regval, void *info __unused)
cpus[cpu].cpu = cpu;
cpus[cpu].hartid = regval;
+ isa_init(&cpus[cpu]);
if (!sbi_hart_get_status(cpus[cpu].hartid).error)
set_cpu_present(cpu, true);
More information about the kvm-riscv
mailing list