Blame SOURCES/kvm-memory-make-cpu_physical_memory_reset_dirty-take-a-l.patch

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