From 41db525e9c6e4c98d6e41c403c7dc704ce0e77aa Mon Sep 17 00:00:00 2001 From: Richard Henderson Date: Thu, 22 Apr 2010 22:56:42 -0700 Subject: target-sparc: Fix address masking in ldqf and stqf. Use address_mask on both addr and addr+8 in both these routines, rather than explicit masking with 0xffffffff. Reformulate address_mask to return a result, rather than masking a pass-by-reference argument. Signed-off-by: Richard Henderson Signed-off-by: Blue Swirl --- target-sparc/op_helper.c | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/target-sparc/op_helper.c b/target-sparc/op_helper.c index 704631a24e..b27778bb2a 100644 --- a/target-sparc/op_helper.c +++ b/target-sparc/op_helper.c @@ -201,12 +201,13 @@ static void replace_tlb_1bit_lru(SparcTLBEntry *tlb, #endif -static inline void address_mask(CPUState *env1, target_ulong *addr) +static inline target_ulong address_mask(CPUState *env1, target_ulong addr) { #ifdef TARGET_SPARC64 if (AM_CHECK(env1)) - *addr &= 0xffffffffULL; + addr &= 0xffffffffULL; #endif + return addr; } static void raise_exception(int tt) @@ -1923,7 +1924,7 @@ uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign) raise_exception(TT_PRIV_ACT); helper_check_align(addr, size - 1); - address_mask(env, &addr); + addr = address_mask(env, addr); switch (asi) { case 0x82: // Primary no-fault @@ -2026,7 +2027,7 @@ void helper_st_asi(target_ulong addr, target_ulong val, int asi, int size) raise_exception(TT_PRIV_ACT); helper_check_align(addr, size - 1); - address_mask(env, &addr); + addr = address_mask(env, addr); /* Convert to little endian */ switch (asi) { @@ -2944,8 +2945,7 @@ void helper_stdf(target_ulong addr, int mem_idx) break; } #else - address_mask(env, &addr); - stfq_raw(addr, DT0); + stfq_raw(address_mask(env, addr), DT0); #endif } @@ -2969,8 +2969,7 @@ void helper_lddf(target_ulong addr, int mem_idx) break; } #else - address_mask(env, &addr); - DT0 = ldfq_raw(addr); + DT0 = ldfq_raw(address_mask(env, addr)); #endif } @@ -3003,9 +3002,8 @@ void helper_ldqf(target_ulong addr, int mem_idx) break; } #else - address_mask(env, &addr); - u.ll.upper = ldq_raw(addr); - u.ll.lower = ldq_raw((addr + 8) & 0xffffffffULL); + u.ll.upper = ldq_raw(address_mask(env, addr)); + u.ll.lower = ldq_raw(address_mask(env, addr + 8)); QT0 = u.q; #endif } @@ -3040,9 +3038,8 @@ void helper_stqf(target_ulong addr, int mem_idx) } #else u.q = QT0; - address_mask(env, &addr); - stq_raw(addr, u.ll.upper); - stq_raw((addr + 8) & 0xffffffffULL, u.ll.lower); + stq_raw(address_mask(env, addr), u.ll.upper); + stq_raw(address_mask(env, addr + 8), u.ll.lower); #endif } -- cgit v1.2.3