Replace direct phys_ram_dirty access with wrapper functions.

Replaces direct phys_ram_dirty access with wrapper functions to prevent
direct access to the phys_ram_dirty bitmap.

Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>
Signed-off-by: OHMURA Kei <ohmura.kei@lab.ntt.co.jp>
Reviewed-by: Avi Kivity <avi@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
master
Yoshiaki Tamura 2010-03-23 16:39:53 +09:00 committed by Aurelien Jarno
parent ca39b46e18
commit f7c11b5350
1 changed files with 20 additions and 25 deletions

45
exec.c
View File

@ -2030,7 +2030,7 @@ static void tlb_protect_code(ram_addr_t ram_addr)
static void tlb_unprotect_code_phys(CPUState *env, ram_addr_t ram_addr, static void tlb_unprotect_code_phys(CPUState *env, ram_addr_t ram_addr,
target_ulong vaddr) target_ulong vaddr)
{ {
phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] |= CODE_DIRTY_FLAG; cpu_physical_memory_set_dirty_flags(ram_addr, CODE_DIRTY_FLAG);
} }
static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry, static inline void tlb_reset_dirty_range(CPUTLBEntry *tlb_entry,
@ -2051,8 +2051,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
{ {
CPUState *env; CPUState *env;
unsigned long length, start1; unsigned long length, start1;
int i, mask, len; int i;
uint8_t *p;
start &= TARGET_PAGE_MASK; start &= TARGET_PAGE_MASK;
end = TARGET_PAGE_ALIGN(end); end = TARGET_PAGE_ALIGN(end);
@ -2060,11 +2059,7 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,
length = end - start; length = end - start;
if (length == 0) if (length == 0)
return; return;
len = length >> TARGET_PAGE_BITS; cpu_physical_memory_mask_dirty_range(start, length, dirty_flags);
mask = ~dirty_flags;
p = phys_ram_dirty + (start >> TARGET_PAGE_BITS);
for(i = 0; i < len; i++)
p[i] &= mask;
/* we modify the TLB cache so that the dirty bit will be set again /* we modify the TLB cache so that the dirty bit will be set again
when accessing the range */ when accessing the range */
@ -2986,16 +2981,16 @@ static void notdirty_mem_writeb(void *opaque, target_phys_addr_t ram_addr,
uint32_t val) uint32_t val)
{ {
int dirty_flags; int dirty_flags;
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
if (!(dirty_flags & CODE_DIRTY_FLAG)) { if (!(dirty_flags & CODE_DIRTY_FLAG)) {
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(ram_addr, 1); tb_invalidate_phys_page_fast(ram_addr, 1);
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
#endif #endif
} }
stb_p(qemu_get_ram_ptr(ram_addr), val); stb_p(qemu_get_ram_ptr(ram_addr), val);
dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags; cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
/* we remove the notdirty callback only if the code has been /* we remove the notdirty callback only if the code has been
flushed */ flushed */
if (dirty_flags == 0xff) if (dirty_flags == 0xff)
@ -3006,16 +3001,16 @@ static void notdirty_mem_writew(void *opaque, target_phys_addr_t ram_addr,
uint32_t val) uint32_t val)
{ {
int dirty_flags; int dirty_flags;
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
if (!(dirty_flags & CODE_DIRTY_FLAG)) { if (!(dirty_flags & CODE_DIRTY_FLAG)) {
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(ram_addr, 2); tb_invalidate_phys_page_fast(ram_addr, 2);
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
#endif #endif
} }
stw_p(qemu_get_ram_ptr(ram_addr), val); stw_p(qemu_get_ram_ptr(ram_addr), val);
dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags; cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
/* we remove the notdirty callback only if the code has been /* we remove the notdirty callback only if the code has been
flushed */ flushed */
if (dirty_flags == 0xff) if (dirty_flags == 0xff)
@ -3026,16 +3021,16 @@ static void notdirty_mem_writel(void *opaque, target_phys_addr_t ram_addr,
uint32_t val) uint32_t val)
{ {
int dirty_flags; int dirty_flags;
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
if (!(dirty_flags & CODE_DIRTY_FLAG)) { if (!(dirty_flags & CODE_DIRTY_FLAG)) {
#if !defined(CONFIG_USER_ONLY) #if !defined(CONFIG_USER_ONLY)
tb_invalidate_phys_page_fast(ram_addr, 4); tb_invalidate_phys_page_fast(ram_addr, 4);
dirty_flags = phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS]; dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
#endif #endif
} }
stl_p(qemu_get_ram_ptr(ram_addr), val); stl_p(qemu_get_ram_ptr(ram_addr), val);
dirty_flags |= (0xff & ~CODE_DIRTY_FLAG); dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
phys_ram_dirty[ram_addr >> TARGET_PAGE_BITS] = dirty_flags; cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
/* we remove the notdirty callback only if the code has been /* we remove the notdirty callback only if the code has been
flushed */ flushed */
if (dirty_flags == 0xff) if (dirty_flags == 0xff)
@ -3486,8 +3481,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,
/* invalidate code */ /* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + l, 0); tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
/* set dirty bit */ /* set dirty bit */
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |= cpu_physical_memory_set_dirty_flags(
(0xff & ~CODE_DIRTY_FLAG); addr1, (0xff & ~CODE_DIRTY_FLAG));
} }
} }
} else { } else {
@ -3693,8 +3688,8 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
/* invalidate code */ /* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + l, 0); tb_invalidate_phys_page_range(addr1, addr1 + l, 0);
/* set dirty bit */ /* set dirty bit */
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |= cpu_physical_memory_set_dirty_flags(
(0xff & ~CODE_DIRTY_FLAG); addr1, (0xff & ~CODE_DIRTY_FLAG));
} }
addr1 += l; addr1 += l;
access_len -= l; access_len -= l;
@ -3828,8 +3823,8 @@ void stl_phys_notdirty(target_phys_addr_t addr, uint32_t val)
/* invalidate code */ /* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0); tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */ /* set dirty bit */
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |= cpu_physical_memory_set_dirty_flags(
(0xff & ~CODE_DIRTY_FLAG); addr1, (0xff & ~CODE_DIRTY_FLAG));
} }
} }
} }
@ -3897,8 +3892,8 @@ void stl_phys(target_phys_addr_t addr, uint32_t val)
/* invalidate code */ /* invalidate code */
tb_invalidate_phys_page_range(addr1, addr1 + 4, 0); tb_invalidate_phys_page_range(addr1, addr1 + 4, 0);
/* set dirty bit */ /* set dirty bit */
phys_ram_dirty[addr1 >> TARGET_PAGE_BITS] |= cpu_physical_memory_set_dirty_flags(addr1,
(0xff & ~CODE_DIRTY_FLAG); (0xff & ~CODE_DIRTY_FLAG));
} }
} }
} }