Skip to contentSkip to conversation

ppcmas_tlb_check: Fix effective address comparison

PATCH In review Fabien Chouteau 2 participants 3 messages May 7, 2012

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ppcmas_tlb_check: Fix effective address comparison

Use size mask in both operands of effective address comparison. This is the expected as the size of EPN field in MAS2 depends on page size.

Definition of EPN field from e500v2 RM:
EPN Effective page number: Depending on page size, only the bits associated with a page boundary are valid. Bits that represent offsets within a page are ignored and should be cleared.

There is a similar (but more complicated) definition in PowerISA V2.06.

---
 target-ppc/helper.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/helper.c +1 -1
index e97e496..adb96a0 100644
@@ -1320,7 +1320,7 @@ int ppcmas_tlb_check(CPUPPCState *env, ppcmas_tlb_t *tlb,
     }
 
     /* Check effective address */
-    if ((address & mask) != (tlb->mas2 & MAS2_EPN_MASK)) {
+    if ((address & mask) != (tlb->mas2 & MAS2_EPN_MASK & mask)) {
         return -1;
     }
 
Signature · 1 line
1.7.9.5
#1 lore raw
Quoted 10 lines · Fabien Chouteau

Use size mask in both operands of effective address comparison. This is the expected as the size of EPN field in MAS2 depends on page size.

Definition of EPN field from e500v2 RM:
EPN Effective page number: Depending on page size, only the bits associated with a page boundary are valid. Bits that represent offsets within a page are ignored and should be cleared.

There is a similar (but more complicated) definition in PowerISA V2.06.

Would it make sense to do this at tlbwe time? That path is a bit less hot that the tlb check :).

Alex

Quoted 22 lines

---
target-ppc/helper.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
target-ppc/helper.c +1 -1
index e97e496..adb96a0 100644
@@ -1320,7 +1320,7 @@ int ppcmas_tlb_check(CPUPPCState *env, ppcmas_tlb_t *tlb,
    }
 
    /* Check effective address */
-    if ((address & mask) != (tlb->mas2 & MAS2_EPN_MASK)) {
+    if ((address & mask) != (tlb->mas2 & MAS2_EPN_MASK & mask)) {
        return -1;
    }
 
Signature · 1 line
1.7.9.5
#2 lore raw
Quoted 7 lines · Alexander Graf
Quoted 4 lines · Fabien Chouteau

Use size mask in both operands of effective address comparison. This is the expected as the size of EPN field in MAS2 depends on page size.

Quoted 8 lines
Quoted 6 lines

Definition of EPN field from e500v2 RM:
EPN Effective page number: Depending on page size, only the bits associated with a page boundary are valid. Bits that represent offsets within a page are ignored and should be cleared.

There is a similar (but more complicated) definition in PowerISA V2.06.

Would it make sense to do this at tlbwe time? That path is a bit less hot that the tlb check :).

Why not, I'll check that tomorrow.

Thanks,

Signature · 1 line
Fabien Chouteau