From patchwork Fri May 27 13:00:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B32796075C for ; Fri, 27 May 2016 13:14:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A57A525D91 for ; Fri, 27 May 2016 13:14:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9A0AE27E3D; Fri, 27 May 2016 13:14:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4573125D91 for ; Fri, 27 May 2016 13:14:20 +0000 (UTC) Received: from localhost ([::1]:45755 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Hal-0003TE-Cm for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:14:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37297) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNl-0007OQ-GY for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNj-0001Bp-GR for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:52 -0400 Received: from mail-lf0-x22f.google.com ([2a00:1450:4010:c07::22f]:36654) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNi-0001Bf-R3 for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:51 -0400 Received: by mail-lf0-x22f.google.com with SMTP id b73so23104711lfb.3 for ; Fri, 27 May 2016 06:00:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=bR3rc9SwKs0T8dZ2EZXcOouTIWlpsRIYAMHyhbi54v4=; b=CX44dKTYYSri55HL/Ag2fHana7X95t4boKJEtwUseD/Xf8RNOXYnZlLHYpIvfVZlfY 24ufTRguM9Jh14Y1LbuZMOOdNs7ic+Ll/TVtU4pM24v0BZCtGmN1al8C3U1K9j9h8p8f fUclRzLfuEK000f3hqCistLh8jsKRnn8cp5Uc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=bR3rc9SwKs0T8dZ2EZXcOouTIWlpsRIYAMHyhbi54v4=; b=YOJm/87UM1hSWUhq3AYOclIQR1/nbUjEmsFA6Ebp0H5zLoZ4GY0uEcML+KS+VYiMmQ zYK8OxJ7gvxxEcmHRJzPsKVmNrRjNioZDDzuJXILLSMsknNaAmELPbN+pbHMzc9EFytd WiyrSfd3g180pLkSRccS8QjjU9U4NrAPf7uqYNCYAmmP9TgPtVHYd1hPRR3b0rycZYCl eyvx2eZzn4fF5964zeN0zznmXZT95nRvFM1Crlks4ss7BgskIiV5rI2+HgXm9O9mpiFW sMNTXB6xjE+HBPFSVaJjw+xyPxUevAUbQ61lkGygwBLZkMcqq4Z5n98kTm1/3e2ukiKY AWgg== X-Gm-Message-State: ALyK8tKNssFWzetaOLkOPGptWQ54ey9qxij36GjC5eShJ6+o6nOn4ZK9fj79sV31lIxNwCwx X-Received: by 10.25.210.202 with SMTP id j193mr4046107lfg.139.1464354049992; Fri, 27 May 2016 06:00:49 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id n16sm2281066lfg.31.2016.05.27.06.00.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:00:49 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:05 +0300 Message-Id: <7fe7231a4904529404e85517888112c0acc0de4e.1464353863.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22f Subject: [Qemu-devel] [PULL v2 14/38] linux-user: Support for restarting system calls for OpenRISC targets X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Timothy E Baldwin Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 9e6448a..6a0be7d 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 */