From patchwork Mon Jun 13 10:57:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefano Stabellini X-Patchwork-Id: 634564 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rSr0D21Nmz9snl for ; Mon, 13 Jun 2016 21:19:40 +1000 (AEST) Received: from localhost ([::1]:55432 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCPu5-0000gz-Rh for incoming@patchwork.ozlabs.org; Mon, 13 Jun 2016 07:19:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCPYW-00064s-Nj for qemu-devel@nongnu.org; Mon, 13 Jun 2016 06:57:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bCPYR-0003ca-MS for qemu-devel@nongnu.org; Mon, 13 Jun 2016 06:57:20 -0400 Received: from mail.kernel.org ([198.145.29.136]:51612) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bCPYR-0003cW-GY for qemu-devel@nongnu.org; Mon, 13 Jun 2016 06:57:15 -0400 Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5C8F62010F; Mon, 13 Jun 2016 10:57:14 +0000 (UTC) Received: from localhost.localdomain (60.99.208.46.dyn.plus.net [46.208.99.60]) (using TLSv1.2 with cipher AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 801E220109; Mon, 13 Jun 2016 10:57:12 +0000 (UTC) From: Stefano Stabellini To: peter.maydell@linaro.org Date: Mon, 13 Jun 2016 11:57:06 +0100 Message-Id: <1465815427-22041-1-git-send-email-sstabellini@kernel.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: References: X-Virus-Scanned: ClamAV using ClamSMTP X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 198.145.29.136 Subject: [Qemu-devel] [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: anthony.perard@citrix.com, sstabellini@kernel.org, qemu-devel@nongnu.org, xen-devel@lists.xen.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Anthony PERARD Since f615f39 (exec: remove ram_addr argument from qemu_ram_block_from_host), migration under Xen is likely to fail, with a SEGV of QEMU. But the commit only reveal a bug with the calculation of the offset value in qemu_ram_block_from_host(). This patch calculates the offset from the ram_addr as qemu_ram_addr_from_host() will later calculate the ram_addr from the offset. Signed-off-by: Anthony PERARD Acked-by: Paolo Bonzini Signed-off-by: Stefano Stabellini --- exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/exec.c b/exec.c index a9d465b..4f3818c 100644 --- a/exec.c +++ b/exec.c @@ -1935,7 +1935,7 @@ RAMBlock *qemu_ram_block_from_host(void *ptr, bool round_offset, ram_addr = xen_ram_addr_from_mapcache(ptr); block = qemu_get_ram_block(ram_addr); if (block) { - *offset = (host - block->host); + *offset = ram_addr - block->offset; } rcu_read_unlock(); return block;