From nobody Fri Oct 24 20:18:49 2025 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 1518775731733267.6203376548773; Fri, 16 Feb 2018 02:08:51 -0800 (PST) Received: from localhost ([::1]:59086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emcwg-0003Lb-SE for importer@patchew.org; Fri, 16 Feb 2018 05:08:46 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35381) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1emcuT-0001aU-GJ for qemu-devel@nongnu.org; Fri, 16 Feb 2018 05:06:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1emcuQ-00056A-8y for qemu-devel@nongnu.org; Fri, 16 Feb 2018 05:06:29 -0500 Received: from ozlabs.org ([103.22.144.67]:44743) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1emcuP-00050j-I0; Fri, 16 Feb 2018 05:06:26 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 3zjTLj5sdNz9t66; Fri, 16 Feb 2018 21:06:21 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1518775581; bh=GhCL0/RQl+MIxfgqQerRpYhzJKH2RWnE8xd+XW7QWqw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lJlRWbJGp35AL4UwGL1fYXXK1RQjL6s9YrXpdFioIxACezJvaXo+fM952Jx8cSaeQ ReENj7HRW+qbVoJK6T1wnkrXefOdnb3iq4oqL4zn+rd6vWMLOnD74lcwEAp0PfZVHp T9lhzfImIDVFt2InVc7jE7XqPsmDHGW81FB0f9Sk= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 16 Feb 2018 21:06:07 +1100 Message-Id: <20180216100617.25265-5-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.14.3 In-Reply-To: <20180216100617.25265-1-david@gibson.dropbear.id.au> References: <20180216100617.25265-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 103.22.144.67 Subject: [Qemu-devel] [PULL 04/14] hw/ppc/spapr_hcall: set htab_shift after kvmppc_resize_hpt_commit 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: lvivier@redhat.com, surajjs@au1.ibm.com, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, Daniel Henrique Barboza , David Gibson 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" From: Daniel Henrique Barboza Newer kernels have a htab resize capability when adding or remove memory. At these situations, the guest kernel might reallocate its htab to a more suitable size based on the resulting memory. However, we're not setting the new value back into the machine state when a KVM guest resizes its htab. At first this doesn't seem harmful, but when migrating or saving the guest state (via virsh managedsave, for instance) this mismatch between the htab size of QEMU and the kernel makes the guest hangs when trying to load its state. Inside h_resize_hpt_commit, the hypercall that commits the hash page resize changes, let's set spapr->htab_shift to the new value if we're sure that kvmppc_resize_hpt_commit were successful. While we're here, add a "not RADIX" sanity check as it is already done in the related hypercall h_resize_hpt_prepare. Fixes: https://github.com/open-power-host-os/qemu/issues/28 Reported-by: Satheesh Rajendran Signed-off-by: Daniel Henrique Barboza Signed-off-by: David Gibson --- hw/ppc/spapr_hcall.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 76422cfac1..1986560480 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -731,11 +731,21 @@ static target_ulong h_resize_hpt_commit(PowerPCCPU *c= pu, return H_AUTHORITY; } =20 + if (!spapr->htab_shift) { + /* Radix guest, no HPT */ + return H_NOT_AVAILABLE; + } + trace_spapr_h_resize_hpt_commit(flags, shift); =20 rc =3D kvmppc_resize_hpt_commit(cpu, flags, shift); if (rc !=3D -ENOSYS) { - return resize_hpt_convert_rc(rc); + rc =3D resize_hpt_convert_rc(rc); + if (rc =3D=3D H_SUCCESS) { + /* Need to set the new htab_shift in the machine state */ + spapr->htab_shift =3D shift; + } + return rc; } =20 if (flags !=3D 0) { --=20 2.14.3