From patchwork Tue Nov 20 01:40:47 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kardashevskiy X-Patchwork-Id: 200226 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 EE4FA2C0087 for ; Tue, 20 Nov 2012 12:41:11 +1100 (EST) Received: from localhost ([::1]:54572 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tacpo-0000tc-22 for incoming@patchwork.ozlabs.org; Mon, 19 Nov 2012 20:41:08 -0500 Received: from eggs.gnu.org ([208.118.235.92]:43416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tacpg-0000rx-G5 for qemu-devel@nongnu.org; Mon, 19 Nov 2012 20:41:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Tacpf-0001p1-7s for qemu-devel@nongnu.org; Mon, 19 Nov 2012 20:41:00 -0500 Received: from mail-pa0-f45.google.com ([209.85.220.45]:53089) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tacpf-0001oj-1q for qemu-devel@nongnu.org; Mon, 19 Nov 2012 20:40:59 -0500 Received: by mail-pa0-f45.google.com with SMTP id bg2so1324147pad.4 for ; Mon, 19 Nov 2012 17:40:57 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:x-gm-message-state; bh=Fax0+wAvFWzQDuSLIeEja0SPyLQ5+HkHEydezUuMXxI=; b=JaD7Hcn/K42RvDQvEBqYlurxtlW7UGCTIjTRTHy3IkuIjcZ74TSMDtKbVWr5Q/XLtF XHaBvrVNXJ3QmLrALQ/G5fpBLA0sioDJzpF2L0YlaX3aAFbfJN/YV9lcqsmmpZDcE0G8 HArZRLaiDef5WJt+SP+Mx2JKZf4zxADv/4M1chfJnwFnkZ3CMe+CPFT01BTBLV+igZhW Q0lFQARBK9UiutGFGs7o/j90gKvYmaYbqip7tXtxLRTNPpMLj5CQDN9P8oBfbxtUqFYu hyKF650DNMjsKsssyYEEWBLlLi1Z8P4nIhdMCzMj31iFM2c5HeH+bDWUrTHjW5CmTMr/ WS+w== Received: by 10.68.239.232 with SMTP id vv8mr38293999pbc.53.1353375657106; Mon, 19 Nov 2012 17:40:57 -0800 (PST) Received: from ka1.ozlabs.ibm.com (ibmaus65.lnk.telstra.net. [165.228.126.9]) by mx.google.com with ESMTPS id uq5sm7098102pbc.56.2012.11.19.17.40.53 (version=TLSv1/SSLv3 cipher=OTHER); Mon, 19 Nov 2012 17:40:55 -0800 (PST) From: Alexey Kardashevskiy To: qemu-ppc@nongnu.org, qemu-devel@nongnu.org Date: Tue, 20 Nov 2012 12:40:47 +1100 Message-Id: <1353375647-31268-1-git-send-email-aik@ozlabs.ru> X-Mailer: git-send-email 1.7.10.4 X-Gm-Message-State: ALoCoQlipOZCaUqVvWJS4v01A2TCFlW8Vp4UH0gLsbOE97P3nuAyuvK/NgejHpZuUC9VYdqHKUpK X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [fuzzy] X-Received-From: 209.85.220.45 Cc: Alexey Kardashevskiy Subject: [Qemu-devel] [PATCH] 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 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 --- kvm-all.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kvm-all.c b/kvm-all.c index b6d0483..c99997f 100644 --- a/kvm-all.c +++ b/kvm-all.c @@ -364,7 +364,7 @@ static int kvm_get_dirty_pages_log_range(MemoryRegionSection *section, unsigned int i, j; unsigned long page_number, c; hwaddr 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; /*