From nobody Tue Nov 4 15:30:52 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 1530181062906638.4773893869215; Thu, 28 Jun 2018 03:17:42 -0700 (PDT) Received: from localhost ([::1]:35524 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYTzg-0001BE-9J for importer@patchew.org; Thu, 28 Jun 2018 06:17:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36315) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYTxQ-0008Ki-VY for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYTxN-0005aZ-O6 for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:20 -0400 Received: from 9.mo3.mail-out.ovh.net ([87.98.184.141]:54982) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYTxN-0005Y3-DU for qemu-devel@nongnu.org; Thu, 28 Jun 2018 06:15:17 -0400 Received: from player738.ha.ovh.net (unknown [10.109.108.75]) by mo3.mail-out.ovh.net (Postfix) with ESMTP id 9BE2C1BFE5D for ; Thu, 28 Jun 2018 12:15:15 +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 player738.ha.ovh.net (Postfix) with ESMTPA id 5BF3C5A84; Thu, 28 Jun 2018 12:14:57 +0200 (CEST) From: Greg Kurz To: qemu-devel@nongnu.org Date: Thu, 28 Jun 2018 12:14:51 +0200 Message-ID: <153018089136.336571.15410439376219137880.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: 13055090897630828886 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: 87.98.184.141 Subject: [Qemu-devel] [PATCH 1/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: 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 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, it only needs the kvm_state global variable to be set. The fallback code only needs informations from the machine's CPU model class. So this patch basically drops the CPU argument to kvm_get_smmu_info() and kvm_get_fallback_smmu_info(). The kvm_state and current_machine globals are used instead to reach out to KVM and CPU model details respectively. Signed-off-by: Greg Kurz Reviewed-by: C=C3=A9dric Le Goater --- target/ppc/kvm.c | 37 ++++++++++++++++++------------------- target/ppc/mmu-hash64.h | 8 +++++++- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 4df4ff6cbff2..9fae89ff8175 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -248,11 +248,12 @@ static int kvm_booke206_tlb_init(PowerPCCPU *cpu) =20 =20 #if defined(TARGET_PPC64) -static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, - struct kvm_ppc_smmu_info *info) +static void kvm_get_fallback_smmu_info(struct kvm_ppc_smmu_info *info) { - CPUPPCState *env =3D &cpu->env; - CPUState *cs =3D CPU(cpu); + const PowerPCCPUClass *pcc; + + assert(current_machine !=3D NULL); + pcc =3D POWERPC_CPU_CLASS(object_class_by_name(current_machine->cpu_ty= pe)); =20 memset(info, 0, sizeof(*info)); =20 @@ -278,7 +279,7 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, * implements KVM_CAP_PPC_GET_SMMU_INFO and thus doesn't hit * this fallback. */ - if (kvmppc_is_pr(cs->kvm_state)) { + if (kvmppc_is_pr(kvm_state)) { /* No flags */ info->flags =3D 0; info->slb_size =3D 64; @@ -300,12 +301,12 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cp= u, /* HV KVM has backing store size restrictions */ info->flags =3D KVM_PPC_PAGE_SIZES_REAL; =20 - if (ppc_hash64_has(cpu, PPC_HASH64_1TSEG)) { + if (hash64_opts_has(pcc->hash64_opts, PPC_HASH64_1TSEG)) { info->flags |=3D KVM_PPC_1T_SEGMENTS; } =20 - if (env->mmu_model =3D=3D POWERPC_MMU_2_06 || - env->mmu_model =3D=3D POWERPC_MMU_2_07) { + if (pcc->mmu_model =3D=3D POWERPC_MMU_2_06 || + pcc->mmu_model =3D=3D POWERPC_MMU_2_07) { info->slb_size =3D 32; } else { info->slb_size =3D 64; @@ -319,8 +320,8 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cpu, i++; =20 /* 64K on MMU 2.06 and later */ - if (env->mmu_model =3D=3D POWERPC_MMU_2_06 || - env->mmu_model =3D=3D POWERPC_MMU_2_07) { + if (pcc->mmu_model =3D=3D POWERPC_MMU_2_06 || + pcc->mmu_model =3D=3D POWERPC_MMU_2_07) { info->sps[i].page_shift =3D 16; info->sps[i].slb_enc =3D 0x110; info->sps[i].enc[0].page_shift =3D 16; @@ -336,19 +337,18 @@ static void kvm_get_fallback_smmu_info(PowerPCCPU *cp= u, } } =20 -static void kvm_get_smmu_info(PowerPCCPU *cpu, struct kvm_ppc_smmu_info *i= nfo) +static void kvm_get_smmu_info(struct kvm_ppc_smmu_info *info) { - CPUState *cs =3D CPU(cpu); int ret; =20 - if (kvm_check_extension(cs->kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { - ret =3D kvm_vm_ioctl(cs->kvm_state, KVM_PPC_GET_SMMU_INFO, info); + if (kvm_check_extension(kvm_state, KVM_CAP_PPC_GET_SMMU_INFO)) { + ret =3D kvm_vm_ioctl(kvm_state, KVM_PPC_GET_SMMU_INFO, info); if (ret =3D=3D 0) { return; } } =20 - kvm_get_fallback_smmu_info(cpu, info); + kvm_get_fallback_smmu_info(info); } =20 struct ppc_radix_page_info *kvm_get_radix_page_info(void) @@ -408,14 +408,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); + kvm_get_smmu_info(&smmu_info); return !!(smmu_info.flags & KVM_PPC_PAGE_SIZES_REAL); } =20 @@ -429,7 +428,7 @@ void kvm_check_mmu(PowerPCCPU *cpu, Error **errp) return; } =20 - kvm_get_smmu_info(cpu, &smmu_info); + kvm_get_smmu_info(&smmu_info); =20 if (ppc_hash64_has(cpu, PPC_HASH64_1TSEG) && !(smmu_info.flags & KVM_PPC_1T_SEGMENTS)) { @@ -2168,7 +2167,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); + kvm_get_smmu_info(&info); rampagesize =3D qemu_getrampagesize(); best_page_shift =3D 0; =20 diff --git a/target/ppc/mmu-hash64.h b/target/ppc/mmu-hash64.h index f11efc9cbc1f..00a249f26bc3 100644 --- a/target/ppc/mmu-hash64.h +++ b/target/ppc/mmu-hash64.h @@ -169,9 +169,15 @@ struct PPCHash64Options { extern const PPCHash64Options ppc_hash64_opts_basic; extern const PPCHash64Options ppc_hash64_opts_POWER7; =20 +static inline bool hash64_opts_has(const PPCHash64Options *opts, + unsigned feature) +{ + return !!(opts->flags & feature); +} + static inline bool ppc_hash64_has(PowerPCCPU *cpu, unsigned feature) { - return !!(cpu->hash64_opts->flags & feature); + return hash64_opts_has(cpu->hash64_opts, feature); } =20 #endif /* CONFIG_USER_ONLY */