From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41261) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W72-00015k-AK for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W6u-00036p-83 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:27 -0400 Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:35098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W6t-00036Q-UY for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:20 -0400 Received: by mail-lf0-x233.google.com with SMTP id w16so4190758lfd.2 for ; Wed, 25 May 2016 03:32:19 -0700 (PDT) From: riku.voipio@linaro.org Date: Wed, 25 May 2016 13:31:46 +0300 Message-Id: In-Reply-To: References: Subject: [Qemu-devel] [PULL 14/38] linux-user: Support for restarting system calls for OpenRISC targets List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Timothy E Baldwin From: Timothy E Baldwin Update the OpenRISC main loop code: * on TARGET_ERESTARTSYS, wind guest PC backwards to repeat syscall insn * handle TARGET_QEMU_ESIGRETURN in the main loop as the indication that the main loop should not touch any guest CPU state (We don't implement sigreturn on this target so there is no code there to update.) Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-31-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell [PMM: tweak commit message; drop TARGET_USE_ERESTARTSYS define] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/main.c | 22 ++++++++++++++-------- linux-user/openrisc/target_signal.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 2d7e700..14a7826 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2724,6 +2724,7 @@ void cpu_loop(CPUOpenRISCState *env) { CPUState *cs = CPU(openrisc_env_get_cpu(env)); int trapnr, gdbsig; + abi_long ret; for (;;) { cpu_exec_start(cs); @@ -2769,14 +2770,19 @@ void cpu_loop(CPUOpenRISCState *env) break; case EXCP_SYSCALL: env->pc += 4; /* 0xc00; */ - env->gpr[11] = do_syscall(env, - env->gpr[11], /* return value */ - env->gpr[3], /* r3 - r7 are params */ - env->gpr[4], - env->gpr[5], - env->gpr[6], - env->gpr[7], - env->gpr[8], 0, 0); + ret = do_syscall(env, + env->gpr[11], /* return value */ + env->gpr[3], /* r3 - r7 are params */ + env->gpr[4], + env->gpr[5], + env->gpr[6], + env->gpr[7], + env->gpr[8], 0, 0); + if (ret == -TARGET_ERESTARTSYS) { + env->pc -= 4; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->gpr[11] = ret; + } break; case EXCP_FPE: qemu_log_mask(CPU_LOG_INT, "\nFloating point error\n"); diff --git a/linux-user/openrisc/target_signal.h b/linux-user/openrisc/target_signal.h index 964aed6..f600501 100644 --- a/linux-user/openrisc/target_signal.h +++ b/linux-user/openrisc/target_signal.h @@ -23,4 +23,5 @@ static inline abi_ulong get_sp_from_cpustate(CPUOpenRISCState *state) return state->gpr[1]; } + #endif /* TARGET_SIGNAL_H */ -- 2.1.4