@samitouri / QOSamiQemu / commits / b3faeab53a

target/riscv: Print privilege level and ELP in riscv_cpu_dump_state

The privilege level and ELP are implicit state (like virt), so print them out. Signed-off-by: Anton Blanchard <antonb@tenstorrent.com> Reviewed-by: Daniel Henrique Barboza <daniel.barboza@oss.qualcomm.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <20260529053519.1224019-1-antonb@tenstorrent.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Anton Blanchard committed May 29, 2026 at 05:35 UTC b3faeab53a9e2ea78e184fdeab23619d7ca7f318
1 file changed +22
target/riscv/cpu.c
+22
@@ -577,6 +577,22 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)
577 }
578 }
579
580 +#if !defined(CONFIG_USER_ONLY)
581 +static const char *riscv_priv_str(uint32_t priv)
582 +{
583 + switch (priv) {
584 + case PRV_M:
585 + return "M";
586 + case PRV_S:
587 + return "S";
588 + case PRV_U:
589 + return "U";
590 + }
591 +
592 + return "?";
593 +}
594 +#endif
595 +
596 static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
597 {
598 RISCVCPU *cpu = RISCV_CPU(cs);
@@ -585,9 +601,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
601 uint8_t *p;
602
603 #if !defined(CONFIG_USER_ONLY)
604 + qemu_fprintf(f, " %s %s\n", "priv = ", riscv_priv_str(env->priv));
605 +
606 if (riscv_has_ext(env, RVH)) {
607 qemu_fprintf(f, " %s %d\n", "V = ", env->virt_enabled);
608 }
609 +
610 + if (cpu->cfg.ext_zicfilp) {
611 + qemu_fprintf(f, " %s %d\n", "elp = ", env->elp);
612 + }
613 #endif
614 qemu_fprintf(f, " %s %" PRIx64 "\n", "pc ", env->pc);
615 #ifndef CONFIG_USER_ONLY