From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56965) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzeXJ-0003g5-OU for qemu-devel@nongnu.org; Wed, 25 Jun 2014 00:10:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WzeX8-0005TV-L6 for qemu-devel@nongnu.org; Wed, 25 Jun 2014 00:10:17 -0400 Received: from mail-pa0-x235.google.com ([2607:f8b0:400e:c03::235]:35233) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WzeX8-0005Qa-FG for qemu-devel@nongnu.org; Wed, 25 Jun 2014 00:10:06 -0400 Received: by mail-pa0-f53.google.com with SMTP id ey11so1153046pad.40 for ; Tue, 24 Jun 2014 21:10:05 -0700 (PDT) From: Hunter Laux Date: Tue, 24 Jun 2014 21:08:57 -0700 Message-Id: <1403669337-5431-1-git-send-email-hunterlaux@gmail.com> Subject: [Qemu-devel] [PATCH] linux-user: Handle new ARM breakpoint instruction List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, peter.maydell@linaro.org, riku.voipio@iki.fi Cc: Hunter Laux This instruction space is guaranteed to be undefined. ARM: xxxx 0111 1111 xxxx xxxx xxxx 1111 xxxx Thumb: 1101 1110 xxxx xxxx The breakpoint instructions were selected from this instruction space. Linux traps the illegal instruction and sends a SIGTRAP if it is a breakpoint. Here is the Linux implementation: http://lxr.free-electrons.com/source/arch/arm/kernel/ptrace.c#L221 Signed-off-by: Hunter Laux --- linux-user/main.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/linux-user/main.c b/linux-user/main.c index 900a17f..91f2681 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -688,11 +688,29 @@ void cpu_loop(CPUARMState *env) uint32_t opcode; int rc; + const uint32_t arm_bkpt_mask = 0x0FFFFFFF; + const uint32_t arm_bkpt = 0x07F001F0; + const uint32_t arm_bkpt_thumb_mask = 0x0000FFFF; + const uint32_t arm_bkpt_thumb = 0x0000DE01; + const uint32_t arm_bkpt_thumb2_mask = 0xFFFFFFFF; + const uint32_t arm_bkpt_thumb2 = 0xF7F0A000; + /* we handle the FPU emulation here, as Linux */ /* we get the opcode */ /* FIXME - what to do if get_user() fails? */ get_user_code_u32(opcode, env->regs[15], env->bswap_code); + if (env->thumb) { + if ((opcode & arm_bkpt_thumb_mask) == arm_bkpt_thumb + || (opcode & arm_bkpt_thumb2_mask) == arm_bkpt_thumb2) { + goto excp_debug; + } + } else { + if ((opcode & arm_bkpt_mask) == arm_bkpt) { + goto excp_debug; + } + } + rc = EmulateAll(opcode, &ts->fpa, env); if (rc == 0) { /* illegal instruction */ info.si_signo = SIGILL; -- 1.9.1