From patchwork Mon Feb 4 10:40:57 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 217851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id D51B42C029D for ; Mon, 4 Feb 2013 21:47:47 +1100 (EST) Received: from localhost ([::1]:41251 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2JaT-0001um-OE for incoming@patchwork.ozlabs.org; Mon, 04 Feb 2013 05:47:45 -0500 Received: from eggs.gnu.org ([208.118.235.92]:52000) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2Ja9-0001ts-Sl for qemu-devel@nongnu.org; Mon, 04 Feb 2013 05:47:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1U2Ja8-0002TW-Me for qemu-devel@nongnu.org; Mon, 04 Feb 2013 05:47:25 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:47782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1U2Ja8-0002TJ-FE; Mon, 04 Feb 2013 05:47:24 -0500 Received: from gandalf.tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by isrv.corpit.ru (Postfix) with ESMTP id A59EEA03EF; Mon, 4 Feb 2013 14:47:23 +0400 (MSK) Received: by gandalf.tls.msk.ru (Postfix, from userid 1000) id 3BDA6543; Mon, 4 Feb 2013 14:41:29 +0400 (MSK) From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 4 Feb 2013 14:40:57 +0400 Message-Id: <1359974470-17044-48-git-send-email-mjt@msgid.tls.msk.ru> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1359974470-17044-1-git-send-email-mjt@msgid.tls.msk.ru> References: <1359974470-17044-1-git-send-email-mjt@msgid.tls.msk.ru> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 86.62.121.231 Cc: Alexey Kardashevskiy , qemu-stable@nongnu.org, Alexander Graf Subject: [Qemu-devel] [PATCH 47/60] kvm: fix incorrect length in a loop over kvm dirty pages map X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Alexey Kardashevskiy 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 Signed-off-by: Alexander Graf (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; /*