From c82ea2b20b938c70b962bcab672773e1d8db7496 Mon Sep 17 00:00:00 2001 From: Paolo Bonzini Date: Tue, 13 Feb 2018 08:54:38 -0500 Subject: [PATCH] memory: track DIRTY_MEMORY_CODE in mr->dirty_log_mask DIRTY_MEMORY_CODE is only needed for TCG. By adding it directly to mr->dirty_log_mask, we avoid testing for TCG everywhere a region is checked for the enabled/disabled state of dirty logging. Backports commit 677e7805cf95f3b2bca8baf0888d1ebed7f0c606 from qemu --- qemu/include/exec/memory.h | 4 ++-- qemu/memory.c | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/qemu/include/exec/memory.h b/qemu/include/exec/memory.h index 46dcd2ee..f7c32f16 100644 --- a/qemu/include/exec/memory.h +++ b/qemu/include/exec/memory.h @@ -522,8 +522,8 @@ bool memory_region_is_logging(MemoryRegion *mr, uint8_t client); * memory_region_get_dirty_log_mask: return the clients for which a * memory region is logging writes. * - * Returns a bitmap of clients, which right now will be either 0 or - * (1 << DIRTY_MEMORY_VGA). + * Returns a bitmap of clients, in which the DIRTY_MEMORY_* constants + * are the bit indices. * * @mr: the memory region being queried */ diff --git a/qemu/memory.c b/qemu/memory.c index 97275816..75917302 100644 --- a/qemu/memory.c +++ b/qemu/memory.c @@ -1162,6 +1162,7 @@ void memory_region_init_ram(struct uc_struct *uc, MemoryRegion *mr, mr->terminates = true; mr->destructor = memory_region_destructor_ram; mr->ram_addr = qemu_ram_alloc(size, mr, errp); + mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0; } void memory_region_init_ram_ptr(struct uc_struct *uc, MemoryRegion *mr, @@ -1174,6 +1175,7 @@ void memory_region_init_ram_ptr(struct uc_struct *uc, MemoryRegion *mr, mr->ram = true; mr->terminates = true; mr->destructor = memory_region_destructor_ram_from_ptr; + mr->dirty_log_mask = tcg_enabled(uc) ? (1 << DIRTY_MEMORY_CODE) : 0; /* qemu_ram_alloc_from_ptr cannot fail with ptr != NULL. */ assert(ptr != NULL);