cryptospore / rpms / qemu-kvm

Forked from rpms/qemu-kvm 2 years ago
Clone

Blame SOURCES/kvm-memory-make-cpu_physical_memory_is_dirty-return-bool.patch

9ae3a8
From 478863d3d5428211d0d64a9928484e0b1f5be8a4 Mon Sep 17 00:00:00 2001
9ae3a8
From: Juan Quintela <quintela@redhat.com>
9ae3a8
Date: Tue, 14 Jan 2014 15:07:19 +0100
9ae3a8
Subject: [PATCH 08/40] memory: make cpu_physical_memory_is_dirty return bool
9ae3a8
9ae3a8
RH-Author: Juan Quintela <quintela@redhat.com>
9ae3a8
Message-id: <1389712071-23303-9-git-send-email-quintela@redhat.com>
9ae3a8
Patchwork-id: 56664
9ae3a8
O-Subject: [RHEL7 qemu-kvm PATCH 08/40] memory: make cpu_physical_memory_is_dirty return bool
9ae3a8
Bugzilla: 997559
9ae3a8
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
9ae3a8
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
RH-Acked-by: Dr. David Alan Gilbert (git) <dgilbert@redhat.com>
9ae3a8
9ae3a8
Signed-off-by: Juan Quintela <quintela@redhat.com>
9ae3a8
Reviewed-by: Eric Blake <eblake@redhat.com>
9ae3a8
Reviewed-by: Orit Wasserman <owasserm@redhat.com>
9ae3a8
(cherry picked from commit 4f08cabe9e6efe8a50abc30cfa59e8470ad434d7)
9ae3a8
Signed-off-by: Juan Quintela <quintela@trasno.org>
9ae3a8
---
9ae3a8
 exec.c                         | 7 ++-----
9ae3a8
 include/exec/memory-internal.h | 8 ++++++--
9ae3a8
 2 files changed, 8 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
9ae3a8
---
9ae3a8
 exec.c                         |    7 ++-----
9ae3a8
 include/exec/memory-internal.h |    8 ++++++--
9ae3a8
 2 files changed, 8 insertions(+), 7 deletions(-)
9ae3a8
9ae3a8
diff --git a/exec.c b/exec.c
9ae3a8
index e993049..ea81329 100644
9ae3a8
--- a/exec.c
9ae3a8
+++ b/exec.c
9ae3a8
@@ -1480,11 +1480,8 @@ static const MemoryRegionOps rom_mem_ops = {
9ae3a8
 static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
9ae3a8
                                uint64_t val, unsigned size)
9ae3a8
 {
9ae3a8
-    int dirty_flags;
9ae3a8
-    dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
9ae3a8
     if (!cpu_physical_memory_get_dirty_flag(ram_addr, CODE_DIRTY_FLAG)) {
9ae3a8
         tb_invalidate_phys_page_fast(ram_addr, size);
9ae3a8
-        dirty_flags = cpu_physical_memory_get_dirty_flags(ram_addr);
9ae3a8
     }
9ae3a8
     switch (size) {
9ae3a8
     case 1:
9ae3a8
@@ -1499,8 +1496,8 @@ static void notdirty_mem_write(void *opaque, hwaddr ram_addr,
9ae3a8
     default:
9ae3a8
         abort();
9ae3a8
     }
9ae3a8
-    dirty_flags |= (0xff & ~CODE_DIRTY_FLAG);
9ae3a8
-    cpu_physical_memory_set_dirty_flags(ram_addr, dirty_flags);
9ae3a8
+    cpu_physical_memory_set_dirty_flag(ram_addr, MIGRATION_DIRTY_FLAG);
9ae3a8
+    cpu_physical_memory_set_dirty_flag(ram_addr, VGA_DIRTY_FLAG);
9ae3a8
     /* we remove the notdirty callback only if the code has been
9ae3a8
        flushed */
9ae3a8
     if (cpu_physical_memory_is_dirty(ram_addr))
9ae3a8
diff --git a/include/exec/memory-internal.h b/include/exec/memory-internal.h
9ae3a8
index 8872e36..dfc03e1 100644
9ae3a8
--- a/include/exec/memory-internal.h
9ae3a8
+++ b/include/exec/memory-internal.h
9ae3a8
@@ -65,9 +65,13 @@ static inline bool cpu_physical_memory_get_dirty_flag(ram_addr_t addr,
9ae3a8
 }
9ae3a8
 
9ae3a8
 /* read dirty bit (return 0 or 1) */
9ae3a8
-static inline int cpu_physical_memory_is_dirty(ram_addr_t addr)
9ae3a8
+static inline bool cpu_physical_memory_is_dirty(ram_addr_t addr)
9ae3a8
 {
9ae3a8
-    return cpu_physical_memory_get_dirty_flags(addr) == 0xff;
9ae3a8
+    bool vga = cpu_physical_memory_get_dirty_flag(addr, VGA_DIRTY_FLAG);
9ae3a8
+    bool code = cpu_physical_memory_get_dirty_flag(addr, CODE_DIRTY_FLAG);
9ae3a8
+    bool migration =
9ae3a8
+        cpu_physical_memory_get_dirty_flag(addr, MIGRATION_DIRTY_FLAG);
9ae3a8
+    return vga && code && migration;
9ae3a8
 }
9ae3a8
 
9ae3a8
 static inline int cpu_physical_memory_get_dirty(ram_addr_t start,
9ae3a8
-- 
9ae3a8
1.7.1
9ae3a8