In order to simplify a bit, pass the PTE size in
bytes rather than bits.

Signed-off-by: Philippe Mathieu-Daudé <phi...@linaro.org>
---
 target/mips/tcg/sysemu/tlb_helper.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/target/mips/tcg/sysemu/tlb_helper.c 
b/target/mips/tcg/sysemu/tlb_helper.c
index 3ba6d369a6..a8caf3ade8 100644
--- a/target/mips/tcg/sysemu/tlb_helper.c
+++ b/target/mips/tcg/sysemu/tlb_helper.c
@@ -592,13 +592,13 @@ static void raise_mmu_exception(CPUMIPSState *env, 
target_ulong address,
  * resulting in a TLB or XTLB Refill exception.
  */
 
-static bool get_pte(CPUMIPSState *env, uint64_t vaddr, int entry_size,
+static bool get_pte(CPUMIPSState *env, uint64_t vaddr, unsigned entry_bytes,
         uint64_t *pte)
 {
-    if ((vaddr & ((entry_size >> 3) - 1)) != 0) {
+    if ((vaddr & (entry_bytes - 1)) != 0) {
         return false;
     }
-    if (entry_size == 64) {
+    if (entry_bytes == 8) {
         *pte = cpu_ldq_code(env, vaddr);
     } else {
         *pte = cpu_ldl_code(env, vaddr);
@@ -607,11 +607,11 @@ static bool get_pte(CPUMIPSState *env, uint64_t vaddr, 
int entry_size,
 }
 
 static uint64_t get_tlb_entry_layout(CPUMIPSState *env, uint64_t entry,
-        int entry_size, int ptei)
+                                     unsigned entry_bytes, int ptei)
 {
     uint64_t result = entry;
     uint64_t rixi;
-    if (ptei > entry_size) {
+    if (ptei > entry_bytes >> 3) {
         ptei -= 32;
     }
     result >>= (ptei - 2);
@@ -630,8 +630,8 @@ static int walk_directory(CPUMIPSState *env, uint64_t 
*vaddr,
     int psn = (env->CP0_PWCtl >> CP0PC_PSN) & 0x3F;
     int hugepg = (env->CP0_PWCtl >> CP0PC_HUGEPG) & 0x1;
     int pf_ptew = (env->CP0_PWField >> CP0PF_PTEW) & 0x3F;
-    uint32_t direntry_size = 1 << (directory_shift + 3);
-    uint32_t leafentry_size = 1 << (leaf_shift + 3);
+    uint32_t direntry_size = 1 << directory_shift;
+    uint32_t leafentry_size = 1 << leaf_shift;
     uint64_t entry;
     uint64_t paddr;
     int prot;
@@ -768,7 +768,7 @@ static bool page_table_walk_refill(CPUMIPSState *env, vaddr 
address,
     ptoffset0 = (ptindex >> 1) << (leaf_shift + 1);
     ptoffset1 = ptoffset0 | (1 << (leaf_shift));
 
-    leafentry_size = 1 << (leaf_shift + 3);
+    leafentry_size = 1 << leaf_shift;
 
     /* Global Directory */
     if (gdw > 0) {
-- 
2.45.2


Reply via email to