* [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
@ 2019-06-06 15:43 Alex Bennée
2019-06-06 15:57 ` Andrew Randrianasulu
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Alex Bennée @ 2019-06-06 15:43 UTC (permalink / raw)
To: qemu-devel
Cc: Paolo Bonzini, Alex Bennée, Andrew Randrianasulu,
Richard Henderson
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.
Cc: Andrew Randrianasulu <randrianasulu@gmail.com>
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
accel/tcg/cputlb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
index b796ab1cbe..8f814a1a2c 100644
--- a/accel/tcg/cputlb.c
+++ b/accel/tcg/cputlb.c
@@ -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);
--
2.20.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
2019-06-06 15:43 [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks Alex Bennée
@ 2019-06-06 15:57 ` Andrew Randrianasulu
2019-06-06 17:04 ` Alex Bennée
2019-06-06 16:08 ` Richard Henderson
2019-06-06 23:08 ` Philippe Mathieu-Daudé
2 siblings, 1 reply; 6+ messages in thread
From: Andrew Randrianasulu @ 2019-06-06 15:57 UTC (permalink / raw)
To: Alex Bennée; +Cc: Paolo Bonzini, qemu-devel, Richard Henderson
В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
> addr1 = addr & ~((target_ulong)size - 1);
yes, this fixes my hang! Thanks!
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
2019-06-06 15:43 [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks Alex Bennée
2019-06-06 15:57 ` Andrew Randrianasulu
@ 2019-06-06 16:08 ` Richard Henderson
2019-06-06 23:08 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 6+ messages in thread
From: Richard Henderson @ 2019-06-06 16:08 UTC (permalink / raw)
To: Alex Bennée, qemu-devel; +Cc: Paolo Bonzini, Andrew Randrianasulu
On 6/6/19 10:43 AM, Alex Bennée wrote:
> 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.
>
> Cc: Andrew Randrianasulu <randrianasulu@gmail.com>
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> accel/tcg/cputlb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
r~
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
2019-06-06 15:57 ` Andrew Randrianasulu
@ 2019-06-06 17:04 ` Alex Bennée
2019-06-06 23:41 ` Andrew Randrianasulu
0 siblings, 1 reply; 6+ messages in thread
From: Alex Bennée @ 2019-06-06 17:04 UTC (permalink / raw)
To: Andrew Randrianasulu; +Cc: Paolo Bonzini, qemu-devel, Richard Henderson
Andrew Randrianasulu <randrianasulu@gmail.com> writes:
> В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
>> addr1 = addr & ~((target_ulong)size - 1);
>
> yes, this fixes my hang! Thanks!
Can I take that as a:
Tested-by: Andrew Randrianasulu <randrianasulu@gmail.com>
?
--
Alex Bennée
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
2019-06-06 15:43 [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks Alex Bennée
2019-06-06 15:57 ` Andrew Randrianasulu
2019-06-06 16:08 ` Richard Henderson
@ 2019-06-06 23:08 ` Philippe Mathieu-Daudé
2 siblings, 0 replies; 6+ messages in thread
From: Philippe Mathieu-Daudé @ 2019-06-06 23:08 UTC (permalink / raw)
To: Alex Bennée, qemu-devel
Cc: Paolo Bonzini, Andrew Randrianasulu, Richard Henderson
On 6/6/19 5:43 PM, Alex Bennée wrote:
> 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.
>
> Cc: Andrew Randrianasulu <randrianasulu@gmail.com>
Fixes: https://bugs.launchpad.net/qemu/+bug/1831545
> Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
> ---
> accel/tcg/cputlb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/accel/tcg/cputlb.c b/accel/tcg/cputlb.c
> index b796ab1cbe..8f814a1a2c 100644
> --- a/accel/tcg/cputlb.c
> +++ b/accel/tcg/cputlb.c
> @@ -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...
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
> addr2 = addr1 + size;
> r1 = full_load(env, addr1, oi, retaddr);
> r2 = full_load(env, addr2, oi, retaddr);
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks
2019-06-06 17:04 ` Alex Bennée
@ 2019-06-06 23:41 ` Andrew Randrianasulu
0 siblings, 0 replies; 6+ messages in thread
From: Andrew Randrianasulu @ 2019-06-06 23:41 UTC (permalink / raw)
To: Alex Bennée; +Cc: Paolo Bonzini, qemu-devel, Richard Henderson
В сообщении от Thursday 06 June 2019 20:04:07 Alex Bennée написал(а):
>
> Andrew Randrianasulu <randrianasulu@gmail.com> writes:
>
> > В сообщении от Thursday 06 June 2019 18:43:10 Alex Bennée написал(а):
> >> addr1 = addr & ~((target_ulong)size - 1);
> >
> > yes, this fixes my hang! Thanks!
>
> Can I take that as a:
>
> Tested-by: Andrew Randrianasulu <randrianasulu@gmail.com>
>
> ?
Yes, while I only tested 64-bit x86-64 kernel on 32-bit x86 host, not other machines.
>
> --
> Alex Bennée
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2019-06-06 23:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-06-06 15:43 [Qemu-devel] [PATCH] cputlb: cast size_t to target_ulong before using for address masks Alex Bennée
2019-06-06 15:57 ` Andrew Randrianasulu
2019-06-06 17:04 ` Alex Bennée
2019-06-06 23:41 ` Andrew Randrianasulu
2019-06-06 16:08 ` Richard Henderson
2019-06-06 23:08 ` Philippe Mathieu-Daudé
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).