From patchwork Fri May 27 13:00:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9138325 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 4281C6075C for ; Fri, 27 May 2016 13:10:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F90D2094F for ; Fri, 27 May 2016 13:10:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 230EB27BF4; Fri, 27 May 2016 13:10:10 +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 9506D2094F for ; Fri, 27 May 2016 13:10:07 +0000 (UTC) Received: from localhost ([::1]:45730 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HWg-0007gR-97 for patchwork-qemu-devel@patchwork.kernel.org; Fri, 27 May 2016 09:10:06 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37318) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNn-0007QG-Fk for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b6HNl-0001CJ-FD for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:54 -0400 Received: from mail-lb0-x22a.google.com ([2a00:1450:4010:c04::22a]:36528) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b6HNl-0001CC-7m for qemu-devel@nongnu.org; Fri, 27 May 2016 09:00:53 -0400 Received: by mail-lb0-x22a.google.com with SMTP id h1so31607922lbj.3 for ; Fri, 27 May 2016 06:00:53 -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=6rvWVICpfHbtS8f9rFOnR6eWzogOSrdpCo6VpVJ6ykc=; b=KjeU+Lev1PKD9+mShey4j52ZS3RBPBb+W5bIeyLD1yLc4M/66Y24CANItEBTSWfC1h +qpAm6jCvIKE6EaYhkTlU4OUamRdPrE2TNZqmBrIdfjlhFYfc8IE6H+lUILRUkkdEzCc sgqp0TVZXfi7OPAACHdR49N8CIG75oc49fEXk= 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=6rvWVICpfHbtS8f9rFOnR6eWzogOSrdpCo6VpVJ6ykc=; b=h0lSBwCI3YBy/0MjvZ/vMkjqs7MqmH1gDrT4VU5YpEES/ZEgLRgAoPM2iVvPCBSWH5 /1oNnpnbTFqXCatMnjKcDtreLtz/WXL+NkXH6+MfRcp89pkXHYhBKk/pqKNh0at2AeSX siGupB3SMZ/+UHjUAGpNF3ZlDHt2u60V4DbOpHn3SYrGIzzzLsmrGmZJIvwnRkEPwfas 9Q+U92V8av2sI2Q4Cg09VgGphwCFq9L2MhwkzJLiBZUw+niuhXlhmNbKNyNWnQK/ZSCS 3gdxhFkKCUbNmvq3N6H8rFu54ouUUZJU9icx5vFIXr1LdMiJZEtwneubZaCepvbWzkm3 7Pvg== X-Gm-Message-State: ALyK8tJOm3X7kChYGuzr42tJA0rtYriTUibOh10sAja4h2/dF6OiMbFmSb+RkTOTmUmgmHvo X-Received: by 10.112.199.198 with SMTP id jm6mr4557542lbc.80.1464354052345; Fri, 27 May 2016 06:00:52 -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.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 27 May 2016 06:00:51 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 27 May 2016 16:00:07 +0300 Message-Id: <47405ab642101c8ea0472ae434ab4bd2bc1fa41f.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:c04::22a Subject: [Qemu-devel] [PULL v2 16/38] linux-user: Support for restarting system calls for S390 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 S390 main loop and sigreturn code: * on TARGET_ERESTARTSYS, wind guest PC backwards to repeat syscall insn * set all guest CPU state within signal.c code on sigreturn * handle TARGET_QEMU_ESIGRETURN in the main loop as the indication that the main loop should not touch any guest CPU state Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-33-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell [PMM: tweak commit message; remove stray double semicolon; drop TARGET_USE_ERESTARTSYS define] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/main.c | 12 +++++++++--- linux-user/s390x/target_signal.h | 1 + linux-user/signal.c | 4 ++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 58dc91c..c16d7ed 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3385,6 +3385,7 @@ void cpu_loop(CPUS390XState *env) int trapnr, n, sig; target_siginfo_t info; target_ulong addr; + abi_long ret; while (1) { cpu_exec_start(cs); @@ -3402,9 +3403,14 @@ void cpu_loop(CPUS390XState *env) n = env->regs[1]; } env->psw.addr += env->int_svc_ilen; - env->regs[2] = do_syscall(env, n, env->regs[2], env->regs[3], - env->regs[4], env->regs[5], - env->regs[6], env->regs[7], 0, 0); + ret = do_syscall(env, n, env->regs[2], env->regs[3], + env->regs[4], env->regs[5], + env->regs[6], env->regs[7], 0, 0); + if (ret == -TARGET_ERESTARTSYS) { + env->psw.addr -= env->int_svc_ilen; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->regs[2] = ret; + } break; case EXCP_DEBUG: diff --git a/linux-user/s390x/target_signal.h b/linux-user/s390x/target_signal.h index b4816b0..a6fb287 100644 --- a/linux-user/s390x/target_signal.h +++ b/linux-user/s390x/target_signal.h @@ -23,4 +23,5 @@ static inline abi_ulong get_sp_from_cpustate(CPUS390XState *state) return state->regs[15]; } + #endif /* TARGET_SIGNAL_H */ diff --git a/linux-user/signal.c b/linux-user/signal.c index 3eea6b7..51e11c1 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -4280,7 +4280,7 @@ long do_sigreturn(CPUS390XState *env) } unlock_user_struct(frame, frame_addr, 0); - return env->regs[2]; + return -TARGET_QEMU_ESIGRETURN; badframe: force_sig(TARGET_SIGSEGV); @@ -4310,7 +4310,7 @@ long do_rt_sigreturn(CPUS390XState *env) goto badframe; } unlock_user_struct(frame, frame_addr, 0); - return env->regs[2]; + return -TARGET_QEMU_ESIGRETURN; badframe: unlock_user_struct(frame, frame_addr, 0);