On Wed May 8, 2024 at 10:15 AM AEST, BALATON Zoltan wrote: > This function is not used from any other files so make it static and > fix the maybe used uninitialised warnings this has uncovered. Also > remove mmu_ctx_t definition from internal.h as this type is only used > within this file.
If you add a /* quiet used uninitialized warning */ or similar comment on the memset then. Reviewed-by: Nicholas Piggin <npig...@gmail.com> If you respin you could, put the prot fixes as their own patch but pretty minor thing if you can't be bothered. > > Signed-off-by: BALATON Zoltan <bala...@eik.bme.hu> > --- > target/ppc/internal.h | 17 +---------------- > target/ppc/mmu_common.c | 18 +++++++++++++++--- > 2 files changed, 16 insertions(+), 19 deletions(-) > > diff --git a/target/ppc/internal.h b/target/ppc/internal.h > index 98b41a970c..4a90dd2584 100644 > --- a/target/ppc/internal.h > +++ b/target/ppc/internal.h > @@ -257,28 +257,13 @@ static inline int prot_for_access_type(MMUAccessType > access_type) > > /* PowerPC MMU emulation */ > > -typedef struct mmu_ctx_t mmu_ctx_t; > - > bool ppc_xlate(PowerPCCPU *cpu, vaddr eaddr, MMUAccessType access_type, > hwaddr *raddrp, int *psizep, int *protp, > int mmu_idx, bool guest_visible); > -int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, > - target_ulong eaddr, > - MMUAccessType access_type, int type, > - int mmu_idx); > + > /* Software driven TLB helpers */ > int ppc6xx_tlb_getnum(CPUPPCState *env, target_ulong eaddr, > int way, int is_code); > -/* Context used internally during MMU translations */ > -struct mmu_ctx_t { > - hwaddr raddr; /* Real address */ > - hwaddr eaddr; /* Effective address */ > - int prot; /* Protection bits */ > - hwaddr hash[2]; /* Pagetable hash values */ > - target_ulong ptem; /* Virtual segment ID | API */ > - int key; /* Access key */ > - int nx; /* Non-execute area */ > -}; > > #endif /* !CONFIG_USER_ONLY */ > > diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c > index 63b5fb98d1..d92c9607b8 100644 > --- a/target/ppc/mmu_common.c > +++ b/target/ppc/mmu_common.c > @@ -36,6 +36,17 @@ > > /* #define DUMP_PAGE_TABLES */ > > +/* Context used internally during MMU translations */ > +typedef struct { > + hwaddr raddr; /* Real address */ > + hwaddr eaddr; /* Effective address */ > + int prot; /* Protection bits */ > + hwaddr hash[2]; /* Pagetable hash values */ > + target_ulong ptem; /* Virtual segment ID | API */ > + int key; /* Access key */ > + int nx; /* Non-execute area */ > +} mmu_ctx_t; > + > void ppc_store_sdr1(CPUPPCState *env, target_ulong value) > { > PowerPCCPU *cpu = env_archcpu(env); > @@ -667,7 +678,7 @@ static int mmubooke_get_physical_address(CPUPPCState > *env, mmu_ctx_t *ctx, > qemu_log_mask(CPU_LOG_MMU, > "%s: access %s " TARGET_FMT_lx " => " HWADDR_FMT_plx > " %d %d\n", __func__, ret < 0 ? "refused" : "granted", > - address, raddr, ctx->prot, ret); > + address, raddr, ret == -1 ? 0 : ctx->prot, ret); > return ret; > } > > @@ -883,7 +894,7 @@ found_tlb: > qemu_log_mask(CPU_LOG_MMU, "%s: access %s " TARGET_FMT_lx " => " > HWADDR_FMT_plx " %d %d\n", __func__, > ret < 0 ? "refused" : "granted", address, raddr, > - ctx->prot, ret); > + ret == -1 ? 0 : ctx->prot, ret); > return ret; > } > > @@ -1131,7 +1142,7 @@ void dump_mmu(CPUPPCState *env) > } > } > > -int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, > +static int get_physical_address_wtlb(CPUPPCState *env, mmu_ctx_t *ctx, > target_ulong eaddr, > MMUAccessType access_type, int type, > int mmu_idx) > @@ -1150,6 +1161,7 @@ int get_physical_address_wtlb(CPUPPCState *env, > mmu_ctx_t *ctx, > if (real_mode && (env->mmu_model == POWERPC_MMU_SOFT_6xx || > env->mmu_model == POWERPC_MMU_SOFT_4xx || > env->mmu_model == POWERPC_MMU_REAL)) { > + memset(ctx, 0, sizeof(*ctx)); > ctx->raddr = eaddr; > ctx->prot = PAGE_RWX; > return 0;