[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 65/96] target/ppc: Reorganise and rename ppc_hash32_pp_prot()
From: |
Nicholas Piggin |
Subject: |
[PULL 65/96] target/ppc: Reorganise and rename ppc_hash32_pp_prot() |
Date: |
Fri, 26 Jul 2024 09:53:38 +1000 |
From: BALATON Zoltan <balaton@eik.bme.hu>
Reorganise ppc_hash32_pp_prot() swapping the if legs so it does not
test for negative first and clean up to make it shorter. Also rename
it to ppc_hash32_prot().
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-hash32.c | 2 +-
target/ppc/mmu-hash32.h | 35 +++++++++++++----------------------
target/ppc/mmu_common.c | 2 +-
3 files changed, 15 insertions(+), 24 deletions(-)
diff --git a/target/ppc/mmu-hash32.c b/target/ppc/mmu-hash32.c
index d5f2057eb1..8a446c8a7d 100644
--- a/target/ppc/mmu-hash32.c
+++ b/target/ppc/mmu-hash32.c
@@ -45,7 +45,7 @@ static int ppc_hash32_pte_prot(int mmu_idx,
key = !!(mmuidx_pr(mmu_idx) ? (sr & SR32_KP) : (sr & SR32_KS));
pp = pte.pte1 & HPTE32_R_PP;
- return ppc_hash32_pp_prot(key, pp, !!(sr & SR32_NX));
+ return ppc_hash32_prot(key, pp, !!(sr & SR32_NX));
}
static target_ulong hash32_bat_size(int mmu_idx,
diff --git a/target/ppc/mmu-hash32.h b/target/ppc/mmu-hash32.h
index f0ce6951b4..bc4eedbecc 100644
--- a/target/ppc/mmu-hash32.h
+++ b/target/ppc/mmu-hash32.h
@@ -102,49 +102,40 @@ static inline void ppc_hash32_store_hpte1(PowerPCCPU *cpu,
stl_phys(CPU(cpu)->as, base + pte_offset + HASH_PTE_SIZE_32 / 2, pte1);
}
-static inline int ppc_hash32_pp_prot(bool key, int pp, bool nx)
+static inline int ppc_hash32_prot(bool key, int pp, bool nx)
{
int prot;
- if (key == 0) {
+ if (key) {
switch (pp) {
case 0x0:
- case 0x1:
- case 0x2:
- prot = PAGE_READ | PAGE_WRITE;
+ prot = 0;
break;
-
+ case 0x1:
case 0x3:
prot = PAGE_READ;
break;
-
+ case 0x2:
+ prot = PAGE_READ | PAGE_WRITE;
+ break;
default:
- abort();
+ g_assert_not_reached();
}
} else {
switch (pp) {
case 0x0:
- prot = 0;
- break;
-
case 0x1:
- case 0x3:
- prot = PAGE_READ;
- break;
-
case 0x2:
prot = PAGE_READ | PAGE_WRITE;
break;
-
+ case 0x3:
+ prot = PAGE_READ;
+ break;
default:
- abort();
+ g_assert_not_reached();
}
}
- if (nx == 0) {
- prot |= PAGE_EXEC;
- }
-
- return prot;
+ return nx ? prot : prot | PAGE_EXEC;
}
typedef struct {
diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index e2542694f0..08c5b61f76 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -120,7 +120,7 @@ static int ppc6xx_tlb_pte_check(mmu_ctx_t *ctx,
target_ulong pte0,
}
/* Keep the matching PTE information */
ctx->raddr = pte1;
- ctx->prot = ppc_hash32_pp_prot(ctx->key, pp, ctx->nx);
+ ctx->prot = ppc_hash32_prot(ctx->key, pp, ctx->nx);
if (check_prot_access_type(ctx->prot, access_type)) {
/* Access granted */
qemu_log_mask(CPU_LOG_MMU, "PTE access granted !\n");
--
2.45.2
- [PULL 57/96] target/ppc: Move VSX logical instructions to decodetree., (continued)
- [PULL 57/96] target/ppc: Move VSX logical instructions to decodetree., Nicholas Piggin, 2024/07/25
- [PULL 58/96] target/ppc: Moving VSX scalar storage access insns to decodetree., Nicholas Piggin, 2024/07/25
- [PULL 59/96] target/ppc: Move VSX vector with length storage access insns to decodetree., Nicholas Piggin, 2024/07/25
- [PULL 60/96] target/ppc: Move VSX vector storage access insns to decodetree., Nicholas Piggin, 2024/07/25
- [PULL 62/96] target/ppc: Move get/set_avr64 functions to vmx-impl.c.inc., Nicholas Piggin, 2024/07/25
- [PULL 63/96] target/ppc: Update VMX storage access insns to use tcg_gen_qemu_ld/st_i128., Nicholas Piggin, 2024/07/25
- [PULL 61/96] target/ppc: Move VSX fp compare insns to decodetree., Nicholas Piggin, 2024/07/25
- [PULL 67/96] target/ppc/mmu_common.c: Remove single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 64/96] target/ppc : Update VSX storage access insns to use tcg_gen_qemu _ld/st_i128., Nicholas Piggin, 2024/07/25
- [PULL 66/96] target/ppc/mmu_common.c: Remove local name for a constant, Nicholas Piggin, 2024/07/25
- [PULL 65/96] target/ppc: Reorganise and rename ppc_hash32_pp_prot(),
Nicholas Piggin <=
- [PULL 69/96] target/ppc/mmu_common.c: Remove another single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 68/96] target/ppc/mmu_common.c: Remove single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 70/96] target/ppc/mmu_common.c: Remove yet another single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 72/96] target/ppc/mmu_common.c: Simplify 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 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 77/96] target/ppc/mmu_common.c: Convert local variable to bool, Nicholas Piggin, 2024/07/25
- [PULL 71/96] target/ppc/mmu_common.c: Return directly in ppc6xx_tlb_pte_check(), 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