From patchwork Fri May 27 13:00:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138331 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 809276075C for ; Fri, 27 May 2016 13:14:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 707E827CB1 for ; Fri, 27 May 2016 13:14:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 63C8725D91; Fri, 27 May 2016 13:14:19 +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 F005B25D91 for ; Fri, 27 May 2016 13:14:18 +0000 (UTC) Received: from localhost ([::1]:45754 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6Haj-0003T8-Pg for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:14:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNp-0007VM-QF for qemu-devel@nongnu.org; Fri, 27 May 2016 09:01:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNo-0001Dc-Mz for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:57 -0400 Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:34467) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNn-0001Ct-Kw for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:56 -0400 Received: by mail-lb0-x22f.google.com with SMTP id sh2so31745963lbb.1 for ; Fri, 27 May 2016 06:00:55 -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=IbgHi1fIQipt5AYsmUPZblVjcByLuDv2ocyKBCVQljc=; b=RtsUpOjldBtlM3mg6y1AQHPbwT8/HZy92evsfwFpYAFUdw0GKqjRF5JQ3n+9Rr2GYZ lqejDPP0E7Kc9ViQa14fQqmiYdnDv0t0ozLZ1hjXNcPHnPlkVvMWtfbXnKtmI32/aK25 FttyRI7zybLCFzU8PJKG46HhNhSwuv+eznBS0= 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=IbgHi1fIQipt5AYsmUPZblVjcByLuDv2ocyKBCVQljc=; b=MD1qOjUz5G9k96iC2IkLUuCIpF94hJOCGd8sp2zdt+gH19M0/R8KEMM9hTZyJsjkCT vzp+EVuxE3+7wTRaXIh6/OKs+LejmwTAb0ez53HWpnOUea7KYCa9CN2J12B9Wrxj0ggc 6aKalaCBLnd4czyY5iP3TmLVLuUtugMceCOn6K4gQMKGHgddkUN/WxHhmdUoEBSup18O XdVja4WVeD+4e7TNs0rCdf7oQ31gZv+wr6JJH0nkIp5Vx6cRwjm1npOWx0q4iEqAhV9g Uw8ZGHKOP+lZV6J6Z4kHj4pcnn04QI5pfmCZKVmAJf2gDqQGpKpQO3Xu3xXpFyp+Sm09 cPhQ== X-Gm-Message-State: ALyK8tLEgvv3NGkOBwptCxlechXOOAaf1PzR5bPW5PCbEZ/3tkVwsjYrEfuXAa9jXly/RbLZ X-Received: by 10.112.25.2 with SMTP id y2mr4356409lbf.104.1464354054708; Fri, 27 May 2016 06:00:54 -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.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:00:53 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:09 +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:c04::22f Subject: [Qemu-devel] [PULL v2 18/38] linux-user: Support for restarting system calls for tilegx 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell Update the tilegx main loop and sigreturn code: * on TARGET_ERESTARTSYS, wind guest PC backwards to repeat syscall insn * return -TARGET_QEMU_ESIGRETURN from sigreturn rather than current R_RE * handle TARGET_QEMU_ESIGRETURN in the main loop as the indication that the main loop should not touch any guest CPU state Note that this fixes a bug where a sigreturn which happened to have an errno value in TILEGX_R_RE would incorrectly cause TILEGX_R_ERR to get set. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/main.c | 21 +++++++++++++-------- linux-user/signal.c | 2 +- linux-user/tilegx/target_signal.h | 1 + 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index a532221..4607e48 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3706,15 +3706,20 @@ void cpu_loop(CPUTLGState *env) cpu_exec_end(cs); switch (trapnr) { case TILEGX_EXCP_SYSCALL: - env->regs[TILEGX_R_RE] = do_syscall(env, env->regs[TILEGX_R_NR], - env->regs[0], env->regs[1], - env->regs[2], env->regs[3], - env->regs[4], env->regs[5], - env->regs[6], env->regs[7]); - env->regs[TILEGX_R_ERR] = TILEGX_IS_ERRNO(env->regs[TILEGX_R_RE]) - ? - env->regs[TILEGX_R_RE] - : 0; + { + abi_ulong ret = do_syscall(env, env->regs[TILEGX_R_NR], + env->regs[0], env->regs[1], + env->regs[2], env->regs[3], + env->regs[4], env->regs[5], + env->regs[6], env->regs[7]); + if (ret == -TARGET_ERESTARTSYS) { + env->pc -= 8; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->regs[TILEGX_R_RE] = ret; + env->regs[TILEGX_R_ERR] = TILEGX_IS_ERRNO(ret) ? -ret : 0; + } break; + } case TILEGX_EXCP_OPCODE_EXCH: do_exch(env, true, false); break; diff --git a/linux-user/signal.c b/linux-user/signal.c index 71a8e2a..b4641df 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5709,7 +5709,7 @@ long do_rt_sigreturn(CPUTLGState *env) } unlock_user_struct(frame, frame_addr, 0); - return env->regs[TILEGX_R_RE]; + return -TARGET_QEMU_ESIGRETURN; badframe: diff --git a/linux-user/tilegx/target_signal.h b/linux-user/tilegx/target_signal.h index b595f98..fcf1040 100644 --- a/linux-user/tilegx/target_signal.h +++ b/linux-user/tilegx/target_signal.h @@ -25,4 +25,5 @@ static inline abi_ulong get_sp_from_cpustate(CPUTLGState *state) return state->regs[TILEGX_R_SP]; } + #endif /* TARGET_SIGNAL_H */