[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/9] linux-user: Add is_write segfault check for ARM
From: |
Alexander Graf |
Subject: |
[Qemu-devel] [PATCH 2/9] linux-user: Add is_write segfault check for ARM hosts |
Date: |
Sat, 6 Jul 2013 02:36:11 +0200 |
When we get a segmentation fault we check whether the fault was a write. If
it was a write, it might be a fault because we tried to modify a code region.
This logic does not work on ARM hosts, because they don't evaluate whether a
segementation fault is due to a write. Instead they always declare it a read.
So self modifying code fails with a segmentation fault whenever it tries to
modify itself.
Add the is_write evaluation based on what the kernel tells us as fault reason.
Signed-off-by: Alexander Graf <address@hidden>
---
user-exec.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/user-exec.c b/user-exec.c
index 718c54f..bbeb0dd 100644
--- a/user-exec.c
+++ b/user-exec.c
@@ -448,8 +448,7 @@ int cpu_signal_handler(int host_signum, void *pinfo,
#else
pc = uc->uc_mcontext.arm_pc;
#endif
- /* XXX: compute is_write */
- is_write = 0;
+ is_write = (uc->uc_mcontext.error_code & 0x800) ? 1 : 0;
return handle_cpu_signal(pc, (unsigned long)info->si_addr,
is_write,
&uc->uc_sigmask, puc);
--
1.6.0.2