From nobody Tue Feb 10 15:46:07 2026 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 1529665241585857.8143831638859; Fri, 22 Jun 2018 04:00:41 -0700 (PDT) Received: from localhost ([::1]:60821 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJo0-0004Y3-KE for importer@patchew.org; Fri, 22 Jun 2018 07:00:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fWJPy-0000nN-Pl for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:35:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fWJPw-0003Wf-J1 for qemu-devel@nongnu.org; Fri, 22 Jun 2018 06:35:50 -0400 Received: from ozlabs.org ([2401:3900:2:1::2]:39811) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fWJPw-0003Tx-0i; Fri, 22 Jun 2018 06:35:48 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41Bw2K4V1Cz9s9m; Fri, 22 Jun 2018 20:35:35 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1529663737; bh=+C1rwuyE9BVJq98OzSqbtEjAW8SaoMy9JV5B/R8X75k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cfC9XRkGGeDHf3e1A1vIfryq2Blf7zLJHPyWNObcx9E2j2d5drJ4ba7VkuBzNcidw 9+3owWeHWS7Q0ra/s1HqrPXPppboIX7yJ4HSxuYrhGLsKB19icZ1VzuUq+ctaquc7K 5Y90q8C0LZQPuIjR3CcSIAf9fnGhgTYOn6qf80jc= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 22 Jun 2018 20:35:25 +1000 Message-Id: <20180622103528.28598-23-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180622103528.28598-1-david@gibson.dropbear.id.au> References: <20180622103528.28598-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2401:3900:2:1::2 Subject: [Qemu-devel] [PULL 22/25] spapr: Limit available pagesizes to provide a consistent guest environment 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, aik@ozlabs.ru, qemu-devel@nongnu.org, agraf@suse.de, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, 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-Type: text/plain; charset="utf-8" KVM HV has some limitations (deriving from the hardware) that mean not all host-cpu supported pagesizes may be usable in the guest. At present this means that KVM guests and TCG guests may see different available page sizes even if they notionally have the same vcpu model. This is confusing and also prevents migration between TCG and KVM. This patch makes the environment consistent by always allowing the same set of pagesizes. Since we can't remove the KVM limitations, we do this by always applying the same limitations it has, even to TCG guests. Signed-off-by: David Gibson Reviewed-by: C=C3=A9dric Le Goater Reviewed-by: Greg Kurz --- hw/ppc/spapr_caps.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/hw/ppc/spapr_caps.c b/hw/ppc/spapr_caps.c index 722b213d9a..62663ebdf5 100644 --- a/hw/ppc/spapr_caps.c +++ b/hw/ppc/spapr_caps.c @@ -335,6 +335,39 @@ static void cap_hpt_maxpagesize_apply(sPAPRMachineStat= e *spapr, spapr_check_pagesize(spapr, qemu_getrampagesize(), errp); } =20 +static bool spapr_pagesize_cb(void *opaque, uint32_t seg_pshift, + uint32_t pshift) +{ + unsigned maxshift =3D *((unsigned *)opaque); + + assert(pshift >=3D seg_pshift); + + /* Don't allow the guest to use pages bigger than the configured + * maximum size */ + if (pshift > maxshift) { + return false; + } + + /* For whatever reason, KVM doesn't allow multiple pagesizes + * within a segment, *except* for the case of 16M pages in a 4k or + * 64k segment. Always exclude other cases, so that TCG and KVM + * guests see a consistent environment */ + if ((pshift !=3D seg_pshift) && (pshift !=3D 24)) { + return false; + } + + return true; +} + +static void cap_hpt_maxpagesize_cpu_apply(sPAPRMachineState *spapr, + PowerPCCPU *cpu, + uint8_t val, Error **errp) +{ + unsigned maxshift =3D val; + + ppc_hash64_filter_pagesizes(cpu, spapr_pagesize_cb, &maxshift); +} + sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] =3D { [SPAPR_CAP_HTM] =3D { .name =3D "htm", @@ -402,6 +435,7 @@ sPAPRCapabilityInfo capability_table[SPAPR_CAP_NUM] =3D= { .set =3D spapr_cap_set_pagesize, .type =3D "int", .apply =3D cap_hpt_maxpagesize_apply, + .cpu_apply =3D cap_hpt_maxpagesize_cpu_apply, }, }; =20 --=20 2.17.1