Skip to contentSkip to conversation

target-mips: fix updating XContext on mmu exception

PATCH Superseded Yongbok Kim 2 participants 2 messages Oct 2, 2015 – Oct 6, 2015

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 target-mips: fix updating XContext on mmu exception

Correct updating XContext.Region field on mmu exceptions. If Config3.CTXTC = 0 then the R filed of XContext has to be updated with the value of bits 63..62 of the virtual address upon a TLB exception.

---
 target-mips/helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-mips/helper.c +1 -1
index 01c4461..8ffc990 100644
@@ -294,7 +294,7 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address,
 #if defined(TARGET_MIPS64)
     env->CP0_EntryHi &= env->SEGMask;
     env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) |
-                        ((address & 0xC00000000000ULL) >> (55 - env->SEGBITS)) |
+                        (((address >> 62) & 0x3) << (env->SEGBITS - 9)) |
                         ((address & ((1ULL << env->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9);
 #endif
     cs->exception_index = exception;
Signature · 1 line
1.7.1
#1 lore raw
Quoted 2 lines · Yongbok Kim

Correct updating XContext.Region field on mmu exceptions. If Config3.CTXTC = 0 then the R filed of XContext has to be updated

s/filed/field

Quoted 13 lines

with the value of bits 63..62 of the virtual address upon a TLB exception.

---
 target-mips/helper.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
target-mips/helper.c +0 -0
index 01c4461..8ffc990 100644

target-mips/helper.c static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, · line 297

Quoted 5 lines
target-mips/helper.c +1 -1
@@ -294,7 +294,7 @@ static void raise_mmu_exception(CPUMIPSState *env, target_ulong address,
 #if defined(TARGET_MIPS64)
     env->CP0_EntryHi &= env->SEGMask;
     env->CP0_XContext = (env->CP0_XContext & ((~0ULL) << (env->SEGBITS - 7))) |
-                        ((address & 0xC00000000000ULL) >> (55 - env->SEGBITS)) |
+                        (((address >> 62) & 0x3) << (env->SEGBITS - 9)) |

Did you consider using extract64?

target-mips/helper.c static void raise_mmu_exception(CPUMIPSState *env, target_ulong address, · line 298

Quoted 1 line
target-mips/helper.c +0 -0
                         ((address & ((1ULL << env->SEGBITS) - 1) & 0xFFFFFFFFFFFFE000ULL) >> 9);

Care to fix this >80 chars line while you are on this? :)

Thanks,
Leon

Quoted 3 lines
target-mips/helper.c +0 -0
 #endif
     cs->exception_index = exception;