cputlb: cast size_t to target_ulong before using for address masks
PATCH 1/1 cputlb: cast size_t to target_ulong before using for address masks
While size_t is defined to happily access the biggest host object this isn't the case when generating masks for 64 bit guests on 32 bit hosts. Otherwise we end up truncating the address when we fall back to our unaligned helper.
--- accel/tcg/cputlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
accel/tcg/cputlb.c +1 -1
@@ -1306,7 +1306,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,uint64_t r1, r2;unsigned shift; do_unaligned_access: - addr1 = addr & ~(size -1 ); + addr1 = addr & ~((target_ulong )size -1 ); addr2 = addr1 + size; r1 =full_load (env, addr1, oi, retaddr); r2 =full_load (env, addr2, oi, retaddr);
Signature · 1 line
2.20.1
В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
Quoted 1 line
addr1 = addr & ~((target_ulong)size - 1);
yes, this fixes my hang! Thanks!
Alex Bennée
Tested-by Andrew RandrianasuluQuoted 4 lines · Andrew Randrianasulu
В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
Quoted 1 line
addr1 = addr & ~((target_ulong)size - 1);
yes, this fixes my hang! Thanks!
Can I take that as a:
?
--
Alex Bennée
В сообщении от Thursday 06 June 2019 20:04:07 Alex Bennée написал(а):
Quoted 6 lines
Quoted 3 lines · Andrew Randrianasulu
В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
Quoted 1 line
addr1 = addr & ~((target_ulong)size - 1);
Quoted 7 lines
Quoted 1 line
yes, this fixes my hang! Thanks!
Can I take that as a:
Tested-by Andrew Randrianasulu <[email protected]>?
Yes, while I only tested 64-bit x86-64 kernel on 32-bit x86 host, not other machines.
Quoted 4 lines
--
Alex Bennée
Quoted 10 lines · Alex Bennée
While
size_tis defined to happily access the biggest host object this isn't the case when generating masks for 64 bit guests on 32 bit hosts. Otherwise we end up truncating the address when we fall back to our unaligned helper.Cc Andrew Randrianasulu <[email protected]>Signed-off-by Alex Bennée <[email protected]>--- accel/tcg/cputlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
r~
Quoted 6 lines · Alex Bennée
While
size_tis defined to happily access the biggest host object this isn't the case when generating masks for 64 bit guests on 32 bit hosts. Otherwise we end up truncating the address when we fall back to our unaligned helper.Cc Andrew Randrianasulu <[email protected]>
Quoted 10 lines
Signed-off-by Alex Bennée <[email protected]>--- accel/tcg/cputlb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)accel/tcg/cputlb.c +0
-0
accel/tcg/cputlb.c load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi, · line 1309
Quoted 5 lines
accel/tcg/cputlb.c +1
-1@@ -1306,7 +1306,7 @@ load_helper(CPUArchState *env, target_ulong addr, TCGMemOpIdx oi,uint64_t r1, r2;unsigned shift; do_unaligned_access: - addr1 = addr & ~(size -1 ); + addr1 = addr & ~((target_ulong )size -1 );
Tricky...
Quoted 4 lines
accel/tcg/cputlb.c +0
-0addr2 = addr1 + size; r1 =full_load (env, addr1, oi, retaddr); r2 =full_load (env, addr2, oi, retaddr);