From patchwork Wed May 25 10:31:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9135091 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 3133C607D7 for ; Wed, 25 May 2016 10:33:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 25CBB282BE for ; Wed, 25 May 2016 10:33:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1881D282DD; Wed, 25 May 2016 10:33:12 +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 6A53F282BE for ; Wed, 25 May 2016 10:33:11 +0000 (UTC) Received: from localhost ([::1]:58802 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W7i-0001Fo-Dh for patchwork-qemu-devel@patchwork.kernel.org; Wed, 25 May 2016 06:33:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W73-00016e-BA 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 1b5W6s-00035n-4H for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:28 -0400 Received: from mail-lf0-x22d.google.com ([2a00:1450:4010:c07::22d]:35093) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W6r-00035G-NJ for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:18 -0400 Received: by mail-lf0-x22d.google.com with SMTP id w16so4190381lfd.2 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=md7/lcAgy911Ib3ebWKKb1LKDhS+jeVO0IDDszzSkpw=; b=MQTx20WnJV4WQG/19fGVMWCsP8+5YDXwktLP4AVAAUZXBWHmLZAaZekJEBZuj9ey4j kO1WyrzGNGMzcd61MU/6jdkocs92b5u8XwgCeG7840pgb9lSUxmSDugGPb2SetTprXLW unF5m0rqSiEMgcdflshU6QPBW+vS+nTpcJMwY= 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=md7/lcAgy911Ib3ebWKKb1LKDhS+jeVO0IDDszzSkpw=; b=TYv7Ih8+rWnJjQvJA0ufHxmabxHOCHqYBJ334Ir8PA2J152s4tldtg0lj6Do+R/LlO rGPEjF4XLgxw7RNlusnA7801nZxaARVPhlm+LGOud44hEEPaBIXVuwpjdOchxX+XLInI fVX8IwvLR2g+GPJfiPeRMpF+lVb40YJZ6jpaq4yOHE/0ID/Nrlhf9lVJLSN1GpN4R+Gq rMaD12TxOfCPCD1Jrtrdw0G6OxkgN7VHpKYJA6/7K3yyr9E6uwlBhjrQbNt+2T7kzUal yR1FJvi5EzL/K2doTnpaksEfjPzegtcnm4Es7YeGrfGWHkePyAqD7so5cPXlJnl+p5Fb qosg== X-Gm-Message-State: ALyK8tKbm+LpVb6gLXo7tQgUl4B6nf6xCmBzGAr5NfuYmdnqq02T+HP5xMShvjPcdvz8y0t8 X-Received: by 10.25.40.145 with SMTP id o139mr725118lfo.151.1464172336924; Wed, 25 May 2016 03:32:16 -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.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:15 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:44 +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::22d Subject: [Qemu-devel] [PULL 12/38] linux-user: Support for restarting system calls for Alpha 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 Alpha main loop and sigreturn 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 Signed-off-by: Timothy Edward Baldwin Message-id: 1441497448-32489-13-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell [PMM: tweak commit message; drop TARGET_USE_ERESTARTSYS define; PC is env->pc, not env->ir[IR_PV]] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/alpha/target_signal.h | 1 + linux-user/main.c | 7 +++++-- linux-user/signal.c | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/linux-user/alpha/target_signal.h b/linux-user/alpha/target_signal.h index d3822da..4c78319 100644 --- a/linux-user/alpha/target_signal.h +++ b/linux-user/alpha/target_signal.h @@ -27,6 +27,7 @@ static inline abi_ulong get_sp_from_cpustate(CPUAlphaState *state) return state->ir[IR_SP]; } + /* From . */ #define TARGET_GEN_INTOVF -1 /* integer overflow */ #define TARGET_GEN_INTDIV -2 /* integer division by zero */ diff --git a/linux-user/main.c b/linux-user/main.c index 838d9b3..eeea8f5 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3267,8 +3267,11 @@ void cpu_loop(CPUAlphaState *env) env->ir[IR_A2], env->ir[IR_A3], env->ir[IR_A4], env->ir[IR_A5], 0, 0); - if (trapnr == TARGET_NR_sigreturn - || trapnr == TARGET_NR_rt_sigreturn) { + if (sysret == -TARGET_ERESTARTSYS) { + env->pc -= 4; + break; + } + if (sysret == -TARGET_QEMU_ESIGRETURN) { break; } /* Syscall writes 0 to V0 to bypass error check, similar diff --git a/linux-user/signal.c b/linux-user/signal.c index 8b5ddf2..559e764 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5527,7 +5527,7 @@ long do_sigreturn(CPUAlphaState *env) restore_sigcontext(env, sc); unlock_user_struct(sc, sc_addr, 0); - return env->ir[IR_V0]; + return -TARGET_QEMU_ESIGRETURN; badframe: force_sig(TARGET_SIGSEGV); @@ -5554,7 +5554,7 @@ long do_rt_sigreturn(CPUAlphaState *env) } unlock_user_struct(frame, frame_addr, 0); - return env->ir[IR_V0]; + return -TARGET_QEMU_ESIGRETURN; badframe: