[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 81/96] target/ppc/mmu_common.c: Remove ptem field from mmu_ctx_t
From: |
Nicholas Piggin |
Subject: |
[PULL 81/96] target/ppc/mmu_common.c: Remove ptem field from mmu_ctx_t |
Date: |
Fri, 26 Jul 2024 09:53:54 +1000 |
From: BALATON Zoltan <balaton@eik.bme.hu>
Instead of passing around ptem in context use it once in the same
function so it can be removed from mmu_ctx_t.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Reviewed-by: Nicholas Piggin <npiggin@gmail.com>
Signed-off-by: Nicholas Piggin <npiggin@gmail.com>
---
target/ppc/mmu_common.c | 23 ++++++++++++++---------
1 file changed, 14 insertions(+), 9 deletions(-)
diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index 784e833ff2..339df377e8 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -41,7 +41,6 @@
typedef struct {
hwaddr raddr; /* Real address */
int prot; /* Protection bits */
- target_ulong ptem; /* Virtual segment ID | API */
int key; /* Access key */
} mmu_ctx_t;
@@ -95,16 +94,18 @@ int ppc6xx_tlb_getnum(CPUPPCState *env, target_ulong eaddr,
static int ppc6xx_tlb_check(CPUPPCState *env,
mmu_ctx_t *ctx, target_ulong eaddr,
- MMUAccessType access_type, bool nx)
+ MMUAccessType access_type, target_ulong ptem,
+ bool nx)
{
ppc6xx_tlb_t *tlb;
target_ulong *pte1p;
int nr, best, way, ret;
+ bool is_code = (access_type == MMU_INST_FETCH);
best = -1;
ret = -1; /* No TLB found */
for (way = 0; way < env->nb_ways; way++) {
- nr = ppc6xx_tlb_getnum(env, eaddr, way, access_type == MMU_INST_FETCH);
+ nr = ppc6xx_tlb_getnum(env, eaddr, way, is_code);
tlb = &env->tlb.tlb6[nr];
/* This test "emulates" the PTE index match for hardware TLBs */
if ((eaddr & TARGET_PAGE_MASK) != tlb->EPN) {
@@ -124,7 +125,7 @@ static int ppc6xx_tlb_check(CPUPPCState *env,
access_type == MMU_INST_FETCH ? 'I' : 'D');
/* Check validity and table match */
if (!pte_is_valid(tlb->pte0) || ((tlb->pte0 >> 6) & 1) != 0 ||
- (tlb->pte0 & PTE_PTEM_MASK) != ctx->ptem) {
+ (tlb->pte0 & PTE_PTEM_MASK) != ptem) {
continue;
}
/* all matches should have equal RPN, WIMG & PP */
@@ -164,6 +165,10 @@ static int ppc6xx_tlb_check(CPUPPCState *env,
}
}
}
+ if (ret == -1) {
+ int r = is_code ? SPR_ICMP : SPR_DCMP;
+ env->spr[r] = ptem;
+ }
#if defined(DUMP_PAGE_TABLES)
if (qemu_loglevel_mask(CPU_LOG_MMU)) {
CPUState *cs = env_cpu(env);
@@ -293,7 +298,7 @@ static int mmu6xx_get_physical_address(CPUPPCState *env,
mmu_ctx_t *ctx,
{
PowerPCCPU *cpu = env_archcpu(env);
hwaddr hash;
- target_ulong vsid, sr, pgidx;
+ target_ulong vsid, sr, pgidx, ptem;
bool pr, ds, nx;
/* First try to find a BAT entry if there are any */
@@ -320,7 +325,7 @@ static int mmu6xx_get_physical_address(CPUPPCState *env,
mmu_ctx_t *ctx,
access_type == MMU_DATA_STORE, type);
pgidx = (eaddr & ~SEGMENT_MASK_256M) >> TARGET_PAGE_BITS;
hash = vsid ^ pgidx;
- ctx->ptem = (vsid << 7) | (pgidx >> 10);
+ ptem = (vsid << 7) | (pgidx >> 10); /* Virtual segment ID | API */
qemu_log_mask(CPU_LOG_MMU, "pte segment: key=%d ds %d nx %d vsid "
TARGET_FMT_lx "\n", ctx->key, ds, nx, vsid);
@@ -339,7 +344,7 @@ static int mmu6xx_get_physical_address(CPUPPCState *env,
mmu_ctx_t *ctx,
/* Initialize real address with an invalid value */
ctx->raddr = (hwaddr)-1ULL;
/* Software TLB search */
- return ppc6xx_tlb_check(env, ctx, eaddr, access_type, nx);
+ return ppc6xx_tlb_check(env, ctx, eaddr, access_type, ptem, nx);
}
/* Direct-store segment : absolutely *BUGGY* for now */
@@ -741,7 +746,7 @@ static bool ppc_6xx_xlate(PowerPCCPU *cpu, vaddr eaddr,
cs->exception_index = POWERPC_EXCP_IFTLB;
env->error_code = 1 << 18;
env->spr[SPR_IMISS] = eaddr;
- env->spr[SPR_ICMP] = 0x80000000 | ctx.ptem;
+ env->spr[SPR_ICMP] |= 0x80000000;
goto tlb_miss;
case -2:
/* Access rights violation */
@@ -772,7 +777,7 @@ static bool ppc_6xx_xlate(PowerPCCPU *cpu, vaddr eaddr,
env->error_code = 0;
}
env->spr[SPR_DMISS] = eaddr;
- env->spr[SPR_DCMP] = 0x80000000 | ctx.ptem;
+ env->spr[SPR_DCMP] |= 0x80000000;
tlb_miss:
env->error_code |= ctx.key << 19;
env->spr[SPR_HASH1] = ppc_hash32_hpt_base(cpu) +
--
2.45.2
- [PULL 71/96] target/ppc/mmu_common.c: Return directly in ppc6xx_tlb_pte_check(), (continued)
- [PULL 71/96] target/ppc/mmu_common.c: Return directly in ppc6xx_tlb_pte_check(), Nicholas Piggin, 2024/07/25
- [PULL 73/96] target/ppc/mmu_common.c: Remove unused field from mmu_ctx_t, Nicholas Piggin, 2024/07/25
- [PULL 72/96] target/ppc/mmu_common.c: Simplify ppc6xx_tlb_pte_check(), Nicholas Piggin, 2024/07/25
- [PULL 74/96] target/ppc/mmu_common.c: Remove hash field from mmu_ctx_t, Nicholas Piggin, 2024/07/25
- [PULL 75/96] target/ppc/mmu_common.c: Remove pte_update_flags(), Nicholas Piggin, 2024/07/25
- [PULL 76/96] target/ppc/mmu_common.c: Remove nx field from mmu_ctx_t, Nicholas Piggin, 2024/07/25
- [PULL 77/96] target/ppc/mmu_common.c: Convert local variable to bool, Nicholas Piggin, 2024/07/25
- [PULL 79/96] target/ppc/mmu_common.c: Simplify a switch statement, Nicholas Piggin, 2024/07/25
- [PULL 78/96] target/ppc/mmu_common.c: Remove single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 80/96] target/ppc/mmu_common.c: Inline and remove ppc6xx_tlb_pte_check(), Nicholas Piggin, 2024/07/25
- [PULL 81/96] target/ppc/mmu_common.c: Remove ptem field from mmu_ctx_t,
Nicholas Piggin <=
- [PULL 82/96] target/ppc: Add function to get protection key for hash32 MMU, Nicholas Piggin, 2024/07/25
- [PULL 83/96] target/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_prot(), Nicholas Piggin, 2024/07/25
- [PULL 84/96] target/ppc/mmu_common.c: Init variable in function that relies on it, Nicholas Piggin, 2024/07/25
- [PULL 85/96] target/ppc/mmu_common.c: Remove key field from mmu_ctx_t, Nicholas Piggin, 2024/07/25
- [PULL 86/96] target/ppc/mmu_common.c: Stop using ctx in ppc6xx_tlb_check(), Nicholas Piggin, 2024/07/25
- [PULL 87/96] target/ppc/mmu_common.c: Rename function parameter, Nicholas Piggin, 2024/07/25
- [PULL 88/96] target/ppc/mmu_common.c: Use defines instead of numeric constants, Nicholas Piggin, 2024/07/25
- [PULL 91/96] target/ppc/mmu_common.c: Remove mmu_ctx_t, Nicholas Piggin, 2024/07/25
- [PULL 89/96] target/ppc: Remove bat_size_prot(), Nicholas Piggin, 2024/07/25
- [PULL 90/96] target/ppc/mmu_common.c: Stop using ctx in get_bat_6xx_tlb(), Nicholas Piggin, 2024/07/25