From 4a7b3b7a3ab7b6f872ff134542245e2e23d71101 Mon Sep 17 00:00:00 2001 From: "Takacs, Philipp" Date: Fri, 12 May 2023 12:28:39 +0200 Subject: [PATCH] fixup! load_helper only call cpu_loop_exit() when emulation is running --- qemu/accel/tcg/cputlb.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu/accel/tcg/cputlb.c b/qemu/accel/tcg/cputlb.c index 29c6555b..3d0ae80f 100644 --- a/qemu/accel/tcg/cputlb.c +++ b/qemu/accel/tcg/cputlb.c @@ -1520,7 +1520,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, mr = find_memory_region(uc, paddr); if (mr == NULL) { uc->invalid_error = UC_ERR_MAP; - if (!uc->cpu->stopped) { + if (uc->nested_level > 0) { cpu_exit(uc->cpu); // XXX(@lazymio): We have to exit early so that the target register won't be overwritten // because qemu might generate tcg code like: @@ -1534,7 +1534,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uc->invalid_addr = paddr; uc->invalid_error = error_code; // printf("***** Invalid fetch (unmapped memory) at " TARGET_FMT_lx "\n", addr); - if (!uc->cpu->stopped) { + if (uc->nested_level > 0) { cpu_exit(uc->cpu); // See comments above cpu_loop_exit(uc->cpu); @@ -1592,7 +1592,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uc->invalid_addr = paddr; uc->invalid_error = UC_ERR_READ_PROT; // printf("***** Invalid memory read (non-readable) at " TARGET_FMT_lx "\n", addr); - if (!uc->cpu->stopped) { + if (uc->nested_level > 0) { cpu_exit(uc->cpu); // See comments above cpu_loop_exit(uc->cpu); @@ -1624,7 +1624,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, uc->invalid_addr = paddr; uc->invalid_error = UC_ERR_FETCH_PROT; // printf("***** Invalid fetch (non-executable) at " TARGET_FMT_lx "\n", addr); - if (!uc->cpu->stopped) { + if (uc->nested_level > 0) { cpu_exit(uc->cpu); // See comments above cpu_loop_exit(uc->cpu);