From 6f6f935114053733dd761f9d9fde7dcb75007ea6 Mon Sep 17 00:00:00 2001 From: Alfredo Mazzinghi Date: Mon, 8 Jul 2024 13:30:53 +0100 Subject: [PATCH] Introduce tracing nops for aarch64. Use the hlt instruction with a custom set of immediates to issue tracing commands. This mirrors the behaviour of the ARM FVP Tarmac trace plugin, which uses the hlt instruction with configurable immediate values to start and stop tracing. Introduce the following hlt immediates: - 0xff00: start instruction tracing - 0xff01: stop instruction tracing - 0xff02: start user-mode instruction tracing --- target/arm/translate-a64.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/arm/translate-a64.c b/target/arm/translate-a64.c index 2982700c32..d2f95b4763 100644 --- a/target/arm/translate-a64.c +++ b/target/arm/translate-a64.c @@ -2697,7 +2697,32 @@ static void disas_exc(DisasContext *s, uint32_t insn) #endif gen_exception_internal_insn(s, s->pc_curr, EXCP_SEMIHOST); } else { +#ifdef CONFIG_TCG_LOG_INSTR + TCGv tpc = tcg_const_tl(s->base.pc_next); + switch (imm16) { + case 0xff00: + gen_helper_qemu_log_instr_start(cpu_env, tpc); + s->base.is_jmp = DISAS_EXIT; + break; + case 0xff01: + gen_helper_qemu_log_instr_stop(cpu_env, tpc); + s->base.is_jmp = DISAS_EXIT; + break; + case 0xff02: + gen_helper_qemu_log_instr_user_start(cpu_env, tpc); + s->base.is_jmp = DISAS_EXIT; + break; + default: + unsupported_encoding(s, insn); + } + tcg_temp_free(tpc); + + if (s->base.is_jmp != DISAS_NEXT) { + gen_a64_set_pc_im(s->base.pc_next); + } +#else unsupported_encoding(s, insn); +#endif } break; case 5: