]> Git Repo - qemu.git/commitdiff
cpu-all.h: Don't accidentally sign extend in g2h()
authorPeter Maydell <[email protected]>
Fri, 9 Mar 2012 14:33:20 +0000 (14:33 +0000)
committerAnthony Liguori <[email protected]>
Mon, 12 Mar 2012 19:05:26 +0000 (14:05 -0500)
Cast the argument of the g2h() macro to a target_ulong so that
it isn't accidentally sign-extended if it is a signed 32 bit
type and long is a 64 bit type. In particular, this fixes a
bug where it would return the wrong value for 32 bit guests
on 64 bit hosts when passed in one of the arg* values from
do_syscall() [which are all abi_long and thus signed types].
This could result in spurious failure of mlock(), among others.

Reviewed-by: Andreas F=E4rber <[email protected]>
Signed-off-by: Peter Maydell <[email protected]>
Signed-off-by: Anthony Liguori <[email protected]>
cpu-all.h

index 80e6d4234f80a589bb5bbdc931e81cbda7e773e5..a174532b192e9e32762df02ad2c0e615f8b90608 100644 (file)
--- a/cpu-all.h
+++ b/cpu-all.h
@@ -197,7 +197,7 @@ extern unsigned long reserved_va;
 #endif
 
 /* All direct uses of g2h and h2g need to go away for usermode softmmu.  */
-#define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE))
+#define g2h(x) ((void *)((unsigned long)(target_ulong)(x) + GUEST_BASE))
 
 #if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS
 #define h2g_valid(x) 1
This page took 0.025386 seconds and 4 git commands to generate.