From patchwork Wed May 25 10:31:46 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135103 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 D838460221 for ; Wed, 25 May 2016 10:37:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CE3C128249 for ; Wed, 25 May 2016 10:37:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C32B5282D8; Wed, 25 May 2016 10:37:42 +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 4935A28249 for ; Wed, 25 May 2016 10:37:42 +0000 (UTC) Received: from localhost ([::1]:58825 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WC5-0005du-E7 for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:37:41 -0400 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) 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=cdEmVH0BVTKBDQscK2KVoFcPTDCvXgxQEU9swViCduw=; b=h1m+zeqfFJPycCArusGI4iAZKD/rMBgISlN9sMADHW+FDR7HV83ub8CvHRQ9SIXiCE f9xGpv+AW3PjcYlNDkwoprtdaLvqADvLsXphozowtHW1YkiBgJi5nndQocmU4X3ZWrCC 37GQK2/Q/wdte7hg4gSLPt1XgwupY7IG5+aQk= 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=cdEmVH0BVTKBDQscK2KVoFcPTDCvXgxQEU9swViCduw=; b=IM/PkzYeN++sqItJ6H8bC6h53bWutdNhF0eF10XXbuvmT5cR0cQ4VzD1vRrpnWBaKY M9DURi8bikX7VEwC3eycDY3NYPa/lIZvEFtDa2WYXNZ2SZ34lRYUqKhcTxAKBgMTpDCP KeLf+UF5gH0kukwwk/cwdCOOEGcQdqQHubCBUsvgy+FysPXkyrG6CzC6g+zgXkv0nzmm T55FrNmWwGNG+sKhB7RspCg9WWQiKWHNycLjULvqY+UFkcLCMA8Q08NlckXMLCc1hV5V baVTo0Vsd+9HLPzvFckW2MwgjeJw6HLNUaEpDdrkwcwK9F7YyOuXGMG201lGiHIeX8lA gXfA== X-Gm-Message-State: ALyK8tKE8JoqSXhcNVmomi1Il4qIb5EeWBbmnGo9bhdNWq1sZCd0rHjt5vbGPo5QDB1zf6dF X-Received: by 10.25.87.65 with SMTP id l62mr603769lfb.4.1464172339236; Wed, 25 May 2016 03:32:19 -0700 (PDT) Received: from beaming.home (91-157-168-132.elisa-laajakaista.fi. [91.157.168.132]) by smtp.gmail.com with ESMTPSA id o75sm1379610lfi.9.2016.05.25.03.32.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:18 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:46 +0300 Message-Id: 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::233 Subject: [Qemu-devel] [PULL 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 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 */