@samitouri / QOSamiQemu / commits / 724452279f

target/loongarch: Enable disassembly via capstone

Reviewed-by: Song Gao <17746591750@163.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org>

Richard Henderson committed Aug 8, 2026 at 14:20 UTC 724452279fda64259b480db07818bb0f11b0b5a7
2 files changed +14
include/disas/capstone.h
+6
@@ -40,6 +40,12 @@
40
41 #endif /* CONFIG_CAPSTONE */
42
43 +#if CS_API_MAJOR < 6
44 +#define CS_ARCH_LOONGARCH -1
45 +#define CS_MODE_LOONGARCH32 0
46 +#define CS_MODE_LOONGARCH64 0
47 +#endif
48 +
49 #if CS_API_MAJOR < 5
50 #define CS_ARCH_RISCV -1
51 #define CS_MODE_RISCV32 0
target/loongarch/cpu.c
+8
@@ -29,6 +29,7 @@
29 #include <linux/kvm.h>
30 #endif
31 #include "tcg/tcg_loongarch.h"
32 +#include "disas/capstone.h"
33
34 const char * const regnames[32] = {
35 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
@@ -694,8 +695,15 @@ static void loongarch_cpu_reset_hold(Object *obj, ResetType type)
695 static void loongarch_cpu_disas_set_info(const CPUState *cs,
696 disassemble_info *info)
697 {
698 + CPULoongArchState *env = cpu_env((CPUState *)cs);
699 +
700 info->endian = BFD_ENDIAN_LITTLE;
701 info->print_insn = print_insn_loongarch;
702 +
703 + info->cap_arch = CS_ARCH_LOONGARCH;
704 + info->cap_insn_unit = 4;
705 + info->cap_insn_split = 4;
706 + info->cap_mode = is_la64(env) ? CS_MODE_LOONGARCH64 : CS_MODE_LOONGARCH32;
707 }
708
709 static void loongarch_cpu_realizefn(DeviceState *dev, Error **errp)