Skip to contentSkip to conversation

riscv: Capture IMSIC addresses at boot time

PATCH New Andrew Jones 1 participant 1 message Nov 20

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 riscv: Capture IMSIC addresses at boot time

Tests may want to use the IMSICs for MSIs and the upcoming BRS tests want to confirm IMSICs are present. Provide those tests the S-mode interrupt file addresses by parsing DT and capturing them at boot time.

---
 lib/riscv/asm/imsic.h     |  8 ++++
 lib/riscv/asm/processor.h |  1 +
 lib/riscv/imsic.c         | 86 +++++++++++++++++++++++++++++++++++++++
 lib/riscv/setup.c         |  2 +
 riscv/Makefile            |  1 +
 5 files changed, 98 insertions(+)
 create mode 100644 lib/riscv/asm/imsic.h
 create mode 100644 lib/riscv/imsic.c
lib/riscv/asm/imsic.h new file +8 -0
new file mode 100644
index 000000000000..c011b106da8c
@@ -0,0 +1,8 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+#ifndef _ASMRISCV_IMSIC_H_
+#define _ASMRISCV_IMSIC_H_
+#include <asm/processor.h>
+
+void imsic_init(struct thread_info *ti);
+
+#endif /* _ASMRISCV_IMSIC_H_ */
lib/riscv/asm/processor.h +1 -0
index a3dab064691c..2c261805d181 100644
@@ -15,6 +15,7 @@ struct thread_info {
 	int cpu;
 	unsigned long hartid;
 	unsigned long isa[1];
+	phys_addr_t imsic_addr;		/* S-level interrupt file, INVALID_PHYS_ADDR if none */
 	unsigned long sp;
 	exception_fn exception_handlers[EXCEPTION_CAUSE_MAX];
 	exception_fn interrupt_handlers[INTERRUPT_CAUSE_MAX];
lib/riscv/imsic.c new file +86 -0

86 lines not on this page · raw message

lib/riscv/setup.c +2 -0
index a30aa0c4cb80..99acb550cf32 100644
@@ -16,6 +16,7 @@
 #include <on-cpus.h>
 #include <vmalloc.h>
 #include <asm/csr.h>
+#include <asm/imsic.h>
 #include <asm/mmu.h>
 #include <asm/page.h>
 #include <asm/processor.h>
@@ -56,6 +57,7 @@ static void cpu_set_fdt(int fdtnode __unused, u64 regval, void *info __unused)
 
 	cpus[cpu].cpu = cpu;
 	cpus[cpu].hartid = regval;
+	imsic_init(&cpus[cpu]);
 
 	if (!sbi_hart_get_status(cpus[cpu].hartid).error)
 		set_cpu_present(cpu, true);
riscv/Makefile +1 -0
index 348a30a77df9..f90992ab0b71 100644
@@ -39,6 +39,7 @@ cflatobjs += lib/on-cpus.o
 cflatobjs += lib/vmalloc.o
 cflatobjs += lib/riscv/bitops.o
 cflatobjs += lib/riscv/delay.o
+cflatobjs += lib/riscv/imsic.o
 cflatobjs += lib/riscv/io.o
 cflatobjs += lib/riscv/isa.o
 cflatobjs += lib/riscv/mmu.o
Signature · 7 lines
2.56.0


-- 
kvm-riscv mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kvm-riscv