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: 9172683 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 43221604DB for ; Mon, 13 Jun 2016 10:59:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 35596200E7 for ; Mon, 13 Jun 2016 10:59:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28BD927AC2; Mon, 13 Jun 2016 10:59:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A4A83200E7 for ; Mon, 13 Jun 2016 10:59:30 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCPYV-0003Gs-Ii; Mon, 13 Jun 2016 10:57:19 +0000 Received: from mail6.bemta14.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bCPYT-0003Gh-Lq for xen-devel@lists.xen.org; Mon, 13 Jun 2016 10:57:17 +0000 Received: from [193.109.254.147] by server-8.bemta-14.messagelabs.com id 6E/8C-26731-D819E575; Mon, 13 Jun 2016 10:57:17 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrBLMWRWlGSWpSXmKPExsVybKJsh27PxLh wg81tShZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8b/HbvZC+5yVHyZ/5upgbGDvYuRk0NIYCqj xN5rTl2MXEB2L5PEnLm3WEESbAKGEn+fbGIDsUUEZCQ6Ly1i7GLk4GAWyJC4trcGJCwsYCexs OcYC4jNIqAq8fbhN7CZvAJuEmeefmAGsSUE5CROHpsMNpJTwFvixbRmqL1eEg0rZ7FB1GRIzO uZwwphe0ksunEJylaTuHpuE/MERr4FjAyrGNWLU4vKUot0jfWSijLTM0pyEzNzdA0NTfRyU4u LE9NTcxKTivWS83M3MQJDhAEIdjDe7XM+xCjJwaQkyivhExcuxJeUn1KZkVicEV9UmpNafIhR hoNDSYJXfQJQTrAoNT21Ii0zBxisMGkJDh4lEd56kDRvcUFibnFmOkTqFKOilDjvl36ghABII qM0D64NFiGXGGWlhHkZgQ4R4ilILcrNLEGVf8UozsGoJMxrCDKeJzOvBG76K6DFTECLOfZFgy wuSURISTUwthkerIh/dOPv3eQvi+Ucoo94rOXlDr7EtPLg8RPT+KcITJw29XnAobz/e93vP5Q rNrn1dmvVgn+5H/8LHzzv25gdF2h8RPb2xSqn67PMtoue3yH+8cTOe1OSJynUlEQ9Ln4a5H2i dFdO39XaL0bdzbIWglLXp0xkvHArP+1N7oFr3WtKrkwvm6bEUpyRaKjFXFScCAB6qOzLiwIAA A== X-Env-Sender: sstabellini@kernel.org X-Msg-Ref: server-15.tower-27.messagelabs.com!1465815435!47396057!1 X-Originating-IP: [198.145.29.136] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 8.46; banners=-,-,- X-VirusChecked: Checked Received: (qmail 58019 invoked from network); 13 Jun 2016 10:57:16 -0000 Received: from mail.kernel.org (HELO mail.kernel.org) (198.145.29.136) by server-15.tower-27.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 13 Jun 2016 10:57:16 -0000 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 Cc: anthony.perard@citrix.com, sstabellini@kernel.org, qemu-devel@nongnu.org, xen-devel@lists.xen.org Subject: [Xen-devel] [PULL 1/2] exec: Fix qemu_ram_block_from_host for Xen X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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;