From nobody Tue Nov 4 15:29:08 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; 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 1530181060399757.1657842128656; Thu, 28 Jun 2018 03:17:40 -0700 (PDT) Received: from localhost ([::1]:35523 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYTzd-0001AI-PX for importer@patchew.org; Thu, 28 Jun 2018 06:17:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36426) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYTxd-0008Ui-UV for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYTxa-0005wF-Nz for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:33 -0400 Received: from 4.mo173.mail-out.ovh.net ([46.105.34.219]:44888) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYTxa-0005v1-B7 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:30 -0400 Received: from player159.ha.ovh.net (unknown [10.109.108.57]) by mo173.mail-out.ovh.net (Postfix) with ESMTP id C9496C753B for ; Thu, 28 Jun 2018 12:15:28 +0200 (CEST) Received: from [192.168.0.243] (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player159.ha.ovh.net (Postfix) with ESMTPA id F3FE44800B2; Thu, 28 Jun 2018 12:15:20 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 12:15:14 +0200 Message-ID: <153018091454.336571.7311461748726927045.stgit@bahia> In-Reply-To: <153018086531.336571.17029459443980070626.stgit@bahia.lan> References: <153018086531.336571.17029459443980070626.stgit@bahia.lan> User-Agent: StGit/0.17.1-46-g6855-dirty MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Ovh-Tracer-Id: 13060438921537689942 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtiedrudelgddviecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.34.219 Subject: [Qemu-devel] [PATCH 2/3] spapr: compute default value of "hpt-max-page-size" later 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: Eduardo Habkost , qemu-ppc@nongnu.org, =?utf-8?q?C=C3=A9dric?= Le Goater , Paolo Bonzini , David Gibson , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 It is currently not possible to run a pseries-2.12 or older machine with HV KVM. QEMU prints the following and exits right away. qemu-system-ppc64: KVM doesn't support for base page shift 34 The "hpt-max-page-size" capability was recently added to spapr to hide host configuration details from HPT mode guests. Its default value for newer machine types is 64k. For backwards compatibility, pseries-2.12 and older machine types need a different value. This is handled as usual in a class init function. The default value is 16G, ie, all page sizes supported by POWER7 and newer CPUs, but HV KVM requires guest pages to be hpa contiguous as well as gpa contiguous. The default value is the page size used to back the guest RAM in this case. Unfortunately kvmppc_hpt_needs_host_contiguous_pages()->kvm_enabled() is called way before KVM init and returns false, even if the user requested KVM. We thus end up selecting 16G, which isn't supported by HV KVM. We fix this by moving the logic to spapr_machine_init() because this is the earliest call where we're sure kvm_enabled() can be trusted. Since the user cannot pass cap-hpt-max-page-size=3D0, we set the default to 0 in the pseries-2.12 class init function and use that as a flag in spapr_machine_init() to do the real work. Signed-off-by: Greg Kurz --- hw/ppc/spapr.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 8cc996d0b822..1eb45cd8c424 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2527,6 +2527,18 @@ static void spapr_machine_init(MachineState *machine) QLIST_INIT(&spapr->phbs); QTAILQ_INIT(&spapr->pending_dimm_unplugs); =20 + /* This is for pseries-2.12 and older machine types */ + if (!smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE]) { + uint8_t mps; + + if (kvmppc_hpt_needs_host_contiguous_pages()) { + mps =3D ctz64(qemu_getrampagesize()); + } else { + mps =3D 34; /* allow everything up to 16GiB, i.e. everything */ + } + smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D mps; + } + /* Determine capabilities to run with */ spapr_caps_init(spapr); =20 @@ -4103,17 +4115,16 @@ static void spapr_machine_2_12_instance_options(Mac= hineState *machine) static void spapr_machine_2_12_class_options(MachineClass *mc) { sPAPRMachineClass *smc =3D SPAPR_MACHINE_CLASS(mc); - uint8_t mps; =20 spapr_machine_3_0_class_options(mc); SET_MACHINE_COMPAT(mc, SPAPR_COMPAT_2_12); =20 - if (kvmppc_hpt_needs_host_contiguous_pages()) { - mps =3D ctz64(qemu_getrampagesize()); - } else { - mps =3D 34; /* allow everything up to 16GiB, i.e. everything */ - } - smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D mps; + /* We depend on kvm_enabled() to choose a default value for the + * hpt-max-page-size capability. Of course we can't do it here + * because this is too early and the HW accelerator isn't initialzed + * yet. Postpone this to spapr_machine_init(). + */ + smc->default_caps.caps[SPAPR_CAP_HPT_MAXPAGESIZE] =3D 0; } =20 DEFINE_SPAPR_MACHINE(2_12, "2.12", false);