diff options
author | David Gibson <david@gibson.dropbear.id.au> | 2013-03-12 00:31:32 +0000 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2013-03-22 15:28:51 +0100 |
commit | 6a9801106ed90b8817128e15b187a9d5f71a54d9 (patch) | |
tree | aaecff34ed37b26817f9cd863f9196bcbc138ea9 /target-ppc/mmu-hash64.c | |
parent | 181488987671841407c52b6f958650f68b66f3f4 (diff) | |
download | hqemu-6a9801106ed90b8817128e15b187a9d5f71a54d9.zip hqemu-6a9801106ed90b8817128e15b187a9d5f71a54d9.tar.gz |
mmu-hash*: Fold pte_check*() logic into caller
With previous cleanups made, the 32-bit and 64-bit pte_check*() functions
are pretty trivial and only have one call site. This patch therefore
clarifies the overall code flow by folding those functions into their
call site.
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'target-ppc/mmu-hash64.c')
-rw-r--r-- | target-ppc/mmu-hash64.c | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/target-ppc/mmu-hash64.c b/target-ppc/mmu-hash64.c index 10372f0..2e109f4 100644 --- a/target-ppc/mmu-hash64.c +++ b/target-ppc/mmu-hash64.c @@ -297,32 +297,6 @@ static int ppc_hash64_check_prot(int prot, int rwx) return ret; } -static int pte64_check(struct mmu_ctx_hash64 *ctx, target_ulong pte0, - target_ulong pte1, int rwx) -{ - int access, ret, pp; - bool nx; - - pp = (pte1 & HPTE64_R_PP) | ((pte1 & HPTE64_R_PP0) >> 61); - /* No execute if either noexec or guarded bits set */ - nx = (pte1 & HPTE64_R_N) || (pte1 & HPTE64_R_G); - /* Compute access rights */ - access = ppc_hash64_pp_check(ctx->key, pp, nx); - /* Keep the matching PTE informations */ - ctx->raddr = pte1; - ctx->prot = access; - ret = ppc_hash64_check_prot(ctx->prot, rwx); - if (ret == 0) { - /* Access granted */ - LOG_MMU("PTE access granted !\n"); - } else { - /* Access right violation */ - LOG_MMU("PTE access rejected\n"); - } - - return ret; -} - static int ppc_hash64_pte_update_flags(struct mmu_ctx_hash64 *ctx, uint64_t *pte1p, int ret, int rw) { @@ -439,6 +413,8 @@ static int ppc_hash64_translate(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, ppc_hash_pte64_t pte; int target_page_bits; + assert((rwx == 0) || (rwx == 1) || (rwx == 2)); + /* 1. Handle real mode accesses */ if (((rwx == 2) && (msr_ir == 0)) || ((rwx != 2) && (msr_dr == 0))) { /* Translation is off */ @@ -471,7 +447,27 @@ static int ppc_hash64_translate(CPUPPCState *env, struct mmu_ctx_hash64 *ctx, ctx->key = !!(msr_pr ? (slb->vsid & SLB_VSID_KP) : (slb->vsid & SLB_VSID_KS)); - ret = pte64_check(ctx, pte.pte0, pte.pte1, rwx); + + int access, pp; + bool nx; + + pp = (pte.pte1 & HPTE64_R_PP) | ((pte.pte1 & HPTE64_R_PP0) >> 61); + /* No execute if either noexec or guarded bits set */ + nx = (pte.pte1 & HPTE64_R_N) || (pte.pte1 & HPTE64_R_G); + /* Compute access rights */ + access = ppc_hash64_pp_check(ctx->key, pp, nx); + /* Keep the matching PTE informations */ + ctx->raddr = pte.pte1; + ctx->prot = access; + ret = ppc_hash64_check_prot(ctx->prot, rwx); + if (ret == 0) { + /* Access granted */ + LOG_MMU("PTE access granted !\n"); + } else { + /* Access right violation */ + LOG_MMU("PTE access rejected\n"); + } + /* Update page flags */ if (ppc_hash64_pte_update_flags(ctx, &pte.pte1, ret, rwx) == 1) { ppc_hash64_store_hpte1(env, pte_offset, pte.pte1); |