[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 17/21] linux-user: fix segmentation fault passing wit
From: |
riku . voipio |
Subject: |
[Qemu-devel] [PULL 17/21] linux-user: fix segmentation fault passing with h2g(x) != x |
Date: |
Tue, 23 Jul 2013 18:49:07 +0300 |
From: Alexander Graf <address@hidden>
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 <address@hidden>
Signed-off-by: Riku Voipio <address@hidden>
---
include/exec/cpu-all.h | 8 ++++++--
user-exec.c | 4 ++++
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index 5084202..f1cde97 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -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)
diff --git a/user-exec.c b/user-exec.c
index d45ca8e..82bfa66 100644
--- a/user-exec.c
+++ b/user-exec.c
@@ -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);
--
1.8.1.2
- [Qemu-devel] [PULL 00/21] Linux-user updates, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 02/21] configure: Don't say target_nptl="no" if there is no linux-user target, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 06/21] linux-user: Enable NPTL for OpenRISC, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 03/21] configure: Enable threading on all ppc and mips linux-user targets, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 04/21] configure: Enable threading for unicore32-linux-user, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 12/21] linux-user: Enable NPTL for x86-64, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 01/21] configure: Flip default of target_nptl, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 15/21] linux-user: Fix target_stat and target_stat64 for OpenRISC, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 17/21] linux-user: fix segmentation fault passing with h2g(x) != x,
riku . voipio <=
- [Qemu-devel] [PULL 05/21] linux-user: Move includes of target-specific headers to end of qemu.h, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 08/21] linux-user: Enable NPTL for m68k, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 09/21] linux-user: Add missing 'break' in i386 get_thread_area syscall, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 18/21] linux-user: Fix epoll on ARM hosts, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 07/21] linux-user: Enable NPTL for SPARC targets, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 10/21] linux-user: Clean up handling of clone() argument order, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 14/21] linux-user: Avoid conditional cpu_reset(), riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 16/21] linux-user: Fix pipe syscall return for SPARC, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 11/21] linux-user: Add i386 TLS setter, riku . voipio, 2013/07/23
- [Qemu-devel] [PULL 13/21] configure: Make NPTL non-optional, riku . voipio, 2013/07/23