Received: from eggs.gnu.org ([2001:4830:134:3::10]:36702) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvGUF-0001Kb-Fb for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UvGUC-0002rN-E7 for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:27 -0400 Received: from cantor2.suse.de ([195.135.220.15]:42301 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UvGUC-0002qj-85 for qemu-devel@nongnu.org; Fri, 05 Jul 2013 20:36:24 -0400 From: Alexander Graf Date: Sat, 6 Jul 2013 02:36:11 +0200 Message-Id: <1373070978-11966-3-git-send-email-agraf@suse.de> In-Reply-To: <1373070978-11966-1-git-send-email-agraf@suse.de> References: <1373070978-11966-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH 2/9] linux-user: Add is_write segfault check for ARM hosts List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Riku Voipio 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 --- 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