From b1f5794ab405a1209424f22600826d238856c833 Mon Sep 17 00:00:00 2001 From: w1tcher Date: Tue, 14 Jan 2020 09:29:29 -0500 Subject: [PATCH] Fix the error in the hook_code of the arm Calling emu_stop and causing the pc value to be incorrect after the end of the run. (#1157) Backports commit 83887b8193dfeca3e5e8da851b41f874bcd0514e from unicorn. --- qemu/accel/tcg/cpu-exec.c | 3 ++- qemu/accel/tcg/translate-all.c | 6 +++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/qemu/accel/tcg/cpu-exec.c b/qemu/accel/tcg/cpu-exec.c index b9155ddc..ae02e407 100644 --- a/qemu/accel/tcg/cpu-exec.c +++ b/qemu/accel/tcg/cpu-exec.c @@ -69,7 +69,8 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb) } else { assert(cc->set_pc); // avoid sync twice when helper_uc_tracecode() already did this. - if (env->uc->emu_counter <= env->uc->emu_count && !env->uc->quit_request) { + if (env->uc->emu_counter <= env->uc->emu_count && + !env->uc->stop_request && !env->uc->quit_request) { cc->set_pc(cpu, last_tb->pc); } } diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index b44a54a9..858d26b1 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -202,9 +202,9 @@ void tb_cleanup(struct uc_struct *uc) return; } - int x = V_L1_SHIFT / V_L2_BITS; + int x = uc->v_l1_shift / V_L2_BITS; if (x <= 1) { - for (int i = 0; i < V_L1_SIZE; i++) { + for (int i = 0; i < uc->v_l1_size; i++) { void **p = uc->l1_map[i]; if (p) { g_free(p); @@ -212,7 +212,7 @@ void tb_cleanup(struct uc_struct *uc) } } } else { - for (int i = 0; i < V_L1_SIZE; i++) { + for (int i = 0; i < uc->v_l1_size; i++) { void **p = uc->l1_map[i]; if (p) { tb_clean_internal(p, x - 1);