qemu-devel
[Top][All Lists]
Advanced

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

[Qemu-devel] [PATCH 47/60] kvm: fix incorrect length in a loop over kvm


From: Michael Tokarev
Subject: [Qemu-devel] [PATCH 47/60] kvm: fix incorrect length in a loop over kvm dirty pages map
Date: Mon, 4 Feb 2013 14:40:57 +0400

From: Alexey Kardashevskiy <address@hidden>

QEMU allocates a map enough for 4k pages. However the system page size
can be 64K (for example on POWER) and the host kernel uses only a small
part of it as one big stores a dirty flag for 16 pages 4K each,
the hpratio variable stores this ratio and
the kvm_get_dirty_pages_log_range function handles it correctly.

However kvm_get_dirty_pages_log_range still goes beyond the data
provided by the host kernel which is not correct. It does not cause
errors at the moment as the whole bitmap is zeroed before doing KVM ioctl.

The patch reduces number of iterations over the map.

Signed-off-by: Alexey Kardashevskiy <address@hidden>
Signed-off-by: Alexander Graf <address@hidden>
(cherry picked from commit 752ced0488806830f18f96b60ae6f3d1fadfd089)

Conflicts:
        kvm-all.c
---
 kvm-all.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/kvm-all.c b/kvm-all.c
index 9b73ccf..e92dc6f 100644
--- a/kvm-all.c
+++ b/kvm-all.c
@@ -347,7 +347,7 @@ static int 
kvm_get_dirty_pages_log_range(MemoryRegionSection *section,
     unsigned int i, j;
     unsigned long page_number, c;
     target_phys_addr_t addr, addr1;
-    unsigned int len = ((section->size / TARGET_PAGE_SIZE) + HOST_LONG_BITS - 
1) / HOST_LONG_BITS;
+    unsigned int len = ((section->size / getpagesize()) + HOST_LONG_BITS - 1) 
/ HOST_LONG_BITS;
     unsigned long hpratio = getpagesize() / TARGET_PAGE_SIZE;
 
     /*
-- 
1.7.10.4




reply via email to

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