From nobody Sun May 5 05:53:02 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 150764181235869.71787214181631; Tue, 10 Oct 2017 06:23:32 -0700 (PDT) Received: from localhost ([::1]:35066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1uVK-0002u2-Lc for importer@patchew.org; Tue, 10 Oct 2017 09:23:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55435) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1e1uU9-0002J4-2w for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:22:17 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1e1uU3-0003Zx-7W for qemu-devel@nongnu.org; Tue, 10 Oct 2017 09:22:13 -0400 Received: from ozlabs.org ([103.22.144.67]:57179) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1e1uU2-0003YD-Kf; Tue, 10 Oct 2017 09:22:07 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 3yBHp36hqYz9tYN; Wed, 11 Oct 2017 00:22:03 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1507641723; bh=x0R5usMuZfZ0m8eTsxxlHHkAxh2axAexBfux957K8Lw=; h=From:To:Cc:Subject:Date:From; b=og/KwHJrkLQ+tE1/eDj9XWEOBHTiAcRCWElYYPVxsmvYOHnVsGxR1CphJTo9J9vzJ hQyoOATsMenul7VmgXrBsMC9rShmy21Y4WlRqG/pVXro5iWwW777YdBRXSXkG2hUjI 2v5EgGsMTKrcDv93wmv499SclUBy0h2CNeHC7Uuc= From: David Gibson To: lvivier@redhat.com, groug@kaod.org, clg@kaod.org Date: Wed, 11 Oct 2017 00:21:59 +1100 Message-Id: <20171010132159.15787-1-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.13.6 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] [PATCH] spapr: Correct RAM size calculation for HPT resizing 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: qemu-ppc@nongnu.org, qemu-devel@nongnu.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-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" In order to prevent the guest from forcing the allocation of large amounts of qemu memory (or host kernel memory, in the case of KVM HV), we limit the size of Hashed Page Table (HPT) it is allowed to allocated, based on its RAM size. However, the current calculation is not correct: it only adds up the size of plugged memory, ignoring the base memory size. This patch corrects it. While we're there, use get_plugged_memory_size() instead of directly calling pc_existing_dimms_capacity(). The only difference is that it will abort on failure, which is right: a failure here indicates something wrong within qemu. Signed-off-by: David Gibson Reviewed-by: Laurent Vivier --- hw/ppc/spapr_hcall.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr_hcall.c b/hw/ppc/spapr_hcall.c index 8d72bb7c1c..06af1b15c0 100644 --- a/hw/ppc/spapr_hcall.c +++ b/hw/ppc/spapr_hcall.c @@ -494,7 +494,7 @@ static target_ulong h_resize_hpt_prepare(PowerPCCPU *cp= u, return H_PARAMETER; } =20 - current_ram_size =3D pc_existing_dimms_capacity(&error_fatal); + current_ram_size =3D ram_size + get_plugged_memory_size(); =20 /* We only allow the guest to allocate an HPT one order above what * we'd normally give them (to stop a small guest claiming a huge --=20 2.13.6