[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/6] qemu-kvm: Modify and introduce wrapper function
From: |
Yoshiaki Tamura |
Subject: |
[Qemu-devel] [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty. |
Date: |
Tue, 16 Mar 2010 19:53:55 +0900 |
Modifies wrapper functions for byte-based phys_ram_dirty bitmap to
bit-based phys_ram_dirty bitmap, and adds more wrapper functions to prevent
direct access to the phys_ram_dirty bitmap.
Signed-off-by: Yoshiaki Tamura <address@hidden>
Signed-off-by: OHMURA Kei <address@hidden>
---
cpu-all.h | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 90 insertions(+), 4 deletions(-)
diff --git a/cpu-all.h b/cpu-all.h
index 9bc01b9..91ec3e5 100644
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -843,7 +843,9 @@ int cpu_str_to_log_mask(const char *str);
/* memory API */
extern int phys_ram_fd;
-extern uint8_t *phys_ram_dirty;
+extern unsigned long *phys_ram_vga_dirty;
+extern unsigned long *phys_ram_code_dirty;
+extern unsigned long *phys_ram_migration_dirty;
extern ram_addr_t ram_size;
extern ram_addr_t last_ram_offset;
extern uint8_t *bios_mem;
@@ -879,20 +881,104 @@ int cpu_memory_rw_debug(CPUState *env, target_ulong addr,
/* 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_vga_dirty[index] &
+ phys_ram_code_dirty[index] &
+ phys_ram_migration_dirty[index] & mask) == mask;
+}
+
+static inline int cpu_physical_memory_get_dirty_flags(ram_addr_t addr)
+{
+ 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_vga_dirty[index] & mask)
+ ret |= VGA_DIRTY_FLAG;
+ if (phys_ram_code_dirty[index] & mask)
+ ret |= CODE_DIRTY_FLAG;
+ if (phys_ram_migration_dirty[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;
+ return cpu_physical_memory_get_dirty_flags(addr) & dirty_flags;
}
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_vga_dirty[index] |= mask;
+ phys_ram_code_dirty[index] |= mask;
+ phys_ram_migration_dirty[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_vga_dirty[index] |= mask;
+ phys_ram_code_dirty[index] |= mask;
+ phys_ram_migration_dirty[index] |= mask;
}
+static inline void cpu_physical_memory_set_dirty_flags(ram_addr_t addr,
+ int 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_vga_dirty[index] |= mask;
+ if (dirty_flags & CODE_DIRTY_FLAG)
+ phys_ram_code_dirty[index] |= mask;
+ if (dirty_flags & MIGRATION_DIRTY_FLAG)
+ phys_ram_migration_dirty[index] |= mask;
+}
+
+static inline void cpu_physical_memory_mask_dirty_range(ram_addr_t start,
+ int length,
+ int dirty_flags)
+{
+ 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);
+
+ if (dirty_flags & VGA_DIRTY_FLAG)
+ phys_ram_vga_dirty[index] &= mask;
+ if (dirty_flags & CODE_DIRTY_FLAG)
+ phys_ram_code_dirty[index] &= mask;
+ if (dirty_flags & MIGRATION_DIRTY_FLAG)
+ phys_ram_migration_dirty[index] &= mask;
+ }
+}
+
+int cpu_physical_memory_get_dirty_range(ram_addr_t start, ram_addr_t end,
+ ram_addr_t *dirty_rams, int length,
+ int dirty_flags);
+
void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
int dirty_flags);
void cpu_tlb_update_dirty(CPUState *env);
--
1.7.0.31.g1df487
- [Qemu-devel] [PATCH 0/6] qemu-kvm: Introduce bit-based phys_ram_dirty, and bit-based dirty page checker., Yoshiaki Tamura, 2010/03/16
- [Qemu-devel] [PATCH 5/6] qemu-kvm: Use cpu_physical_memory_set_dirty_range() to update phys_ram_dirty., Yoshiaki Tamura, 2010/03/16
- [Qemu-devel] [PATCH 6/6] qemu-kvm: Use cpu_physical_memory_get_dirty_range() to check multiple dirty pages., Yoshiaki Tamura, 2010/03/16
- [Qemu-devel] [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty.,
Yoshiaki Tamura <=
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Avi Kivity, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Yoshiaki Tamura, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Avi Kivity, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Yoshiaki Tamura, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Anthony Liguori, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Avi Kivity, 2010/03/16
- [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Anthony Liguori, 2010/03/16
- Re: [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Blue Swirl, 2010/03/16
- Re: [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Richard Henderson, 2010/03/16
- Re: [Qemu-devel] Re: [PATCH 2/6] qemu-kvm: Modify and introduce wrapper functions to access phys_ram_dirty., Paul Brook, 2010/03/16