[PATCH 4/5] target/hppa: Use privilege helper in hppa_get_physical_address()

deller@kernel.org posted 5 patches 1 year, 3 months ago
Maintainers: Richard Henderson <richard.henderson@linaro.org>
[PATCH 4/5] target/hppa: Use privilege helper in hppa_get_physical_address()
Posted by deller@kernel.org 1 year, 3 months ago
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
Re: [PATCH 4/5] target/hppa: Use privilege helper in hppa_get_physical_address()
Posted by Philippe Mathieu-Daudé 1 year, 3 months ago
On 24/8/23 23:04, deller@kernel.org wrote:
> 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(-)

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>