[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v7 24/61] target/ppc/mmu_common.c: Split off real mode handli
|
From: |
Nicholas Piggin |
|
Subject: |
Re: [PATCH v7 24/61] target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb() |
|
Date: |
Fri, 17 May 2024 15:26:52 +1000 |
On Mon May 13, 2024 at 9:27 AM AEST, BALATON Zoltan wrote:
> Add ppc_real_mode_xlate() to handle real mode translation and allow
> removing this case from ppc_jumbo_xlate().
>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
> ---
> 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 = (type == ACCESS_CODE) ? !FIELD_EX64(env->msr, MSR, IR)
> - : !FIELD_EX64(env->msr, MSR, DR);
> - if (real_mode) {
> - ctx->raddr = eaddr;
> - ctx->prot = PAGE_RWX;
> - return 0;
> - }
> -
> switch (env->mmu_model) {
> case POWERPC_MMU_SOFT_6xx:
> return mmu6xx_get_physical_address(env, ctx, eaddr, access_type,
> type);
> case POWERPC_MMU_SOFT_4xx:
> return mmu40x_get_physical_address(env, &ctx->raddr, &ctx->prot,
> eaddr,
> 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
> eaddr,
> return false;
> }
>
> +static bool ppc_real_mode_xlate(PowerPCCPU *cpu, vaddr eaddr,
> + MMUAccessType access_type,
> + hwaddr *raddrp, int *psizep, int *protp)
> +{
> + CPUPPCState *env = &cpu->env;
> +
> + if (access_type == MMU_INST_FETCH ? !FIELD_EX64(env->msr, MSR, IR)
> + : !FIELD_EX64(env->msr, MSR, DR)) {
> + *raddrp = eaddr;
> + *protp = PAGE_RWX;
> + *psizep = TARGET_PAGE_BITS;
> + return true;
> + } else if (env->mmu_model == 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
> eaddr,
> int type;
> int ret;
>
> + if (ppc_real_mode_xlate(cpu, eaddr, access_type, raddrp, psizep, protp))
> {
> + return true;
> + }
> +
> if (access_type == MMU_INST_FETCH) {
> /* code access */
> type = ACCESS_CODE;
> @@ -1303,11 +1314,8 @@ static bool ppc_jumbo_xlate(PowerPCCPU *cpu, vaddr
> eaddr,
> env->spr[SPR_40x_DEAR] = eaddr;
> env->spr[SPR_40x_ESR] = 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
> eaddr,
> env->spr[SPR_40x_ESR] = 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,
> MMUAccessType 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:
- [PATCH v7 12/61] target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb(), (continued)
- [PATCH v7 12/61] target/ppc/mmu_common.c: Split off real mode cases in get_physical_address_wtlb(), BALATON Zoltan, 2024/05/12
- [PATCH v7 14/61] target/ppc/mmu_common.c: Fix misindented qemu_log_mask() calls, BALATON Zoltan, 2024/05/12
- [PATCH v7 16/61] target/ppc/mmu_common.c: Replace hard coded constants in ppc_jumbo_xlate(), BALATON Zoltan, 2024/05/12
- [PATCH v7 17/61] target/ppc/mmu_common.c: Don't use mmu_ctx_t for mmu40x_get_physical_address(), BALATON Zoltan, 2024/05/12
- [PATCH v7 15/61] target/ppc/mmu_common.c: Deindent ppc_jumbo_xlate(), BALATON Zoltan, 2024/05/12
- [PATCH v7 18/61] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke_get_physical_address(), BALATON Zoltan, 2024/05/12
- [PATCH v7 19/61] target/ppc/mmu_common.c: Don't use mmu_ctx_t in mmubooke206_get_physical_address(), BALATON Zoltan, 2024/05/12
- [PATCH v7 21/61] target/ppc/mmu_common.c: Split off BookE handling from ppc_jumbo_xlate(), BALATON Zoltan, 2024/05/12
- [PATCH v7 23/61] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 2, BALATON Zoltan, 2024/05/12
- [PATCH v7 24/61] target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb(), BALATON Zoltan, 2024/05/12
- Re: [PATCH v7 24/61] target/ppc/mmu_common.c: Split off real mode handling from get_physical_address_wtlb(),
Nicholas Piggin <=
- [PATCH v7 30/61] target/ppc: Split off common embedded TLB init, BALATON Zoltan, 2024/05/12
- [PATCH v7 34/61] target/ppc: Move out BookE and related MMU functions from mmu_common.c, BALATON Zoltan, 2024/05/12
- [PATCH v7 20/61] target/ppc/mmu_common.c: Remove BookE from direct store handling, BALATON Zoltan, 2024/05/12
- [PATCH v7 22/61] target/ppc/mmu_common.c: Simplify ppc_booke_xlate() part 1, BALATON Zoltan, 2024/05/12
- [PATCH v7 25/61] target/ppc/mmu_common.c: Split off 40x cases from ppc_jumbo_xlate(), BALATON Zoltan, 2024/05/12
- [PATCH v7 26/61] target/ppc/mmu_common.c: Transform ppc_jumbo_xlate() into ppc_6xx_xlate(), BALATON Zoltan, 2024/05/12
- [PATCH v7 27/61] target/ppc/mmu_common.c: Move mmu_ctx_t type to mmu_common.c, BALATON Zoltan, 2024/05/12
- [PATCH v7 28/61] target/ppc/mmu_common.c: Remove pte_update_flags(), BALATON Zoltan, 2024/05/12