From nobody Mon Nov 25 09:28:42 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1716506041; cv=none; d=zohomail.com; s=zohoarc; b=it6ZLkymB/r/oDaLe6slLe4eX96EKIn3LNZMH3796uCiUvIj7E4VhIAfw3b03RAJQ4SVqm97X00Veqhu7IwhUcFZxd6cJbtUEugqzmrUfgUkLwGarc3eQHhSDJx4LX2ptOEwSkmCjhfNWHELyr408fVQXrhRWr044weMXXs0xTs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716506041; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=6BpHgmg8vkBNPqt3TbYQHWcRZAKjdhW0RXAY1aIvRew=; b=PG0PA4pra18C9yBi2DzTYYFnjxHlXkrG2UPxCKdQLzqu7mRY1O+YSTJaQHW40qq3UAqUcff4pUidA6vEh1XJcZdmXRSsFftRXYW60W8Zy0G1TiPy3mGSqdLO/R8NY7rQxYbr7MwRcLzgBmZYHG0yx9t1rkWa3iSfmsnjaS7zKEw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1716506041554674.0997257179425; Thu, 23 May 2024 16:14:01 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAHab-0006ow-FP; Thu, 23 May 2024 19:11:14 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sAHZl-00037z-33; Thu, 23 May 2024 19:10:21 -0400 Received: from mail-il1-x133.google.com ([2607:f8b0:4864:20::133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sAHZi-000666-VZ; Thu, 23 May 2024 19:10:20 -0400 Received: by mail-il1-x133.google.com with SMTP id e9e14a558f8ab-3737bc62884so870415ab.1; Thu, 23 May 2024 16:10:18 -0700 (PDT) Received: from wheely.local0.net (110-175-65-7.tpgi.com.au. [110.175.65.7]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-682227f1838sm87041a12.46.2024.05.23.16.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 16:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716505816; x=1717110616; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=6BpHgmg8vkBNPqt3TbYQHWcRZAKjdhW0RXAY1aIvRew=; b=Zw2HyuU8kReepyiFD/AIEYw3Hsc3x0iP8tv1j9kU+4pOM/J7A+xH7zWv1xqIcExSjv FlnQrl3ID7B4AbOmtPZBYexomB186h7T0MY6RAuB2GBQeVOxlDpcMnyd+UmbjE/Gcoey cuQdWp4/4u8Trn5CEt28ut76caNACfmmk0FGc9S3k1U52Or+uTb4+X2jxZ9+qQBsO/wl PCQMcELsDAQj9fP7vPeCwoXLbP4DXjQHb5T14ACWmAKgnEbV5/LR82N2sekAzRe1KMqb tJDEF91Xu3GsXLEh7adIRiKcbChrzjAIO0piIII+bNiVoBeHquMw0GrhvVsRuIb+MT08 pipg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716505816; x=1717110616; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=6BpHgmg8vkBNPqt3TbYQHWcRZAKjdhW0RXAY1aIvRew=; b=Odi3C895n7ZiRZW7ccy6Ir9+m9lZZvGesYXJJ8ilWt4i0bHJuW5fVp3ZDUYsXu0Npi MTzxTSWcBjqh4dKUP/GARH61FJVQ6E/kYBXVt19w0XqnxgH491R7xnRzqSuVfcaxcYod f5lbx3emOX9xBgGxMV4N+MtXcK9ZnOiWNNszoAzMobRkLtamzBk/QhwgACmUCsP0rfnu GVznK5PNLiNDLBLwV+E1DnydxqW66lG13IeVSMzj27yXXVqqlwVUf+ihAEjMnvTggh/m Wq262eZJAOuDAxL8l5w9afQwi44A/7kSOSI6PY3dc1h7S4hx3Ekd4nWTuhNwr6aox6IS pHlw== X-Forwarded-Encrypted: i=1; AJvYcCVODZHrIrkFA0kixJTPfWQ8/kQTtj9y2W5pdQkYewDfuZxsWjKJzi6mQbD+32tAl+K9o6f3RvSdQzT7++480YMo7F7G X-Gm-Message-State: AOJu0YwF7gHQrGHU2Q3cxWbtZZPk2DDfRaz+TuHQphWvY3aFzVSZ2orT t/ZxJT3aamZrFDwpD722fbM3D+OaEq4VQ6UJZFrX4sGO8/Sbpqc7lyed9A== X-Google-Smtp-Source: AGHT+IF+b3FP70wHEjHg0E2ENeXiX1S++VrIS9/RW7tUA2H1sChjbVAFyhcW/c9Cw7Imz35oyPrNIw== X-Received: by 2002:a05:6e02:1b02:b0:36d:bbf7:2fd7 with SMTP id e9e14a558f8ab-3737b2953cfmr9191175ab.12.1716505816049; Thu, 23 May 2024 16:10:16 -0700 (PDT) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org, BALATON Zoltan Subject: [PULL 45/72] target/ppc/mmu_common.c: Introduce mmu6xx_get_physical_address() Date: Fri, 24 May 2024 09:07:18 +1000 Message-ID: <20240523230747.45703-46-npiggin@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240523230747.45703-1-npiggin@gmail.com> References: <20240523230747.45703-1-npiggin@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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; Received-SPF: pass client-ip=2607:f8b0:4864:20::133; envelope-from=npiggin@gmail.com; helo=mail-il1-x133.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1716506042996100003 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Repurpose get_segment_6xx_tlb() to do the whole address translation for POWERPC_MMU_SOFT_6xx MMU model by moving the BAT check there and renaming it to match other similar functions. These are only called once together so no need to keep these separate functions and combining them simplifies the caller allowing further restructuring. Reviewed-by: Nicholas Piggin Signed-off-by: BALATON Zoltan Signed-off-by: Nicholas Piggin --- target/ppc/mmu_common.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 3391df61cb..b7c07cf515 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -360,19 +360,23 @@ static int get_bat_6xx_tlb(CPUPPCState *env, mmu_ctx_= t *ctx, return ret; } =20 -/* Perform segment based translation */ -static int get_segment_6xx_tlb(CPUPPCState *env, mmu_ctx_t *ctx, - target_ulong eaddr, MMUAccessType access_ty= pe, - int type) +static int mmu6xx_get_physical_address(CPUPPCState *env, mmu_ctx_t *ctx, + target_ulong eaddr, + MMUAccessType access_type, int type) { PowerPCCPU *cpu =3D env_archcpu(env); hwaddr hash; - target_ulong vsid; + target_ulong vsid, sr, pgidx; int ds, target_page_bits; bool pr; int ret; - target_ulong sr, pgidx; =20 + /* First try to find a BAT entry if there are any */ + if (env->nb_BATs && get_bat_6xx_tlb(env, ctx, eaddr, access_type) =3D= =3D 0) { + return 0; + } + + /* Perform segment based translation when no BATs matched */ pr =3D FIELD_EX64(env->msr, MSR, PR); ctx->eaddr =3D eaddr; =20 @@ -1194,14 +1198,8 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu_= ctx_t *ctx, if (real_mode) { ret =3D check_physical(env, ctx, eaddr, access_type); } else { - /* Try to find a BAT */ - if (env->nb_BATs !=3D 0) { - ret =3D get_bat_6xx_tlb(env, ctx, eaddr, access_type); - } - if (ret < 0) { - /* We didn't match any BAT entry or don't have BATs */ - ret =3D get_segment_6xx_tlb(env, ctx, eaddr, access_type, = type); - } + ret =3D mmu6xx_get_physical_address(env, ctx, eaddr, access_ty= pe, + type); } break; =20 --=20 2.43.0