|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [PATCH v2] xen/riscv: dump GPRS and CSRs on unexpected traps
On 1/19/26 9:34 AM, Jan Beulich wrote: On 16.01.2026 17:16, Oleksii Kurochko wrote:Provide more context on the exception state when an unexpected exception occurs by dumping various Supervisor, Virtual Supervisor and Hypervisor CSRs, and GPRs pertaining to the trap. Signed-off-by: Oleksii Kurochko<oleksii.kurochko@xxxxxxxxx> --- Changes in v2 - Address coments about print_csr() macros and dump_csrs(). - Add dumping of GPRs pertaining to the trap. --- xen/arch/riscv/traps.c | 82 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/xen/arch/riscv/traps.c b/xen/arch/riscv/traps.c index e9c967786312..4e0df698552f 100644 --- a/xen/arch/riscv/traps.c +++ b/xen/arch/riscv/traps.c @@ -17,6 +17,13 @@ #include <asm/traps.h> #include <asm/vsbi.h>+#define print_csr(csr) \ No, the prefix isn't really useful. It was printed so only because all CSRs registers defintions start on CSR_*. Unlike for the GPRs this also prints the register names in upper case. That may be fine, or may not be. I will follow then like it is written in RISC-V spec for consistency. The values printed also won't align, which may make reading more difficult. Do you expect the similar alignment like for GPRs?
It is less clear how it would be better to group them. I thought about CSR_STVEC: .... CSR_VSTVEC: .... CSR_STTATUS: ... CSR_VSSTATUS: .... So group them in S-mode mode register and VS-mode register.
Agree, we could drop this print. (Then probably the same could be for Supervisor CSRs and Virtual Supervisor CSRs, etc as it is clear based on the name which one CSR it is) + print_gprs(regs, ra, sp); + print_gprs(regs, gp, tp); + print_gprs(regs, t0, t1); + print_gprs(regs, t2, s0); + print_gprs(regs, s1, a0); + print_gprs(regs, a1, a2); + print_gprs(regs, a3, a4); + print_gprs(regs, a5, a6); + print_gprs(regs, a7, s2); + print_gprs(regs, s3, s4); + print_gprs(regs, s5, s6); + print_gprs(regs, s7, s8); + print_gprs(regs, s9, s10); + print_gprs(regs, s11, t3); + print_gprs(regs, t4, t5); + print_gprs(regs, t6, sepc); + print_gprs(regs, sstatus, hstatus);The last three aren't GPRs. Why would they be logged here? (All three also being logged in dump_csrs() would further require some disambiguation in the output, for people to not need to go look at the source code every time.) Agree, that it would be better to print it with the CSRs. It was print here only as they are in the same structure with GPRs.
It is hard to describe in general why they could be needed. The best I can come up is: Dump VS* CSRs to provide full guest exception context. When handling traps originating from VS-mode, host CSRs alone do not describe the fault; VSCAUSE, VSEPC, VSTVAL, and related state are required to diagnose guest crashes and hypervisor misconfiguration, and to correlate host-side handling with guest-visible exceptions. Does it good enough justification? ~ Oleksii
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |