From nobody Tue Nov 4 15:30:51 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 1530265940827287.6034822987623; Fri, 29 Jun 2018 02:52:20 -0700 (PDT) Received: from localhost ([::1]:40888 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYq4i-0003d7-5c for importer@patchew.org; Fri, 29 Jun 2018 05:52:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYq1C-0001Fk-8o for qemu-devel@nongnu.org; Fri, 29 Jun 2018 05:48:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYq17-0005GA-JQ for qemu-devel@nongnu.org; Fri, 29 Jun 2018 05:48:42 -0400 Received: from 8.mo178.mail-out.ovh.net ([46.105.74.227]:39482) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYq17-0005Bb-AS for qemu-devel@nongnu.org; Fri, 29 Jun 2018 05:48:37 -0400 Received: from player755.ha.ovh.net (unknown [10.109.108.51]) by mo178.mail-out.ovh.net (Postfix) with ESMTP id CED331D753 for ; Fri, 29 Jun 2018 11:48:35 +0200 (CEST) Received: from bahia.lan (lns-bzn-46-82-253-208-248.adsl.proxad.net [82.253.208.248]) (Authenticated sender: groug@kaod.org) by player755.ha.ovh.net (Postfix) with ESMTPA id 3EAA826009E; Fri, 29 Jun 2018 11:48:32 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 11:48:32 +0200 Message-ID: <153026571205.394407.1842744312813398945.stgit@bahia.lan> In-Reply-To: <153026568125.394407.16374811229961951138.stgit@bahia.lan> References: <153026568125.394407.16374811229961951138.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: 32369625057106315 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedtiedrvddugddujecutefuodetggdotefrodftvfcurfhrohhfihhlvgemucfqggfjpdevjffgvefmvefgnecuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 46.105.74.227 Subject: [Qemu-devel] [PATCH v2 2/3] target/ppc/kvm: don't pass cpu to kvm_get_smmu_info() 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, =?utf-8?q?C=C3=A9dric?= Le Goater , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 In a future patch the machine code will need to retrieve the MMU information from KVM during machine initialization before the CPUs are created. Actually, KVM_PPC_GET_SMMU_INFO is a VM class ioctl, and thus, we don't need to have a CPU object around. We just need for KVM to be initialized and use the kvm_state global. This patch just does that. Signed-off-by: Greg Kurz --- v2: - fallback code was dropped by a previous patch --- target/ppc/kvm.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index b6000f12b98f..9211ee2ee1a0 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -248,19 +248,19 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu) =20 =20 #if defined(TARGET_PPC64) -static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *i= nfo, - Error **errp) +static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info, Error **errp) { - CPUState *cs =3D CPU(cpu); int ret; =20 - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { + assert(kvm_state !=3D NULL); + + if (!kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { error_setg(errp, "KVM doesn't expose the MMU features it supports"= ); error_append_hint(errp, "Consider switching to a newer KVM\n"); return; } =20 - ret =3D kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_SMMU_INFO, info); + ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_SMMU_INFO, info); if (ret =3D=3D 0) { return; } @@ -326,14 +326,13 @@ target_ulong kvmppc_configure_v3_mmu(PowerPCCPU *cpu, =20 bool kvmppc_hpt_needs_host_contiguous_pages(void) { - PowerPCCPU *cpu =3D POWERPC_CPU(first_cpu); static struct kvm_ppc_smmu_info smmu_info; =20 if (!kvm_enabled()) { return false; } =20 - kvm_get_smmu_info(cpu, &smmu_info, &error_fatal); + kvm_get_smmu_info(&smmu_info, &error_fatal); return !!(smmu_info.flags & KVM_PPC_PAGE_SIZES_REAL); } =20 @@ -348,7 +347,7 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) return; } =20 - kvm_get_smmu_info(cpu, &smmu_info, &local_err); + kvm_get_smmu_info(&smmu_info, &local_err); if (local_err) { error_propagate(errp, local_err); return; @@ -2091,7 +2090,7 @@ uint64_t kvmppc_rma_size(uint64_t current_size, unsig= ned int hash_shift) =20 /* Find the largest hardware supported page size that's less than * or equal to the (logical) backing page size of guest RAM */ - kvm_get_smmu_info(POWERPC_CPU(first_cpu), &info, &error_fatal); + kvm_get_smmu_info(&info, &error_fatal); rampagesize =3D qemu_getrampagesize(); best_page_shift =3D 0; =20