[kvm-unit-tests PATCH v3 7/9] riscv: Initialize ISA extensions for all harts at CPU setup
Xiang W
wangxiang at iscas.ac.cn
Tue Nov 24 17:44:07 PST 2026
Move isa_init() from thread_info_init() into cpu_set_fdt() and
cpu_set_acpi().
thread_info_init() only promotes sscratch to the current hart's
thread_info. cpu_has_extension() reads cpus[].isa from the boot
hart, including for secondaries that have not started yet, so ISA
parsing has to happen while enumerating CPUs.
Signed-off-by: Xiang W <wangxiang at iscas.ac.cn>
---
lib/riscv/processor.c | 1 -
lib/riscv/setup.c | 3 +++
2 files changed, 3 insertions(+), 1 deletion(-)
diff --git a/lib/riscv/processor.c b/lib/riscv/processor.c
index b055acc9..ddecc25e 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 f1121573..547851f5 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);
--
2.47.3
More information about the kvm-riscv
mailing list