[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 82/96] target/ppc: Add function to get protection key for hash32 M
From: |
Nicholas Piggin |
Subject: |
[PULL 82/96] target/ppc: Add function to get protection key for hash32 MMU |
Date: |
Fri, 26 Jul 2024 09:53:55 +1000 |
From: BALATON Zoltan <balaton@eik.bme.hu>
Add a function to get key bit from SR and use it instead of open coded
version.
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 | 9 ++++++---
target/ppc/mmu-hash32.h | 5 +++++
target/ppc/mmu_common.c | 3 +--
3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/target/ppc/mmu-hash32.c b/target/ppc/mmu-hash32.c
index 8a446c8a7d..93559447ff 100644
--- a/target/ppc/mmu-hash32.c
+++ b/target/ppc/mmu-hash32.c
@@ -42,7 +42,7 @@ static int ppc_hash32_pte_prot(int mmu_idx,
{
unsigned pp, key;
- key = !!(mmuidx_pr(mmu_idx) ? (sr & SR32_KP) : (sr & SR32_KS));
+ key = ppc_hash32_key(mmuidx_pr(mmu_idx), sr);
pp = pte.pte1 & HPTE32_R_PP;
return ppc_hash32_prot(key, pp, !!(sr & SR32_NX));
@@ -145,7 +145,6 @@ static bool ppc_hash32_direct_store(PowerPCCPU *cpu,
target_ulong sr,
{
CPUState *cs = CPU(cpu);
CPUPPCState *env = &cpu->env;
- int key = !!(mmuidx_pr(mmu_idx) ? (sr & SR32_KP) : (sr & SR32_KS));
qemu_log_mask(CPU_LOG_MMU, "direct store...\n");
@@ -206,7 +205,11 @@ static bool ppc_hash32_direct_store(PowerPCCPU *cpu,
target_ulong sr,
cpu_abort(cs, "ERROR: insn should not need address translation\n");
}
- *prot = key ? PAGE_READ | PAGE_WRITE : PAGE_READ;
+ if (ppc_hash32_key(mmuidx_pr(mmu_idx), sr)) {
+ *prot = PAGE_READ | PAGE_WRITE;
+ } else {
+ *prot = PAGE_READ;
+ }
if (check_prot_access_type(*prot, access_type)) {
*raddr = eaddr;
return true;
diff --git a/target/ppc/mmu-hash32.h b/target/ppc/mmu-hash32.h
index bc4eedbecc..5902cf8333 100644
--- a/target/ppc/mmu-hash32.h
+++ b/target/ppc/mmu-hash32.h
@@ -102,6 +102,11 @@ 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 bool ppc_hash32_key(bool pr, target_ulong sr)
+{
+ return pr ? (sr & SR32_KP) : (sr & SR32_KS);
+}
+
static inline int ppc_hash32_prot(bool key, int pp, bool nx)
{
int prot;
diff --git a/target/ppc/mmu_common.c b/target/ppc/mmu_common.c
index 339df377e8..1ed2f45ac7 100644
--- a/target/ppc/mmu_common.c
+++ b/target/ppc/mmu_common.c
@@ -310,8 +310,7 @@ static int mmu6xx_get_physical_address(CPUPPCState *env,
mmu_ctx_t *ctx,
pr = FIELD_EX64(env->msr, MSR, PR);
sr = env->sr[eaddr >> 28];
- ctx->key = (((sr & 0x20000000) && pr) ||
- ((sr & 0x40000000) && !pr)) ? 1 : 0;
+ ctx->key = ppc_hash32_key(pr, sr);
ds = sr & SR32_T;
nx = sr & SR32_NX;
vsid = sr & SR32_VSID;
--
2.45.2
- [PULL 73/96] target/ppc/mmu_common.c: Remove unused field from mmu_ctx_t, (continued)
- [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
- [PULL 78/96] target/ppc/mmu_common.c: Remove single use local variable, Nicholas Piggin, 2024/07/25
- [PULL 79/96] target/ppc/mmu_common.c: Simplify a switch statement, 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, 2024/07/25
- [PULL 82/96] target/ppc: Add function to get protection key for hash32 MMU,
Nicholas Piggin <=
- [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 89/96] target/ppc: Remove bat_size_prot(), Nicholas Piggin, 2024/07/25
- [PULL 91/96] target/ppc/mmu_common.c: Remove mmu_ctx_t, 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 93/96] target/ppc/mmu-hash32.c: Move get_pteg_offset32() to the header, Nicholas Piggin, 2024/07/25
- [PULL 92/96] target/ppc/mmu-hash32.c: Inline and remove ppc_hash32_pte_raddr(), Nicholas Piggin, 2024/07/25