Commit b3faeab53a for qemu.org
commit b3faeab53a9e2ea78e184fdeab23619d7ca7f318
Author: Anton Blanchard <antonb@tenstorrent.com>
Date: Fri May 29 05:35:18 2026 +0000
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>
diff --git a/target/riscv/cpu.c b/target/riscv/cpu.c
index df101b1213..a5b1c2ba62 100644
--- a/target/riscv/cpu.c
+++ b/target/riscv/cpu.c
@@ -577,6 +577,22 @@ static void riscv_dump_csr(CPURISCVState *env, int csrno, FILE *f)
}
}
+#if !defined(CONFIG_USER_ONLY)
+static const char *riscv_priv_str(uint32_t priv)
+{
+ switch (priv) {
+ case PRV_M:
+ return "M";
+ case PRV_S:
+ return "S";
+ case PRV_U:
+ return "U";
+ }
+
+ return "?";
+}
+#endif
+
static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
{
RISCVCPU *cpu = RISCV_CPU(cs);
@@ -585,9 +601,15 @@ static void riscv_cpu_dump_state(CPUState *cs, FILE *f, int flags)
uint8_t *p;
#if !defined(CONFIG_USER_ONLY)
+ qemu_fprintf(f, " %s %s\n", "priv = ", riscv_priv_str(env->priv));
+
if (riscv_has_ext(env, RVH)) {
qemu_fprintf(f, " %s %d\n", "V = ", env->virt_enabled);
}
+
+ if (cpu->cfg.ext_zicfilp) {
+ qemu_fprintf(f, " %s %d\n", "elp = ", env->elp);
+ }
#endif
qemu_fprintf(f, " %s %" PRIx64 "\n", "pc ", env->pc);
#ifndef CONFIG_USER_ONLY