]> git.proxmox.com Git - mirror_qemu.git/commitdiff
linux-user: fix segmentation fault passing with h2g(x) != x
authorAlexander Graf <agraf@suse.de>
Sat, 6 Jul 2013 12:17:49 +0000 (14:17 +0200)
committerRiku Voipio <riku.voipio@linaro.org>
Tue, 23 Jul 2013 14:28:28 +0000 (17:28 +0300)
When forwarding a segmentation fault into the guest process, we were passing
the host's address directly into the guest process's signal descriptor.

That obviously confused the guest process, since it didn't know what to make
of the (usually 32-bit truncated) address. Passing in h2g(address) makes the
guest process a lot happier.

To make the code more obvious, introduce a h2g_nocheck() macro that does the
same as h2g(), but allows us to convert addresses that may be outside of guest
mapped range into the guest's view of address space.

This fixes java running in arm-linux-user for me.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
include/exec/cpu-all.h
user-exec.c

index 5084202217569afef50711c170ac16d14867bf3f..f1cde978ab50d7c06bb0eb6e9a0b717553f46067 100644 (file)
@@ -209,11 +209,15 @@ extern unsigned long reserved_va;
 })
 #endif
 
-#define h2g(x) ({ \
+#define h2g_nocheck(x) ({ \
     unsigned long __ret = (unsigned long)(x) - GUEST_BASE; \
+    (abi_ulong)__ret; \
+})
+
+#define h2g(x) ({ \
     /* Check if given address fits target address space */ \
     assert(h2g_valid(x)); \
-    (abi_ulong)__ret; \
+    h2g_nocheck(x); \
 })
 
 #define saddr(x) g2h(x)
index d45ca8e8776009ffb16c573198d2aa54e8c4cef4..82bfa66ce303efdfc94701e657674a95b7ce7ea4 100644 (file)
@@ -95,6 +95,10 @@ static inline int handle_cpu_signal(uintptr_t pc, unsigned long address,
         return 1;
     }
 
+    /* Convert forcefully to guest address space, invalid addresses
+       are still valid segv ones */
+    address = h2g_nocheck(address);
+
     env = current_cpu->env_ptr;
     /* see if it is an MMU fault */
     ret = cpu_handle_mmu_fault(env, address, is_write, MMU_USER_IDX);