]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
cputlb: cast size_t to target_ulong before using for address masks
authorAlex Bennée <alex.bennee@linaro.org>
Thu, 6 Jun 2019 15:38:19 +0000 (16:38 +0100)
committerAlex Bennée <alex.bennee@linaro.org>
Wed, 12 Jun 2019 16:53:23 +0000 (17:53 +0100)
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.

Fixes: https://bugs.launchpad.net/qemu/+bug/1831545
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Tested-by: Andrew Randrianasulu <randrianasulu@gmail.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
accel/tcg/cputlb.c

index 8d6891931e8f378fe9646423120a46b24568acb7..bb9897b25a3ae2088748b845a0e83e30f6b78241 100644 (file)
@@ -1318,7 +1318,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);