From c733bbada356b0373fa8aa72c044574bb855fd24 Mon Sep 17 00:00:00 2001 From: lazymio Date: Tue, 23 Nov 2021 23:22:53 +0100 Subject: [PATCH] Fix wrong offset used in split_region --- qemu/accel/tcg/translate-all.c | 4 +++- uc.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/qemu/accel/tcg/translate-all.c b/qemu/accel/tcg/translate-all.c index ac14d902..c0488ca9 100644 --- a/qemu/accel/tcg/translate-all.c +++ b/qemu/accel/tcg/translate-all.c @@ -985,7 +985,9 @@ static void uc_invalidate_tb(struct uc_struct *uc, uint64_t start_addr, size_t l { tb_page_addr_t start, end; - // GVA to GPA (GPA -> HVA via page_find, HVA->HPA via host mmu) + // GVA to GPA + // (GPA -> HVA via memory_region_get_ram_addr(mr) + GPA + block->host, + // HVA->HPA via host mmu) start = get_page_addr_code(uc->cpu->env_ptr, start_addr) & (target_ulong)(-1); // For 32bit target. diff --git a/uc.c b/uc.c index 591ed69c..2e1add22 100644 --- a/uc.c +++ b/uc.c @@ -1090,7 +1090,8 @@ static bool split_region(struct uc_struct *uc, MemoryRegion *mr, QLIST_FOREACH(block, &uc->ram_list.blocks, next) { - if (block->offset <= mr->addr && + // block->offset is the offset within ram_addr_t, not GPA + if (block->mr->addr <= mr->addr && block->used_length >= (mr->end - mr->addr)) { break; }