@samitouri / QOSamiQemu / commits / ae06586a02

uftrace: riscv privilege level

This adds RiscV virtual user and supervisor privilege levels to uftrace plugin to avoid crashing with H extension guests. Signed-off-by: Yanfeng Liu <yfliu2008@qq.com> Reviewed-by: Alistair Francis <alistair.francis@wdc.com> Message-ID: <tencent_E17E8F6494EE130F71527C6BCE481AF33E08@qq.com> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>

Yanfeng Liu committed Jul 12, 2026 at 16:45 UTC ae06586a025afe1929dce5e7c92fe278811c515d
1 file changed +10 -3
contrib/plugins/uftrace.c
+10 -3
@@ -109,6 +109,8 @@ typedef enum {
109 RISCV64_SUPERVISOR,
110 RISCV64_RESERVED,
111 RISCV64_MACHINE,
112 + RISCV64_VUSER,
113 + RISCV64_VSUPERVISOR,
114 RISCV64_PRIVILEGE_LEVEL_MAX,
115 } Riscv64PrivilegeLevel;
116
@@ -153,8 +155,10 @@ static void uftrace_write_map(bool system_emulation)
155 const char *path = "./uftrace.data/sid-0.map";
156
157 if (system_emulation && access(path, F_OK) == 0) {
156 - /* do not erase existing map in system emulation, as a custom one might
157 - * already have been generated by uftrace_symbols.py */
158 + /*
159 + * do not erase existing map in system emulation, as a custom one might
160 + * already have been generated by uftrace_symbols.py
161 + */
162 return;
163 }
164
@@ -706,6 +710,8 @@ static const char *riscv64_get_privilege_level_name(uint8_t pl)
710 case RISCV64_SUPERVISOR: return "Supervisor";
711 case RISCV64_RESERVED: return "Unknown";
712 case RISCV64_MACHINE: return "Machine";
713 + case RISCV64_VUSER: return "VUser";
714 + case RISCV64_VSUPERVISOR: return "VSupervisor";
715 default:
716 g_assert_not_reached();
717 }
@@ -986,7 +992,8 @@ QEMU_PLUGIN_EXPORT int qemu_plugin_install(qemu_plugin_id_t id,
992
993 score = qemu_plugin_scoreboard_new(sizeof(Cpu));
994 qemu_plugin_register_vcpu_init_cb(id, vcpu_init, NULL);
989 - qemu_plugin_register_atexit_cb(id, at_exit, (void *) info->system_emulation);
995 + qemu_plugin_register_atexit_cb(id, at_exit,
996 + (void *) info->system_emulation);
997 qemu_plugin_register_vcpu_tb_trans_cb(id, vcpu_tb_trans, NULL);
998
999 return 0;