@@ -119,7 +119,9 @@ uint8_t *code_gen_ptr;
#if !defined(CONFIG_USER_ONLY)
int phys_ram_fd;
-uint8_t *phys_ram_dirty;
+unsigned long *phys_ram_vga_dirty;
+unsigned long *phys_ram_code_dirty;
+unsigned long *phys_ram_migration_dirty;
uint8_t *bios_mem;
static int in_migration;
@@ -2659,10 +2661,20 @@ ram_addr_t qemu_ram_alloc(ram_addr_t size)
new_block->next = ram_blocks;
ram_blocks = new_block;
- phys_ram_dirty = qemu_realloc(phys_ram_dirty,
- (last_ram_offset + size) >> TARGET_PAGE_BITS);
- memset(phys_ram_dirty + (last_ram_offset >> TARGET_PAGE_BITS),
- 0xff, size >> TARGET_PAGE_BITS);
+ if (BITMAP_SIZE(last_ram_offset + size) != BITMAP_SIZE(last_ram_offset)) {
+ phys_ram_vga_dirty = qemu_realloc(phys_ram_vga_dirty,
+ BITMAP_SIZE(last_ram_offset + size));
+ phys_ram_code_dirty = qemu_realloc(phys_ram_code_dirty,
+ BITMAP_SIZE(last_ram_offset + size));
+ phys_ram_migration_dirty = qemu_realloc(phys_ram_migration_dirty,
+ BITMAP_SIZE(last_ram_offset + size));
+ memset((uint8_t *)phys_ram_vga_dirty +
+ BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+ memset((uint8_t *)phys_ram_code_dirty +
+ BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+ memset((uint8_t *)phys_ram_migration_dirty +
+ BITMAP_SIZE(last_ram_offset), 0xff, BITMAP_SIZE(size));
+ }
last_ram_offset += size;