From nobody Mon May 6 14:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1511497519677204.01326631862526; Thu, 23 Nov 2017 20:25:19 -0800 (PST) Received: from localhost ([::1]:47196 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI5Y5-00034T-CQ for importer@patchew.org; Thu, 23 Nov 2017 23:25:09 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33281) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI5Wf-0002Pg-7h for qemu-devel@nongnu.org; Thu, 23 Nov 2017 23:23:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eI5We-0005W4-B6 for qemu-devel@nongnu.org; Thu, 23 Nov 2017 23:23:41 -0500 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:38533) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eI5Wc-0005U4-BR; Thu, 23 Nov 2017 23:23:38 -0500 Received: by mail-pl0-x241.google.com with SMTP id s10so3741531plj.5; Thu, 23 Nov 2017 20:23:38 -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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Nov 2017 20:23:36 -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=eJ84sSP2qWTkfMjT64yvlDis7nQK9Yz9PIPQxV3MYu4=; b=uMuab5fVlYD1+rRn/vA82htEcAH+WSqMZn8wXf0zzyNbsjarK1fti3H1yNDF6ePLYd ML1sueUCqt5PzQYWvSApLMhjUs03BdyVhsGYkNUC5pu1FSwu6wUXR/lGhOie3ic+KulD cW+fB+ZikbjTMNR6KcbT2aY6MdMI/P4UgSvIROvpYYSPc6NSBb7kbkNId9gjoDhSqjEa dmY2bQVnZZK+GSl2JAgq68docCkNCpwcPg0r4o1RAyBIcTxeTOHBArJ7KJTx66OlQRGG iIuAVPZGPLhOS+NKeheDsw0uDl6cPndUwA0e+HojjV7S2EfUqk8aZeVz8cXD7LCsQ50o E90A== 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=eJ84sSP2qWTkfMjT64yvlDis7nQK9Yz9PIPQxV3MYu4=; b=PMe/z//XsERtqOixTF4LY2rsYW0ltwQwsZ9Xge62jatTgMxicH85nmxNr6sGMhDte6 1CeIEXEVOO+HBVbPG06OvaX5W774ry3RO7qf9xY7okld2Ssm5ZoPKHVSg2sAE+kitrml GD7ilASzJspIHKN7dmpkheHN/AyA8FhWA80f9w5uCJgJBye1UrX4z/+85r8DOjKRvpfH azh5xxovRLpe7/LG7uV0sMfkXpTXF5+xPOFMcAyf3KdgxcaTd1SzugoHcGjrlOuLUsVv MxvbTSu9VtsPU49IrqenqdIjfCfmoMASVme4FQTW8Zf/vU1dN9e3axmZsgj+yGE5lPYj 4TXw== X-Gm-Message-State: AJaThX6mdM1gvVpEal/CvYEvKmS70KgOIoHKIf49gGz5DG4kN9xQmPg5 3sW38dMELrazv+RJODHqIljYd1he X-Google-Smtp-Source: AGs4zMbixTWq8GY6E5usmPlgLbWFOO7IUUL/XN74g5EeIOvAdKh/9iFwVI25ek7eJ2nb9L4eSRUX9A== X-Received: by 10.84.133.15 with SMTP id 15mr26907393plf.367.1511497417284; Thu, 23 Nov 2017 20:23:37 -0800 (PST) From: Suraj Jitindar Singh To: qemu-ppc@nongnu.org Date: Fri, 24 Nov 2017 15:23:24 +1100 Message-Id: <20171124042325.28012-2-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::241 Subject: [Qemu-devel] [QEMU-PPC] [PATCH 1/2] target/ppc: Move setting of patb_entry on hash table init 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" The patb_entry is used to store the location of the process table in guest memory. The msb is also used to indicate the mmu mode of the guest, that is patb_entry & 1 << 63 ? radix_mode : hash_mode. Currently we set this to zero in spapr_setup_hpt_and_vrma() since if this function gets called then we know we're hash. However some code paths, such as setting up the hpt on incoming migration of a hash guest, call spapr_reallocate_hpt() directly bypassing this higher level function. Since we assume radix if the host is capable this results in the msb in patb_entry being left set so in spapr_post_load() we call kvmppc_configure_v3_mmu() and tell the host we're radix which as expected means addresses cannot be translated once we actually run the cpu. To fix this move the zeroing of patb_entry into spapr_reallocate_hpt(). Signed-off-by: Suraj Jitindar Singh Reviewed-by: Greg Kurz --- hw/ppc/spapr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 6841bd294b..e7af47bab0 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1373,6 +1373,8 @@ void spapr_reallocate_hpt(sPAPRMachineState *spapr, i= nt shift, DIRTY_HPTE(HPTE(spapr->htab, i)); } } + /* We're setting up a hash table, so that means we're not radix */ + spapr->patb_entry =3D 0; } =20 void spapr_setup_hpt_and_vrma(sPAPRMachineState *spapr) @@ -1392,8 +1394,6 @@ void spapr_setup_hpt_and_vrma(sPAPRMachineState *spap= r) spapr->rma_size =3D kvmppc_rma_size(spapr_node0_size(MACHINE(spapr= )), spapr->htab_shift); } - /* We're setting up a hash table, so that means we're not radix */ - spapr->patb_entry =3D 0; } =20 static void find_unknown_sysbus_device(SysBusDevice *sbdev, void *opaque) --=20 2.13.6 From nobody Mon May 6 14:18:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 151149761419983.72997537634228; Thu, 23 Nov 2017 20:26:54 -0800 (PST) Received: from localhost ([::1]:47207 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eI5Zi-000477-9o for importer@patchew.org; Thu, 23 Nov 2017 23:26:50 -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) 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) 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) 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+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 !=3D 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) =20 #if defined(TARGET_PPC64) if (cpu->compat_pvr) { + uint32_t compat_pvr =3D cpu->compat_pvr; Error *local_err =3D NULL; =20 - ppc_set_compat(cpu, cpu->compat_pvr, &local_err); + cpu->compat_pvr =3D 0; + ppc_set_compat(cpu, compat_pvr, &local_err); if (local_err) { error_report_err(local_err); return -1; --=20 2.13.6