From nobody Thu Nov 13 20:41:58 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1582587939; cv=none; d=zohomail.com; s=zohoarc; b=BnTe0Hl6dTIgzJdagJjB0KJ88Dwu9DKplEhC/Rer/MihDe2y+7D5bnmjMHWqE2qWZphghbpOV8gG8NKu271M82AUFZSG7xNCkaZm1dduMev6DQmDaTjAuwJc7uXbM5AE3kKS8UYxziBtbX0wk/j0TQpp7/swaI+2zsZFMrHEVp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582587939; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=VXbmn1UGNkAewX+X9YTeM39jMNNJfPZ0EkP3uK531m4=; b=HQ5CIFPgi3FuPPQk4Lm6bBYGom3vfwGI+Tk8IhhYgVXpTc2/Y6u0CvjIduDjoA4LWCSozc1oexCfsxtLOFcGQoabDwIZs9fK2aJSt2dFPVxW15gSsY/oKPAb6f8wOxBunyGjgeWjHPlYXTETOaGkzggi3y6Zefy1Lkq8zt/gASE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 15825879390536.752152423752705; Mon, 24 Feb 2020 15:45:39 -0800 (PST) Received: from localhost ([::1]:46242 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6NPt-0004uB-Fp for importer@patchew.org; Mon, 24 Feb 2020 18:45:37 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:47312) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j6NIS-0006ds-BQ for qemu-devel@nongnu.org; Mon, 24 Feb 2020 18:37:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j6NIQ-0008Aq-Et for qemu-devel@nongnu.org; Mon, 24 Feb 2020 18:37:56 -0500 Received: from ozlabs.org ([2401:3900:2:1::2]:39967) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j6NIQ-00087O-23; Mon, 24 Feb 2020 18:37:54 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48RJQ53F5Dz9sSY; Tue, 25 Feb 2020 10:37:32 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1582587453; bh=G9vVCBQAxL325dmu2RbgIx5Jm0SP2MYRe+FEiLxyaO4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fqNIrEhUlo13XwfTVkg6NFgxcCi9A9eViTRF/MgkMPTh1kXOs3EWnYH6K9B2AzMOp M4LZBRiycS1ftX0CAH+ipLbCKHGsAxDXZUDSPaTutH4ub9Od//MpkawHD+NjzTA4AD 71nZefaPzFEH2kwmAVwOl+NNt5a+VUbaM/nW9Dh0= From: David Gibson To: groug@kaod.org, qemu-ppc@nongnu.org, qemu-devel@nongnu.org, clg@kaod.org Subject: [PATCH v6 14/18] spapr,ppc: Simplify signature of kvmppc_rma_size() Date: Tue, 25 Feb 2020 10:37:20 +1100 Message-Id: <20200224233724.46415-15-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200224233724.46415-1-david@gibson.dropbear.id.au> References: <20200224233724.46415-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 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lvivier@redhat.com, Thomas Huth , Xiao Guangrong , "Michael S. Tsirkin" , aik@ozlabs.ru, farosas@linux.ibm.com, Mark Cave-Ayland , Igor Mammedov , Cedric Le Goater , paulus@samba.org, Paolo Bonzini , "Edgar E. Iglesias" , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This function calculates the maximum size of the RMA as implied by the host's page size of structure of the VRMA (there are a number of other constraints on the RMA size which will supersede this one in many circumstances). The current interface takes the current RMA size estimate, and clamps it to the VRMA derived size. The only current caller passes in an arguably wrong value (it will match the current RMA estimate in some but not all cases). We want to fix that, but for now just keep concerns separated by having the KVM helper function just return the VRMA derived limit, and let the caller combine it with other constraints. We call the new function kvmppc_vrma_limit() to more clearly indicate its limited responsibility. The helper should only ever be called in the KVM enabled case, so replace its !CONFIG_KVM stub with an assert() rather than a dummy value. Signed-off-by: David Gibson Reviewed-by: Cedric Le Goater Reviewed-by: Greg Kurz Reviewed-by: Alexey Kardashevskiy --- hw/ppc/spapr.c | 5 +++-- target/ppc/kvm.c | 5 ++--- target/ppc/kvm_ppc.h | 7 +++---- 3 files changed, 8 insertions(+), 9 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 272a270b7a..b68d80ba69 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -1586,8 +1586,9 @@ void spapr_setup_hpt_and_vrma(SpaprMachineState *spap= r) spapr_reallocate_hpt(spapr, hpt_shift, &error_fatal); =20 if (spapr->vrma_adjust) { - spapr->rma_size =3D kvmppc_rma_size(spapr_node0_size(MACHINE(spapr= )), - spapr->htab_shift); + hwaddr vrma_limit =3D kvmppc_vrma_limit(spapr->htab_shift); + + spapr->rma_size =3D MIN(spapr_node0_size(MACHINE(spapr)), vrma_lim= it); } } =20 diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 7f44b1aa1a..597f72be1b 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -2113,7 +2113,7 @@ void kvmppc_error_append_smt_possible_hint(Error *con= st *errp) =20 =20 #ifdef TARGET_PPC64 -uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift) +uint64_t kvmppc_vrma_limit(unsigned int hash_shift) { struct kvm_ppc_smmu_info info; long rampagesize, best_page_shift; @@ -2140,8 +2140,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsig= ned int hash_shift) } } =20 - return MIN(current_size, - 1ULL << (best_page_shift + hash_shift - 7)); + return 1ULL << (best_page_shift + hash_shift - 7); } #endif =20 diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 9e4f2357cc..332fa0aa1c 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -47,7 +47,7 @@ void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t pa= ge_shift, int *pfd, bool need_vfio); int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size); int kvmppc_reset_htab(int shift_hint); -uint64_t kvmppc_rma_size(uint64_t current_size, unsigned int hash_shift); +uint64_t kvmppc_vrma_limit(unsigned int hash_shift); bool kvmppc_has_cap_spapr_vfio(void); #endif /* !CONFIG_USER_ONLY */ bool kvmppc_has_cap_epr(void); @@ -255,10 +255,9 @@ static inline int kvmppc_reset_htab(int shift_hint) return 0; } =20 -static inline uint64_t kvmppc_rma_size(uint64_t current_size, - unsigned int hash_shift) +static inline uint64_t kvmppc_vrma_limit(unsigned int hash_shift) { - return ram_size; + g_assert_not_reached(); } =20 static inline bool kvmppc_hpt_needs_host_contiguous_pages(void) --=20 2.24.1