diff options
author | Richard Henderson <rth@twiddle.net> | 2010-03-10 14:36:58 -0800 |
---|---|---|
committer | Paul Brook <paul@codesourcery.com> | 2010-03-12 16:28:47 +0000 |
commit | b9f83121a13153536d886305414b540460c34508 (patch) | |
tree | 345a3e65d5860ceda9d284b23e47d19ed5237b9c /cpu-all.h | |
parent | 5270589032f450ae7c3448730855aa18ff68ccff (diff) |
Use TARGET_VIRT_ADDR_SPACE_BITS in h2g_valid.
Previously, only 32-bit guests had a proper check for the
validity of the virtual address. Extend that check to 64-bit
guests with a restricted virtual address space.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Diffstat (limited to 'cpu-all.h')
-rw-r--r-- | cpu-all.h | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -634,16 +634,22 @@ extern int have_guest_base; /* All direct uses of g2h and h2g need to go away for usermode softmmu. */ #define g2h(x) ((void *)((unsigned long)(x) + GUEST_BASE)) + +#if HOST_LONG_BITS <= TARGET_VIRT_ADDR_SPACE_BITS +#define h2g_valid(x) 1 +#else +#define h2g_valid(x) ({ \ + unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ + __guest < (1ul << TARGET_VIRT_ADDR_SPACE_BITS); \ +}) +#endif + #define h2g(x) ({ \ unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \ /* Check if given address fits target address space */ \ - assert(__ret == (abi_ulong)__ret); \ + assert(h2g_valid(x)); \ (abi_ulong)__ret; \ }) -#define h2g_valid(x) ({ \ - unsigned long __guest = (unsigned long)(x) - GUEST_BASE; \ - (__guest == (abi_ulong)__guest); \ -}) #define saddr(x) g2h(x) #define laddr(x) g2h(x) |