From nobody Mon Feb 9 18:45:31 2026 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=1582169602; cv=none; d=zohomail.com; s=zohoarc; b=M43QgGOogWXw3ZE4WhaqUZHuxa3YDAFMzhEU9kFj0TiZu/74nvyNTP1h0SWTCxYSNciAgBa2xRs9Ef4R3DdSxWbxYZo0MrEmZTZGYh5cLQ7SBTBeCbJ3H1fPLRReXzHOCwLTrWSEj4XchRpa/lQNmJV0bLcDOjZ+jvmomO0u+vg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1582169602; 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=81/o01V6RuK0z2L5PxXK5gyFjM/Ppre76Q0wCV8kuA4=; b=mdm1O0WamfXTnmLQtnZ/isIMC3ZlxnWADKqHOJzSg5sUOfJGVe2B2kxb3ILt37AVveUfNvfzBvAMR2IR4Ndn6daEgoSuDQh/MIsydeKKMH9WiDzjxs2canwO2VaP11pDBarUSMdAcLCbkY/sJkNQ8rOqM+BICbTN2R/KOV5+Bls= 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 1582169602617969.8719054873987; Wed, 19 Feb 2020 19:33:22 -0800 (PST) Received: from localhost ([::1]:35400 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4caX-00054T-Kw for importer@patchew.org; Wed, 19 Feb 2020 22:33:21 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:41422) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1j4cRA-0004hr-Ck for qemu-devel@nongnu.org; Wed, 19 Feb 2020 22:23:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1j4cR8-0008OG-QJ for qemu-devel@nongnu.org; Wed, 19 Feb 2020 22:23:40 -0500 Received: from ozlabs.org ([203.11.71.1]:39081) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1j4cR8-0008LZ-E4; Wed, 19 Feb 2020 22:23:38 -0500 Received: by ozlabs.org (Postfix, from userid 1007) id 48NKg13CWcz9sSc; Thu, 20 Feb 2020 14:23:25 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1582169005; bh=/AkTT+ugkeVoIN+7JAwU/EPjvumM4GWvTt+5ak8RmnE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=V+Hfp7eLFrRXopvCRvz6nO7ARk1rSqQEwuo7ETrNxWt/BHBEfRDwIwEhLSfCIZKho q8mvz/TI5/sHg0M/9hK6W+342h23K3FG0AEiNMuPfI0WpBJZ6s72SQ31Fg7PmV+d8P osXrhrcWP1v+1okxpm26CYrJC4Nt0EcD6dw5y6xI= From: David Gibson To: qemu-ppc@nongnu.org, groug@kaod.org, clg@kaod.org Subject: [PATCH v5 11/18] target/ppc: Streamline construction of VRMA SLB entry Date: Thu, 20 Feb 2020 14:23:09 +1100 Message-Id: <20200220032317.96884-12-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200220032317.96884-1-david@gibson.dropbear.id.au> References: <20200220032317.96884-1-david@gibson.dropbear.id.au> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 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, Mark Cave-Ayland , qemu-devel@nongnu.org, Igor Mammedov , 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" When in VRMA mode (i.e. a guest thinks it has the MMU off, but the hypervisor is still applying translation) we use a special SLB entry, rather than looking up an SLBE by address as we do when guest translation is on. We build that special entry in ppc_hash64_update_vrma() along with some logic for handling some non-VRMA cases. Split the actual build of the VRMA SLBE into a separate helper and streamline it a bit. Signed-off-by: David Gibson --- target/ppc/mmu-hash64.c | 74 +++++++++++++++++++---------------------- 1 file changed, 34 insertions(+), 40 deletions(-) diff --git a/target/ppc/mmu-hash64.c b/target/ppc/mmu-hash64.c index 203a41cca1..ac21c14f68 100644 --- a/target/ppc/mmu-hash64.c +++ b/target/ppc/mmu-hash64.c @@ -791,6 +791,35 @@ static target_ulong rmls_limit(PowerPCCPU *cpu) } } =20 +static int build_vrma_slbe(PowerPCCPU *cpu, ppc_slb_t *slb) +{ + CPUPPCState *env =3D &cpu->env; + target_ulong lpcr =3D env->spr[SPR_LPCR]; + uint32_t vrmasd =3D (lpcr & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT; + target_ulong vsid =3D SLB_VSID_VRMA | ((vrmasd << 4) & SLB_VSID_LLP_MA= SK); + int i; + + for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { + const PPCHash64SegmentPageSizes *sps =3D &cpu->hash64_opts->sps[i]; + + if (!sps->page_shift) { + break; + } + + if ((vsid & SLB_VSID_LLP_MASK) =3D=3D sps->slb_enc) { + slb->esid =3D SLB_ESID_V; + slb->vsid =3D vsid; + slb->sps =3D sps; + return 0; + } + } + + error_report("Bad page size encoding in LPCR[VRMASD]; LPCR=3D0x" + TARGET_FMT_lx"\n", lpcr); + + return -1; +} + int ppc_hash64_handle_mmu_fault(PowerPCCPU *cpu, vaddr eaddr, int rwx, int mmu_idx) { @@ -1046,53 +1075,18 @@ void ppc_hash64_tlb_flush_hpte(PowerPCCPU *cpu, tar= get_ulong ptex, static void ppc_hash64_update_vrma(PowerPCCPU *cpu) { CPUPPCState *env =3D &cpu->env; - const PPCHash64SegmentPageSizes *sps =3D NULL; - target_ulong esid, vsid, lpcr; ppc_slb_t *slb =3D &env->vrma_slb; - uint32_t vrmasd; - int i; - - /* First clear it */ - slb->esid =3D slb->vsid =3D 0; - slb->sps =3D NULL; =20 /* Is VRMA enabled ? */ if (ppc_hash64_use_vrma(env)) { - return; - } - - /* - * Make one up. Mostly ignore the ESID which will not be needed - * for translation - */ - lpcr =3D env->spr[SPR_LPCR]; - vsid =3D SLB_VSID_VRMA; - vrmasd =3D (lpcr & LPCR_VRMASD) >> LPCR_VRMASD_SHIFT; - vsid |=3D (vrmasd << 4) & (SLB_VSID_L | SLB_VSID_LP); - esid =3D SLB_ESID_V; - - for (i =3D 0; i < PPC_PAGE_SIZES_MAX_SZ; i++) { - const PPCHash64SegmentPageSizes *sps1 =3D &cpu->hash64_opts->sps[i= ]; - - if (!sps1->page_shift) { - break; - } - - if ((vsid & SLB_VSID_LLP_MASK) =3D=3D sps1->slb_enc) { - sps =3D sps1; - break; + if (build_vrma_slbe(cpu, slb) =3D=3D 0) { + return; } } =20 - if (!sps) { - error_report("Bad page size encoding esid 0x"TARGET_FMT_lx - " vsid 0x"TARGET_FMT_lx, esid, vsid); - return; - } - - slb->vsid =3D vsid; - slb->esid =3D esid; - slb->sps =3D sps; + /* Otherwise, clear it to indicate error */ + slb->esid =3D slb->vsid =3D 0; + slb->sps =3D NULL; } =20 void ppc_store_lpcr(PowerPCCPU *cpu, target_ulong val) --=20 2.24.1