From 8303328aa830c2a1436266eec7e13058e93d3ec3 Mon Sep 17 00:00:00 2001 From: mio Date: Sun, 14 Aug 2022 12:42:34 +0200 Subject: [PATCH] Obtain memory mapping after hooks are called --- qemu/accel/tcg/cputlb.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/qemu/accel/tcg/cputlb.c b/qemu/accel/tcg/cputlb.c index 62233bc0..7a77dc51 100644 --- a/qemu/accel/tcg/cputlb.c +++ b/qemu/accel/tcg/cputlb.c @@ -1977,7 +1977,7 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, size_t size = memop_size(op); struct hook *hook; bool handled; - MemoryRegion *mr = memory_mapping(uc, addr); + MemoryRegion *mr; if (!uc->size_recur_mem) { // disabling write callback if in recursive call // Unicorn: callback on memory write @@ -1994,6 +1994,9 @@ store_helper(CPUArchState *env, target_ulong addr, uint64_t val, } } + // Load the latest memory mapping. + mr = memory_mapping(uc, addr); + // Unicorn: callback on invalid memory if (mr == NULL) { handled = false;