From 60aa55e63ee56107ed2fd639b08ee166ca0b6264 Mon Sep 17 00:00:00 2001 From: Juan Quintela Date: Tue, 14 Jan 2014 15:07:40 +0100 Subject: [PATCH 29/40] memory: make cpu_physical_memory_reset_dirty() take a length parameter RH-Author: Juan Quintela Message-id: <1389712071-23303-30-git-send-email-quintela@redhat.com> Patchwork-id: 56683 O-Subject: [RHEL7 qemu-kvm PATCH 29/40] memory: make cpu_physical_memory_reset_dirty() take a length parameter Bugzilla: 997559 RH-Acked-by: Paolo Bonzini RH-Acked-by: Orit Wasserman RH-Acked-by: Dr. David Alan Gilbert (git) We have an end parameter in all the callers, and this make it coherent with the rest of cpu_physical_memory_* functions, that also take a length parameter. Once here, move the start/end calculation to tlb_reset_dirty_range_all() as we don't need it here anymore. Signed-off-by: Juan Quintela Reviewed-by: Eric Blake Reviewed-by: Orit Wasserman (cherry picked from commit a2f4d5bef2cfde557d76fc45a40d2c89b6bed4e4) Conflicts: exec.c Missing upstream commit: commit 041603fe5d4537cd165941f96bd76a31f7f662fd Author: Paolo Bonzini Date: Mon Sep 9 17:49:45 2013 +0200 exec: remove qemu_safe_ram_ptr Signed-off-by: Juan Quintela --- cputlb.c | 3 +-- exec.c | 19 ++++++++----------- include/exec/memory-internal.h | 2 +- memory.c | 8 ++------ 4 files changed, 12 insertions(+), 20 deletions(-) Signed-off-by: Miroslav Rezanina --- cputlb.c | 3 +-- exec.c | 19 ++++++++----------- include/exec/memory-internal.h | 2 +- memory.c | 8 ++------ 4 files changed, 12 insertions(+), 20 deletions(-) diff --git a/cputlb.c b/cputlb.c index 04d7f14..44ec9bc 100644 --- a/cputlb.c +++ b/cputlb.c @@ -127,8 +127,7 @@ void tlb_flush_page(CPUArchState *env, target_ulong addr) can be detected */ void tlb_protect_code(ram_addr_t ram_addr) { - cpu_physical_memory_reset_dirty(ram_addr, - ram_addr + TARGET_PAGE_SIZE, + cpu_physical_memory_reset_dirty(ram_addr, TARGET_PAGE_SIZE, DIRTY_MEMORY_CODE); } diff --git a/exec.c b/exec.c index ec01b0f..79ea3b2 100644 --- a/exec.c +++ b/exec.c @@ -576,10 +576,13 @@ CPUArchState *cpu_copy(CPUArchState *env) } #if !defined(CONFIG_USER_ONLY) -static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t end, - uintptr_t length) +static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t length) { - uintptr_t start1; + ram_addr_t start1; + ram_addr_t end; + + end = TARGET_PAGE_ALIGN(start + length); + start &= TARGET_PAGE_MASK; /* we modify the TLB cache so that the dirty bit will be set again when accessing the range */ @@ -595,21 +598,15 @@ static void tlb_reset_dirty_range_all(ram_addr_t start, ram_addr_t end, } /* Note: start and end must be within the same ram block. */ -void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, +void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length, unsigned client) { - uintptr_t length; - - start &= TARGET_PAGE_MASK; - end = TARGET_PAGE_ALIGN(end); - - length = end - start; if (length == 0) return; cpu_physical_memory_clear_dirty_range(start, length, client); if (tcg_enabled()) { - tlb_reset_dirty_range_all(start, end, length); + tlb_reset_dirty_range_all(start, length); } } diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h index 416ce86..d2b85de 100644 --- a/include/exec/memory-internal.h +++ b/include/exec/memory-internal.h @@ -111,7 +111,7 @@ static inline void cpu_physical_memory_clear_dirty_range(ram_addr_t start, bitmap_clear(ram_list.dirty_memory[client], page, end - page); } -void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end, +void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t length, unsigned client); extern const IORangeOps memory_region_iorange_ops; diff --git a/memory.c b/memory.c index 2883da5..b49642b 100644 --- a/memory.c +++ b/memory.c @@ -1087,9 +1087,7 @@ bool memory_region_test_and_clear_dirty(MemoryRegion *mr, hwaddr addr, assert(mr->terminates); ret = cpu_physical_memory_get_dirty(mr->ram_addr + addr, size, client); if (ret) { - cpu_physical_memory_reset_dirty(mr->ram_addr + addr, - mr->ram_addr + addr + size, - client); + cpu_physical_memory_reset_dirty(mr->ram_addr + addr, size, client); } return ret; } @@ -1133,9 +1131,7 @@ void memory_region_reset_dirty(MemoryRegion *mr, hwaddr addr, hwaddr size, unsigned client) { assert(mr->terminates); - cpu_physical_memory_reset_dirty(mr->ram_addr + addr, - mr->ram_addr + addr + size, - client); + cpu_physical_memory_reset_dirty(mr->ram_addr + addr, size, client); } void *memory_region_get_ram_ptr(MemoryRegion *mr) -- 1.7.1