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
This commit is contained in:
Paolo Bonzini 2018-02-13 08:54:38 -05:00 committed by Lioncash
parent e3d1cef8fb
commit c82ea2b20b
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7
2 changed files with 4 additions and 2 deletions

View file

@ -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
*/

View file

@ -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);