diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2017-02-14 09:55:48 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2017-02-14 09:55:48 +0000 |
| commit | 5dae13cd71f0755a1395b5a4cde635b8a6ee3f58 (patch) | |
| tree | a9e193d020dbfa96afeb2aa9f08442554b415f26 /linux-user/main.c | |
| parent | ec7a9bd5bb2c46c60cc0ec9b9d9f2ce404226ec0 (diff) | |
| parent | 6597c28d618a3d16d468770b7c30a0237a8c8ea9 (diff) | |
| download | focaccia-qemu-5dae13cd71f0755a1395b5a4cde635b8a6ee3f58.tar.gz focaccia-qemu-5dae13cd71f0755a1395b5a4cde635b8a6ee3f58.zip | |
Merge remote-tracking branch 'remotes/rth/tags/pull-or-20170214' into staging
Queued openrisc patches # gpg: Signature made Mon 13 Feb 2017 21:21:03 GMT # gpg: using RSA key 0xAD1270CC4DD0279B # gpg: Good signature from "Richard Henderson <rth7680@gmail.com>" # gpg: aka "Richard Henderson <rth@redhat.com>" # gpg: aka "Richard Henderson <rth@twiddle.net>" # Primary key fingerprint: 9CB1 8DDA F8E8 49AD 2AFC 16A4 AD12 70CC 4DD0 279B * remotes/rth/tags/pull-or-20170214: (24 commits) target/openrisc: Optimize for r0 being zero target/openrisc: Tidy handling of delayed branches target/openrisc: Tidy ppc/npc implementation target/openrisc: Optimize l.jal to next target/openrisc: Fix madd target/openrisc: Implement muld, muldu, macu, msbu target/openrisc: Represent MACHI:MACLO as a single unit target/openrisc: Implement msync target/openrisc: Enable trap, csync, msync, psync for user mode target/openrisc: Set flags on helpers target/openrisc: Use movcond where appropriate target/openrisc: Keep SR_CY and SR_OV in a separate variables target/openrisc: Keep SR_F in a separate variable target/openrisc: Invert the decoding in dec_calc target/openrisc: Put SR[OVE] in TB flags target/openrisc: Streamline arithmetic and OVE target/openrisc: Rationalize immediate extraction target/openrisc: Tidy insn dumping target/openrisc: Implement lwa, swa target/openrisc: Fix exception handling status registers ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'linux-user/main.c')
| -rw-r--r-- | linux-user/main.c | 98 |
1 files changed, 42 insertions, 56 deletions
diff --git a/linux-user/main.c b/linux-user/main.c index e588f58f2a..4fd49ce6b6 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2574,52 +2574,17 @@ kuser_fail: void cpu_loop(CPUOpenRISCState *env) { CPUState *cs = CPU(openrisc_env_get_cpu(env)); - int trapnr, gdbsig; + int trapnr; abi_long ret; + target_siginfo_t info; for (;;) { cpu_exec_start(cs); trapnr = cpu_exec(cs); cpu_exec_end(cs); process_queued_cpu_work(cs); - gdbsig = 0; switch (trapnr) { - case EXCP_RESET: - qemu_log_mask(CPU_LOG_INT, "\nReset request, exit, pc is %#x\n", env->pc); - exit(EXIT_FAILURE); - break; - case EXCP_BUSERR: - qemu_log_mask(CPU_LOG_INT, "\nBus error, exit, pc is %#x\n", env->pc); - gdbsig = TARGET_SIGBUS; - break; - case EXCP_DPF: - case EXCP_IPF: - cpu_dump_state(cs, stderr, fprintf, 0); - gdbsig = TARGET_SIGSEGV; - break; - case EXCP_TICK: - qemu_log_mask(CPU_LOG_INT, "\nTick time interrupt pc is %#x\n", env->pc); - break; - case EXCP_ALIGN: - qemu_log_mask(CPU_LOG_INT, "\nAlignment pc is %#x\n", env->pc); - gdbsig = TARGET_SIGBUS; - break; - case EXCP_ILLEGAL: - qemu_log_mask(CPU_LOG_INT, "\nIllegal instructionpc is %#x\n", env->pc); - gdbsig = TARGET_SIGILL; - break; - case EXCP_INT: - qemu_log_mask(CPU_LOG_INT, "\nExternal interruptpc is %#x\n", env->pc); - break; - case EXCP_DTLBMISS: - case EXCP_ITLBMISS: - qemu_log_mask(CPU_LOG_INT, "\nTLB miss\n"); - break; - case EXCP_RANGE: - qemu_log_mask(CPU_LOG_INT, "\nRange\n"); - gdbsig = TARGET_SIGSEGV; - break; case EXCP_SYSCALL: env->pc += 4; /* 0xc00; */ ret = do_syscall(env, @@ -2636,32 +2601,54 @@ void cpu_loop(CPUOpenRISCState *env) env->gpr[11] = ret; } break; + case EXCP_DPF: + case EXCP_IPF: + case EXCP_RANGE: + info.si_signo = TARGET_SIGSEGV; + info.si_errno = 0; + info.si_code = TARGET_SEGV_MAPERR; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; + case EXCP_ALIGN: + info.si_signo = TARGET_SIGBUS; + info.si_errno = 0; + info.si_code = TARGET_BUS_ADRALN; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; + case EXCP_ILLEGAL: + info.si_signo = TARGET_SIGILL; + info.si_errno = 0; + info.si_code = TARGET_ILL_ILLOPC; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + break; case EXCP_FPE: - qemu_log_mask(CPU_LOG_INT, "\nFloating point error\n"); + info.si_signo = TARGET_SIGFPE; + info.si_errno = 0; + info.si_code = 0; + info._sifields._sigfault._addr = env->pc; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); break; - case EXCP_TRAP: - qemu_log_mask(CPU_LOG_INT, "\nTrap\n"); - gdbsig = TARGET_SIGTRAP; + case EXCP_INTERRUPT: + /* We processed the pending cpu work above. */ break; - case EXCP_NR: - qemu_log_mask(CPU_LOG_INT, "\nNR\n"); + case EXCP_DEBUG: + trapnr = gdb_handlesig(cs, TARGET_SIGTRAP); + if (trapnr) { + info.si_signo = trapnr; + info.si_errno = 0; + info.si_code = TARGET_TRAP_BRKPT; + queue_signal(env, info.si_signo, QEMU_SI_FAULT, &info); + } break; case EXCP_ATOMIC: cpu_exec_step_atomic(cs); break; default: - EXCP_DUMP(env, "\nqemu: unhandled CPU exception %#x - aborting\n", - trapnr); - gdbsig = TARGET_SIGILL; - break; - } - if (gdbsig) { - gdb_handlesig(cs, gdbsig); - if (gdbsig != TARGET_SIGTRAP) { - exit(EXIT_FAILURE); - } + g_assert_not_reached(); } - process_pending_signals(env); } } @@ -4778,9 +4765,8 @@ int main(int argc, char **argv, char **envp) for (i = 0; i < 32; i++) { env->gpr[i] = regs->gpr[i]; } - - env->sr = regs->sr; env->pc = regs->pc; + cpu_set_sr(env, regs->sr); } #elif defined(TARGET_SH4) { |