From patchwork Wed Mar 16 10:09:10 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Michael S. Tsirkin" X-Patchwork-Id: 87222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id 5163AB7009 for ; Wed, 16 Mar 2011 21:36:55 +1100 (EST) Received: from localhost ([127.0.0.1]:37829 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pzo0t-0001U0-VS for incoming@patchwork.ozlabs.org; Wed, 16 Mar 2011 06:31:36 -0400 Received: from [140.186.70.92] (port=43082 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PznfU-0008N1-M3 for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:09:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PznfT-00047s-A2 for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:09:28 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8685) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PznfT-00047l-1p for qemu-devel@nongnu.org; Wed, 16 Mar 2011 06:09:27 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p2GA9MvH030230 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 16 Mar 2011 06:09:23 -0400 Received: from redhat.com (vpn-200-120.tlv.redhat.com [10.35.200.120]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with SMTP id p2GA9ITb014808; Wed, 16 Mar 2011 06:09:19 -0400 Date: Wed, 16 Mar 2011 12:09:10 +0200 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org, Anthony Liguori , jmforbes@linuxtx.org, Juan Quintela , Alex Williamson , Jason Wang Message-ID: <20110316100909.GA12895@redhat.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.132.183.28 Cc: Subject: [Qemu-devel] [PATCH master,stable] vhost: fix dirty page handling X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org vhost was passing a physical address to cpu_physical_memory_set_dirty, which is wrong: we need to translate to ram address first. Signed-off-by: Michael S. Tsirkin Note: this lead to crashes during migration, so the patch is needed on the stable branch too. Reviewed-by: Juan Quintela Reviewed-by: Alex Williamson --- hw/vhost.c | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-) diff --git a/hw/vhost.c b/hw/vhost.c index aaa34e4..97a1299 100644 --- a/hw/vhost.c +++ b/hw/vhost.c @@ -49,8 +49,10 @@ static void vhost_dev_sync_region(struct vhost_dev *dev, log = __sync_fetch_and_and(from, 0); while ((bit = sizeof(log) > sizeof(int) ? ffsll(log) : ffs(log))) { + ram_addr_t ram_addr; bit -= 1; - cpu_physical_memory_set_dirty(addr + bit * VHOST_LOG_PAGE); + ram_addr = cpu_get_physical_page_desc(addr + bit * VHOST_LOG_PAGE); + cpu_physical_memory_set_dirty(ram_addr); log &= ~(0x1ull << bit); } addr += VHOST_LOG_CHUNK;