From nobody Mon Nov 25 10:49:31 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=1716506247; cv=none; d=zohomail.com; s=zohoarc; b=Rs58EfHkRw7jKc+0G3wGsHOE8PAJa9v9CLabM4TOxtmGHrw6KVJV7YnL2CsIVWLhnIOuyR3TVEKytHS2FHIHFxlGI42OuwloQXJxkG6FX/RkwqfIpwiWXxMNguzj+bt0ye95cOHAy0OptRoMEVD6wbtcsQ7UfiheQhJQyYjPjII= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1716506247; 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=eGRV+A0Z6ioG6ImZPkbnbweK1JbvKAB9m8KPvmYU42o=; b=K5teEydrfFgVofA9qG92DbPfjSAVeUmoth2XVAwxbjO+iX7uyKRCHpuWpk3fgKp/ix6xUp660JKxyYl90tW8DFSJJAKmzRo+6ygHfdO/Jeleql/FVzeKnZTwvuLMm7q/wy6BvzQyALnCQllDqj8GvgVVldQzxGifdgvWCrc2jyg= 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 1716506247102266.87429897365325; Thu, 23 May 2024 16:17:27 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sAHbK-0001jE-Ua; Thu, 23 May 2024 19:11:59 -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 1sAHaf-00076L-FT; Thu, 23 May 2024 19:11:17 -0400 Received: from mail-oo1-xc2b.google.com ([2607:f8b0:4864:20::c2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sAHaX-0006I9-7o; Thu, 23 May 2024 19:11:17 -0400 Received: by mail-oo1-xc2b.google.com with SMTP id 006d021491bc7-5b52b0d0dfeso2833547eaf.0; Thu, 23 May 2024 16:11:08 -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.11.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 May 2024 16:11:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716505867; x=1717110667; 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=eGRV+A0Z6ioG6ImZPkbnbweK1JbvKAB9m8KPvmYU42o=; b=VvRf+89QcDoay9w78YZdqp8ahMVdFCIhCWmQFbXJxZ3sKghYRypDtJj9EocPM9Y2nq 3opQrOlfvVHDArHzFHdKlIE5vT75hDFry2ZgWzAJUWobXQbLyIg3m4EmPcjEME4QH6dg +KWr/BRczGIoFxojCCCyxwUdFL+ViaaQWFMDfwOPTZNR8hZbX4Gs3u57xAnPY6i2Snpq IEw4AWG6TVV22nfeqhf5M7PybNy+3a06HPCRIOawbZ0FrTk1CbnaJc4tppxZKJ+teqcg 7z/NYZxurxn/nzmqHwfuszJxyJq9GE2dL09hjSaXaCVx+ehybfdJRCmnRqvcqrcoeB8+ 00jw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716505867; x=1717110667; 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=eGRV+A0Z6ioG6ImZPkbnbweK1JbvKAB9m8KPvmYU42o=; b=QCInahF1nFu6d59REKiP82HEHXJV/4Il3goD3YG3NOLCL4m0x5k06pxs1Id2zUpXI/ lLPHqSoSmRTkkaULFPwnNPhgFkdbxMHJdfd7lp3hsKuDwO7boHee8aygJWYUv7eUVjrj us1nzc/7foxzrQF2jZiaHVJJ0RUBDkIqskf4xBvXVm3ecFBIj30/ruDIByjFSiiYl9yM cYl65Z+dz3zhYvjHxjc3k14Cup96LuDWYk6nPxeItsW6UXEo4wFBZKiWjyObC8dFtVDp 3lL5vJsh/lKZZb9QhqEQpBx2Ba3kPYsFjykd7tV+TfVwdpbczK9BLs91kHttR7wmOii6 BDHQ== X-Forwarded-Encrypted: i=1; AJvYcCXaUEX9ICNjaM34luo+eWDJYyUXt4SUg7tRckQypQZyF5wHB/c5dbenlZkOjY35RqimV4S2Az16YyL6y0x4F3D2fJMD X-Gm-Message-State: AOJu0Yz5a5hhOow50pGKHpbIBREostQOzPmz3uldDAQ71zA7eiZislX1 a/CZRow8hHuKU3O2kR3YWh+o5YqF0W2xg+A2HkX9vk3HkWTzUiBhP3hnVA== X-Google-Smtp-Source: AGHT+IEx+MxZR4aVoGUlEUdyEBX83EMRNj1V/FJgcPKmSKWYPhXAfrip0eGpM/8F8STEzJJF0Gm8vw== X-Received: by 2002:a05:6358:8094:b0:183:e918:3a42 with SMTP id e5c5f4694b2df-197e50f4d86mr106713655d.9.1716505866888; Thu, 23 May 2024 16:11:06 -0700 (PDT) From: Nicholas Piggin To: qemu-devel@nongnu.org Cc: Nicholas Piggin , qemu-ppc@nongnu.org, BALATON Zoltan Subject: [PULL 62/72] target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb() Date: Fri, 24 May 2024 09:07:35 +1000 Message-ID: <20240523230747.45703-63-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::c2b; envelope-from=npiggin@gmail.com; helo=mail-oo1-xc2b.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_PASS=-0.001, T_SPF_HELO_TEMPERROR=0.01 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: 1716506247910100001 Content-Type: text/plain; charset="utf-8" From: BALATON Zoltan Add ppc_real_mode_xlate() to handle real mode translation and allow removing this case from ppc_jumbo_xlate(). Reviewed-by: Nicholas Piggin Signed-off-by: BALATON Zoltan Signed-off-by: Nicholas Piggin --- target/ppc/mmu_common.c | 46 ++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 19 deletions(-) diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c index 8599106f75..ab912da821 100644 --- a/target/ppc/mmu_common.c +++ b/target/ppc/mmu_common.c @@ -1117,23 +1117,12 @@ int get_physical_address_wtlb(CPUPPCState *env, mmu= _ctx_t *ctx, MMUAccessType access_type, int type, int mmu_idx) { - bool real_mode =3D (type =3D=3D ACCESS_CODE) ? !FIELD_EX64(env->msr, M= SR, IR) - : !FIELD_EX64(env->msr, MSR, DR= ); - if (real_mode) { - ctx->raddr =3D eaddr; - ctx->prot =3D PAGE_RWX; - return 0; - } - switch (env->mmu_model) { case POWERPC_MMU_SOFT_6xx: return mmu6xx_get_physical_address(env, ctx, eaddr, access_type, t= ype); case POWERPC_MMU_SOFT_4xx: return mmu40x_get_physical_address(env, &ctx->raddr, &ctx->prot, e= addr, access_type); - case POWERPC_MMU_REAL: - cpu_abort(env_cpu(env), - "PowerPC in real mode do not do any translation\n"); default: cpu_abort(env_cpu(env), "Unknown or invalid MMU model\n"); } @@ -1251,6 +1240,24 @@ static bool ppc_booke_xlate(PowerPCCPU *cpu, vaddr e= addr, return false; } =20 +static bool ppc_real_mode_xlate(PowerPCCPU *cpu, vaddr eaddr, + MMUAccessType access_type, + hwaddr *raddrp, int *psizep, int *protp) +{ + CPUPPCState *env =3D &cpu->env; + + if (access_type =3D=3D MMU_INST_FETCH ? !FIELD_EX64(env->msr, MSR, IR) + : !FIELD_EX64(env->msr, MSR, DR)) { + *raddrp =3D eaddr; + *protp =3D PAGE_RWX; + *psizep =3D TARGET_PAGE_BITS; + return true; + } else if (env->mmu_model =3D=3D POWERPC_MMU_REAL) { + cpu_abort(CPU(cpu), "PowerPC in real mode shold not do translation= \n"); + } + return false; +} + /* Perform address translation */ /* TODO: Split this by mmu_model. */ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr eaddr, @@ -1264,6 +1271,10 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, int type; int ret; =20 + if (ppc_real_mode_xlate(cpu, eaddr, access_type, raddrp, psizep, protp= )) { + return true; + } + if (access_type =3D=3D MMU_INST_FETCH) { /* code access */ type =3D ACCESS_CODE; @@ -1303,11 +1314,8 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, env->spr[SPR_40x_DEAR] =3D eaddr; env->spr[SPR_40x_ESR] =3D 0x00000000; break; - case POWERPC_MMU_REAL: - cpu_abort(cs, "PowerPC in real mode should never raise " - "any MMU exceptions\n"); default: - cpu_abort(cs, "Unknown or invalid MMU model\n"); + g_assert_not_reached(); } break; case -2: @@ -1359,11 +1367,8 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr e= addr, env->spr[SPR_40x_ESR] =3D 0x00000000; } break; - case POWERPC_MMU_REAL: - cpu_abort(cs, "PowerPC in real mode should never raise " - "any MMU exceptions\n"); default: - cpu_abort(cs, "Unknown or invalid MMU model\n"); + g_assert_not_reached(); } break; case -2: @@ -1457,6 +1462,9 @@ bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAcces= sType access_type, case POWERPC_MMU_BOOKE206: return ppc_booke_xlate(cpu, eaddr, access_type, raddrp, psizep, protp, mmu_idx, guest_visible); + case POWERPC_MMU_REAL: + return ppc_real_mode_xlate(cpu, eaddr, access_type, raddrp, psizep, + protp); case POWERPC_MMU_MPC8xx: cpu_abort(env_cpu(&cpu->env), "MPC8xx MMU model is not implemented= \n"); default: --=20 2.43.0