qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH] exec-obsolete: fix length handling


From: Blue Swirl
Subject: [Qemu-devel] [PATCH] exec-obsolete: fix length handling
Date: Sat, 28 Jan 2012 18:13:45 +0000

Fix suspend/resume broken by off-by-one error in
59abb06198ee9471e29c970f294eae80c0b39be1.

Adjust the loop so that it handles correctly the case
start = (ram_addr_t)-TARGET_PAGE_SIZE, length = TARGET_PAGE_SIZE.

Reported-by: Stefan Berger <address@hidden>
Signed-off-by: Blue Swirl <address@hidden>
---
 exec-obsolete.h |   10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/exec-obsolete.h b/exec-obsolete.h
index 03cf35e..1bba970 100644
--- a/exec-obsolete.h
+++ b/exec-obsolete.h
@@ -81,11 +81,10 @@ static inline void
cpu_physical_memory_set_dirty_range(ram_addr_t start,
                                                        int dirty_flags)
 {
     uint8_t *p;
-    ram_addr_t addr, end;
+    ram_addr_t cur;

-    end = start + length;
     p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
-    for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) {
+    for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) {
         *p++ |= dirty_flags;
     }
 }
@@ -96,12 +95,11 @@ static inline void
cpu_physical_memory_mask_dirty_range(ram_addr_t start,
 {
     int mask;
     uint8_t *p;
-    ram_addr_t addr, end;
+    ram_addr_t cur;

-    end = start + length;
     mask = ~dirty_flags;
     p = ram_list.phys_dirty + (start >> TARGET_PAGE_BITS);
-    for (addr = start; addr <= end; addr += TARGET_PAGE_SIZE) {
+    for (cur = 0; cur < length; cur += TARGET_PAGE_SIZE) {
         *p++ &= mask;
     }
 }
-- 
1.7.9.rc0

Attachment: 0001-exec-obsolete-fix-length-handling.patch
Description: Text Data


reply via email to

[Prev in Thread] Current Thread [Next in Thread]