qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: deller@kernel.org
To: qemu-devel@nongnu.org
Cc: Richard Henderson <richard.henderson@linaro.org>,
	Helge Deller <deller@gmx.de>
Subject: [PATCH 4/5] target/hppa: Use privilege helper in hppa_get_physical_address()
Date: Thu, 24 Aug 2023 23:04:33 +0200	[thread overview]
Message-ID: <20230824210434.151971-5-deller@kernel.org> (raw)
In-Reply-To: <20230824210434.151971-1-deller@kernel.org>

From: Helge Deller <deller@gmx.de>

Convert hppa_get_physical_address() to use the privilege helper macro.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/mem_helper.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/target/hppa/mem_helper.c b/target/hppa/mem_helper.c
index 6f04c101dd..66cf84a0d9 100644
--- a/target/hppa/mem_helper.c
+++ b/target/hppa/mem_helper.c
@@ -73,7 +73,7 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
                               int type, hwaddr *pphys, int *pprot)
 {
     hwaddr phys;
-    int prot, r_prot, w_prot, x_prot;
+    int prot, r_prot, w_prot, x_prot, mmu_priv;
     hppa_tlb_entry *ent;
     int ret = -1;
 
@@ -97,9 +97,10 @@ int hppa_get_physical_address(CPUHPPAState *env, vaddr addr, int mmu_idx,
     phys = ent->pa + (addr & ~TARGET_PAGE_MASK);
 
     /* Map TLB access_rights field to QEMU protection.  */
-    r_prot = (mmu_idx <= ent->ar_pl1) * PAGE_READ;
-    w_prot = (mmu_idx <= ent->ar_pl2) * PAGE_WRITE;
-    x_prot = (ent->ar_pl2 <= mmu_idx && mmu_idx <= ent->ar_pl1) * PAGE_EXEC;
+    mmu_priv = MMU_IDX_TO_PRIV(mmu_idx);
+    r_prot = (mmu_priv <= ent->ar_pl1) * PAGE_READ;
+    w_prot = (mmu_priv <= ent->ar_pl2) * PAGE_WRITE;
+    x_prot = (ent->ar_pl2 <= mmu_priv && mmu_priv <= ent->ar_pl1) * PAGE_EXEC;
     switch (ent->ar_type) {
     case 0: /* read-only: data page */
         prot = r_prot;
-- 
2.41.0



  parent reply	other threads:[~2023-08-25  1:04 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-24 21:04 [PATCH 0/5] target/hppa: Clean up conversion from/to MMU index and priviledge level deller
2023-08-24 21:04 ` [PATCH 1/5] target/hppa: Add missing PL1 and PL2 priviledge levels deller
2023-08-25  7:11   ` Philippe Mathieu-Daudé
2023-08-24 21:04 ` [PATCH 2/5] target/hppa: Add priviledge to MMU index conversion helpers deller
2023-08-25  7:09   ` Philippe Mathieu-Daudé
2023-08-24 21:04 ` [PATCH 3/5] target/hppa: Do not use hardcoded value for tlb_flush_*() deller
2023-08-25  7:14   ` Philippe Mathieu-Daudé
2023-08-24 21:04 ` deller [this message]
2023-08-25  7:15   ` [PATCH 4/5] target/hppa: Use privilege helper in hppa_get_physical_address() Philippe Mathieu-Daudé
2023-08-24 21:04 ` [PATCH 5/5] target/hppa: Switch to use MMU indices 11-15 deller

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=20230824210434.151971-5-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --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).