Signed-off-by: Yoshiaki Tamura <tamura.yoshi...@lab.ntt.co.jp> Signed-off-by: OHMURA Kei <ohmura....@lab.ntt.co.jp> --- cpu-all.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 67 insertions(+), 14 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h index c409fad..0f5bfbe 100644 --- a/cpu-all.h +++ b/cpu-all.h @@ -891,43 +891,96 @@ extern unsigned long *phys_ram_dirty[NUM_DIRTY_FLAGS]; /* read dirty bit (return 0 or 1) */ static inline int cpu_physical_memory_is_dirty(ram_addr_t addr) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] == 0xff; + unsigned long mask; + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + int offset = (addr >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + + mask = 1UL << offset; + return (phys_ram_dirty[MASTER_DIRTY_FLAG][index] & mask) == mask; } static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS]; + unsigned long mask; + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + int offset = (addr >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + int ret = 0; + + mask = 1UL << offset; + if (phys_ram_dirty[MASTER_DIRTY_FLAG][index] & mask) + return 0xff; + if (phys_ram_dirty[VGA_DIRTY_FLAG][index] & mask) + ret |= VGA_DIRTY_FLAG; + if (phys_ram_dirty[CODE_DIRTY_FLAG][index] & mask) + ret |= CODE_DIRTY_FLAG; + if (phys_ram_dirty[MIGRATION_DIRTY_FLAG][index] & mask) + ret |= MIGRATION_DIRTY_FLAG; + + return ret; } static inline int cpu_physical_memory_get_dirty(ram_addr_t addr, int dirty_flags) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] & dirty_flags; + unsigned long mask; + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + int offset = (addr >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + + mask = 1UL << offset; + return (phys_ram_dirty[MASTER_DIRTY_FLAG][index] & mask) || + (phys_ram_dirty[dirty_flags][index] & mask); } static inline void cpu_physical_memory_set_dirty(ram_addr_t addr) { - phys_ram_dirty[addr >> TARGET_PAGE_BITS] = 0xff; + unsigned long mask; + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + int offset = (addr >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + + mask = 1UL << offset; + phys_ram_dirty[MASTER_DIRTY_FLAG][index] |= mask; +} + +static inline void cpu_physical_memory_set_dirty_range(ram_addr_t addr, + unsigned long mask) +{ + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + + phys_ram_dirty[MASTER_DIRTY_FLAG][index] |= mask; } -static inline int cpu_physical_memory_set_dirty_flags(ram_addr_t addr, - int dirty_flags) +static inline void cpu_physical_memory_set_dirty_flags(ram_addr_t addr, + int dirty_flags) { - return phys_ram_dirty[addr >> TARGET_PAGE_BITS] |= dirty_flags; + unsigned long mask; + int index = (addr >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + int offset = (addr >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + + mask = 1UL << offset; + if (dirty_flags & VGA_DIRTY_FLAG) + phys_ram_dirty[VGA_DIRTY_FLAG][index] |= mask; + if (dirty_flags & CODE_DIRTY_FLAG) + phys_ram_dirty[CODE_DIRTY_FLAG][index] |= mask; + if (dirty_flags & MIGRATION_DIRTY_FLAG) + phys_ram_dirty[MIGRATION_DIRTY_FLAG][index] |= mask; } static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start, int length, int dirty_flags) { - int i, mask, len; - uint8_t *p; + ram_addr_t addr = start; + unsigned long mask; + int index, offset, i; + + for (i = 0; i < length; i += TARGET_PAGE_SIZE) { + index = ((addr + i) >> TARGET_PAGE_BITS) / HOST_LONG_BITS; + offset = ((addr + i) >> TARGET_PAGE_BITS) & (HOST_LONG_BITS - 1); + mask = ~(1UL << offset); - len = length >> TARGET_PAGE_BITS; - mask = ~dirty_flags; - p = phys_ram_dirty + (start >> TARGET_PAGE_BITS); - for (i = 0; i < len; i++) - p[i] &= mask; + phys_ram_dirty[MASTER_DIRTY_FLAG][index] &= mask; + phys_ram_dirty[dirty_flags][index] &= mask; + } } void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, -- 1.7.0.31.g1df487 -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html