From patchwork Wed May 25 10:31:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135111 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 0E5D060221 for ; Wed, 25 May 2016 10:40:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03D8F28249 for ; Wed, 25 May 2016 10:40:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ECA91282D8; Wed, 25 May 2016 10:40:41 +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 5638C28249 for ; Wed, 25 May 2016 10:40:41 +0000 (UTC) Received: from localhost ([::1]:58843 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WEy-0008Ou-3f for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:40:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41252) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W71-00015P-Th for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W6r-00035N-Jt for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:26 -0400 Received: from mail-lf0-x229.google.com ([2a00:1450:4010:c07::229]:34590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W6r-00035B-84 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:17 -0400 Received: by mail-lf0-x229.google.com with SMTP id k98so16328441lfi.1 for ; Wed, 25 May 2016 03:32:17 -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=/tcYEs1eopoaXbzwuHcXJbIw98stgWNORW635VvWGxE=; b=XnPlzxRM+jt2COyrdto0i3sFgcyu42SEcEqcM5Z+8OI5aC6DmkjwlugrqJGeaAcNAx AXh55Gzgad8SZJ2eyWUMpAjDoIhqrJV6G/zuUEMLxSiWAFKHQ9iemYJS0qyCBiCtiGRH yiJ/XwdQ2YxM1AHzQBo4d/Mo0ANbqz0KdmJuI= 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=/tcYEs1eopoaXbzwuHcXJbIw98stgWNORW635VvWGxE=; b=NvpbGW4zTqzlKkzEDpbRcVEicMUfgSv0VIy2eDjdzyiYT+MQ012D76/sXqKg2uND05 fejEIF+nVHkI4xm/vqcQKDRzUkeHr1E/tKw5BDxBVHzsl60MM9cvQGBZVGwU3j3Ah+fs s2QxW1vSM83Zx6FakqKJFfA4G1dg8fKyaj4XrOa0D5i0cW3Es8Ph3rCT0CgD61q+MR5l BqcYz+0g69S+ZIyNyarS3bydIb7uIdphTUiGAXvLgUi1GMTgEETgsO2Cwwn7/gM3j+ln 3PNjRTPhMLK9t/RwFyRc07H53O75hOhd49uZlL/9yGb5EvvklmaPW7uTmxc6JyylI5P8 8irg== X-Gm-Message-State: ALyK8tIlJJi26XOwrTe9G2/8n4V7a8kLqsNfDAyFwuayc1o2n9y6ZWDb74TIuSnYuBgidgW/ X-Received: by 10.25.216.36 with SMTP id p36mr733269lfg.198.1464172335558; Wed, 25 May 2016 03:32:15 -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.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:14 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:43 +0300 Message-Id: <9c408d2d1b067a2bd553afed22102cd43825ce9d.1464153942.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::229 Subject: [Qemu-devel] [PULL 11/38] linux-user: Support for restarting system calls for SH4 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 SH4 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-12-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 | 6 +++++- linux-user/sh4/target_signal.h | 1 + linux-user/signal.c | 16 ++++++---------- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 95655df..838d9b3 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -2826,7 +2826,11 @@ void cpu_loop(CPUSH4State *env) env->gregs[0], env->gregs[1], 0, 0); - env->gregs[0] = ret; + if (ret == -TARGET_ERESTARTSYS) { + env->pc -= 2; + } else if (ret != -TARGET_QEMU_ESIGRETURN) { + env->gregs[0] = ret; + } break; case EXCP_INTERRUPT: /* just indicate that signals should be handled asap */ diff --git a/linux-user/sh4/target_signal.h b/linux-user/sh4/target_signal.h index e148da0..f9911aa 100644 --- a/linux-user/sh4/target_signal.h +++ b/linux-user/sh4/target_signal.h @@ -26,4 +26,5 @@ static inline abi_ulong get_sp_from_cpustate(CPUSH4State *state) return state->gregs[15]; } + #endif /* TARGET_SIGNAL_H */ diff --git a/linux-user/signal.c b/linux-user/signal.c index e742347..8b5ddf2 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -3202,13 +3202,12 @@ static void setup_sigcontext(struct target_sigcontext *sc, __put_user(mask, &sc->oldmask); } -static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc, - target_ulong *r0_p) +static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc) { int i; #define COPY(x) __get_user(regs->x, &sc->sc_##x) - COPY(gregs[1]); + COPY(gregs[0]); COPY(gregs[1]); COPY(gregs[2]); COPY(gregs[3]); COPY(gregs[4]); COPY(gregs[5]); COPY(gregs[6]); COPY(gregs[7]); @@ -3228,7 +3227,6 @@ static void restore_sigcontext(CPUSH4State *regs, struct target_sigcontext *sc, __get_user(regs->fpul, &sc->sc_fpul); regs->tra = -1; /* disable syscall checks */ - __get_user(*r0_p, &sc->sc_gregs[0]); } static void setup_frame(int sig, struct target_sigaction *ka, @@ -3345,7 +3343,6 @@ long do_sigreturn(CPUSH4State *regs) abi_ulong frame_addr; sigset_t blocked; target_sigset_t target_set; - target_ulong r0; int i; int err = 0; @@ -3366,10 +3363,10 @@ long do_sigreturn(CPUSH4State *regs) target_to_host_sigset_internal(&blocked, &target_set); do_sigprocmask(SIG_SETMASK, &blocked, NULL); - restore_sigcontext(regs, &frame->sc, &r0); + restore_sigcontext(regs, &frame->sc); unlock_user_struct(frame, frame_addr, 0); - return r0; + return -TARGET_QEMU_ESIGRETURN; badframe: unlock_user_struct(frame, frame_addr, 0); @@ -3382,7 +3379,6 @@ long do_rt_sigreturn(CPUSH4State *regs) struct target_rt_sigframe *frame; abi_ulong frame_addr; sigset_t blocked; - target_ulong r0; frame_addr = regs->gregs[15]; trace_user_do_rt_sigreturn(regs, frame_addr); @@ -3393,7 +3389,7 @@ long do_rt_sigreturn(CPUSH4State *regs) target_to_host_sigset(&blocked, &frame->uc.tuc_sigmask); do_sigprocmask(SIG_SETMASK, &blocked, NULL); - restore_sigcontext(regs, &frame->uc.tuc_mcontext, &r0); + restore_sigcontext(regs, &frame->uc.tuc_mcontext); if (do_sigaltstack(frame_addr + offsetof(struct target_rt_sigframe, uc.tuc_stack), @@ -3402,7 +3398,7 @@ long do_rt_sigreturn(CPUSH4State *regs) } unlock_user_struct(frame, frame_addr, 0); - return r0; + return -TARGET_QEMU_ESIGRETURN; badframe: unlock_user_struct(frame, frame_addr, 0);