From mboxrd@z Thu Jan 1 00:00:00 1970 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 From: Stefano Stabellini Date: Mon, 13 Jun 2016 11:57:06 +0100 Message-Id: <1465815427-22041-1-git-send-email-sstabellini@kernel.org> In-Reply-To: References: Subject: [Qemu-devel] [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter.maydell@linaro.org Cc: sstabellini@kernel.org, qemu-devel@nongnu.org, anthony.perard@citrix.com, xen-devel@lists.xen.org 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; -- 1.9.1