From: deller@kernel.org
To: Richard Henderson <richard.henderson@linaro.org>,
Peter Maydell <peter.maydell@linaro.org>,
qemu-devel@nongnu.org
Cc: "Helge Deller" <deller@gmx.de>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>
Subject: [PULL 2/5] target/hppa: Add privilege to MMU index conversion helpers
Date: Sun, 27 Aug 2023 17:17:43 +0200 [thread overview]
Message-ID: <20230827151747.290653-3-deller@kernel.org> (raw)
In-Reply-To: <20230827151747.290653-1-deller@kernel.org>
From: Helge Deller <deller@gmx.de>
Add two macros which convert privilege level to/from MMU index:
- PRIV_TO_MMU_IDX(priv)
returns the MMU index for the given privilege level
- MMU_IDX_TO_PRIV(mmu_idx)
returns the corresponding privilege level for this MMU index
The introduction of those macros make the code easier to read and
will help to improve performance in follow-up patch.
Signed-off-by: Helge Deller <deller@gmx.de>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
target/hppa/cpu.h | 5 ++++-
target/hppa/translate.c | 9 +++++----
2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/target/hppa/cpu.h b/target/hppa/cpu.h
index 6c5b0e67c8..50b513f0ea 100644
--- a/target/hppa/cpu.h
+++ b/target/hppa/cpu.h
@@ -36,6 +36,9 @@
#define MMU_USER_IDX 3
#define MMU_PHYS_IDX 4
+#define PRIV_TO_MMU_IDX(priv) (priv)
+#define MMU_IDX_TO_PRIV(mmu_idx) (mmu_idx)
+
#define TARGET_INSN_START_EXTRA_WORDS 1
/* Hardware exceptions, interrupts, faults, and traps. */
@@ -236,7 +239,7 @@ static inline int cpu_mmu_index(CPUHPPAState *env, bool ifetch)
return MMU_USER_IDX;
#else
if (env->psw & (ifetch ? PSW_C : PSW_D)) {
- return env->iaoq_f & 3;
+ return PRIV_TO_MMU_IDX(env->iaoq_f & 3);
}
return MMU_PHYS_IDX; /* mmu disabled */
#endif
diff --git a/target/hppa/translate.c b/target/hppa/translate.c
index d66fcb3e6a..e3af668252 100644
--- a/target/hppa/translate.c
+++ b/target/hppa/translate.c
@@ -4057,14 +4057,15 @@ static void hppa_tr_init_disas_context(DisasContextBase *dcbase, CPUState *cs)
ctx->tb_flags = ctx->base.tb->flags;
#ifdef CONFIG_USER_ONLY
- ctx->privilege = MMU_USER_IDX;
+ ctx->privilege = MMU_IDX_TO_PRIV(MMU_USER_IDX);
ctx->mmu_idx = MMU_USER_IDX;
- ctx->iaoq_f = ctx->base.pc_first | MMU_USER_IDX;
- ctx->iaoq_b = ctx->base.tb->cs_base | MMU_USER_IDX;
+ ctx->iaoq_f = ctx->base.pc_first | ctx->privilege;
+ ctx->iaoq_b = ctx->base.tb->cs_base | ctx->privilege;
ctx->unalign = (ctx->tb_flags & TB_FLAG_UNALIGN ? MO_UNALN : MO_ALIGN);
#else
ctx->privilege = (ctx->tb_flags >> TB_FLAG_PRIV_SHIFT) & 3;
- ctx->mmu_idx = (ctx->tb_flags & PSW_D ? ctx->privilege : MMU_PHYS_IDX);
+ ctx->mmu_idx = (ctx->tb_flags & PSW_D ?
+ PRIV_TO_MMU_IDX(ctx->privilege) : MMU_PHYS_IDX);
/* Recover the IAOQ values from the GVA + PRIV. */
uint64_t cs_base = ctx->base.tb->cs_base;
--
2.41.0
next prev parent reply other threads:[~2023-08-27 15:19 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-27 15:17 [PULL 0/5] Devel hppa priv cleanup2 patches deller
2023-08-27 15:17 ` [PULL 1/5] target/hppa: Add missing PL1 and PL2 privilege levels deller
2023-08-27 15:17 ` deller [this message]
2023-08-27 15:17 ` [PULL 3/5] target/hppa: Do not use hardcoded value for tlb_flush_*() deller
2023-08-27 15:17 ` [PULL 4/5] target/hppa: Use privilege helper in hppa_get_physical_address() deller
2023-08-27 15:17 ` [PULL 5/5] target/hppa: Switch to use MMU indices 11-15 deller
2023-08-28 21:14 ` [PULL 0/5] Devel hppa priv cleanup2 patches Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230827151747.290653-3-deller@kernel.org \
--to=deller@kernel.org \
--cc=deller@gmx.de \
--cc=peter.maydell@linaro.org \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).