From patchwork Fri Nov 24 04:23:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suraj Jitindar Singh X-Patchwork-Id: 10073513 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 D13C360383 for ; Fri, 24 Nov 2017 04:26:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D3F3F2A302 for ; Fri, 24 Nov 2017 04:26:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C77FC2A346; Fri, 24 Nov 2017 04:26:35 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 5B18F2A302 for ; Fri, 24 Nov 2017 04:26:35 +0000 (UTC) Received: from localhost ([::1]:47206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI5ZS-0003pD-4w for patchwork-qemu-devel@patchwork.kernel.org; Thu, 23 Nov 2017 23:26:34 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33326) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI5Wh-0002Rr-Qv for qemu-devel@nongnu.org; Thu, 23 Nov 2017 23:23:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eI5Wh-0005Xd-2F for qemu-devel@nongnu.org; Thu, 23 Nov 2017 23:23:43 -0500 Received: from mail-pl0-x244.google.com ([2607:f8b0:400e:c01::244]:35533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eI5Wf-0005WK-3P; Thu, 23 Nov 2017 23:23:41 -0500 Received: by mail-pl0-x244.google.com with SMTP id 62so3737389plc.2; Thu, 23 Nov 2017 20:23:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=3AsELOrpZBwKmXI41L50Qh6hh7DM0zpePE+uAyM2c/s=; b=E58LjiQJ5F61HjK2PTwSrKLhy1mzaWImkNiPjScuqkT7VfxVFRKyHExCwRZ/bmNhA+ 8qNdgs8FiNFBqcEXvp/wtwfeasYAKXEclnofsQrplV7MeDPksrgEtLbO1e/FBkaZGdoY PH8mewFMb0cKA5lzghJguPVDOmNuPUdjBUpagf1svWXYps4qqdhBcwuAKTANdUyrlxrm LsD+TVUcNf1cSC4rt53PbKWJsKKiTTu22v/DCQmibosL+MgzhSZT23GHTYOMFSMwBN7Y vhlaPD1pRCXL6Ao6NSImKOaylLtKbwCUy3QXpvnoXU0J5XipAyN76G4o7G9c75MI0Hrg smsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=3AsELOrpZBwKmXI41L50Qh6hh7DM0zpePE+uAyM2c/s=; b=mnW7wuqtizBdU7Fi+3Mhv1nGzcZ2QrZEYPiQHIvluJ4ggArPw5nk8BZ1ZMbOckioxZ kpgClQardDN9rGA2tImee+WerZpqk2aRk5lEwzLV7d2oA1E3lbFck+hFW0BIvN3tctpH eVgmJxfn8MAkMlEuWxE5PiDzWuDnD1vgr6ajI1cL8Zj+IssJXyK2a+EdZ0ZYCAb7LlGp qGULPTIDe+mXn0tKjE5HZGtQ+kNBoLRDAsjVrHK4Be1wybUYdTP0bCzXDQu9HO2YTU+g Ry62WYLgsBrrnyx8nbnDU1uJy8ODt9mbx+syGgDpQw2vPcMmJ16EtCZ6q8sBhzIXjrRl c+XQ== X-Gm-Message-State: AJaThX7UU5jWCNq/+qOTg6g1bZL+t9VzRrqiEP2wi5Anh3D5NY+UlA7e 4fZ0l4ZpBlfXP+gQn43IXaR03niQ X-Google-Smtp-Source: AGs4zMaod8ZsTvBp8hU+4+vv7bjN7/JEeoFYIjODBEDRfB/3girWQI2DUZlETriD15Ck9MoP+R/Osw== X-Received: by 10.84.252.23 with SMTP id x23mr27789729pll.54.1511497420078; Thu, 23 Nov 2017 20:23:40 -0800 (PST) Received: from surajjs1.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id f70sm40214287pfc.84.2017.11.23.20.23.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 20:23:39 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 24 Nov 2017 15:23:25 +1100 Message-Id: <20171124042325.28012-3-sjitindarsingh@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171124042325.28012-1-sjitindarsingh@gmail.com> References: <20171124042325.28012-1-sjitindarsingh@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::244 Subject: [Qemu-devel] [QEMU-PPC] [PATCH 2/2] target/ppc: Fix setting of cpu->compat_pvr on incoming migration 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: groug@kaod.org, qemu-devel@nongnu.org, sjitindarsingh@gmail.com, david@gibson.dropbear.id.au Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP cpu->compat_pvr is used to store the current compat mode of the cpu. On the receiving side during incoming migration we check compatibility with the compat mode by calling ppc_set_compat(). However we fail to set the compat mode with the hypervisor since the "new" compat mode doesn't differ from the current (due to a "cpu->compat_pvr != compat_pvr" check). This means that kvm runs the vcpus without a compat mode, which is the incorrect behaviour. The implication being that a compatibility mode will never be in effect after migration. To fix this so that the compat mode is correctly set with the hypervisor, store the desired compat mode and reset cpu->compat_pvr to zero before calling ppc_set_compat(). Fixes: 5dfaa532 ("ppc: fix ppc_set_compat() with KVM PR") Signed-off-by: Suraj Jitindar Singh --- It is worth noting that another option was to add a force flag to the ppc_set_compat() function, but the enacted solution seemed cleaner with fewer code changes. --- target/ppc/machine.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/target/ppc/machine.c b/target/ppc/machine.c index 384caee800..24117e8f31 100644 --- a/target/ppc/machine.c +++ b/target/ppc/machine.c @@ -237,9 +237,11 @@ static int cpu_post_load(void *opaque, int version_id) #if defined(TARGET_PPC64) if (cpu->compat_pvr) { + uint32_t compat_pvr = cpu->compat_pvr; Error *local_err = NULL; - ppc_set_compat(cpu, cpu->compat_pvr, &local_err); + cpu->compat_pvr = 0; + ppc_set_compat(cpu, compat_pvr, &local_err); if (local_err) { error_report_err(local_err); return -1;