From patchwork Wed May 25 10:31:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 68569 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp1137826qge; Wed, 25 May 2016 03:52:00 -0700 (PDT) X-Received: by 10.140.43.199 with SMTP id e65mr2673157qga.12.1464173520415; Wed, 25 May 2016 03:52:00 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 47si39307071qgl.50.2016.05.25.03.52.00 for (version=TLS1 cipher=AES128-SHA bits=128/128); Wed, 25 May 2016 03:52:00 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:58893 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WPv-0001Mt-T2 for patch@linaro.org; Wed, 25 May 2016 06:51:59 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41480) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W79-0001Dw-G2 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W70-0003Aj-KU for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:35 -0400 Received: from mail-lf0-x232.google.com ([2a00:1450:4010:c07::232]:36150) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W70-0003AH-D2 for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:26 -0400 Received: by mail-lf0-x232.google.com with SMTP id e130so16303602lfe.3 for ; Wed, 25 May 2016 03:32:26 -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=z//IH+L1MScA+SEuDakUe8k9UwWVvLfOyv2G0z+aGRU=; b=KuXGppqg11i2RtsKxq1WcDDEq/NpJvsxyDo2kLUfxpjMxgGumQGDkdYfNJKHbbigde ydWWKaJWTos4d3/8o497AmwY4BbYBU5pfb0x+mbiURAtugPBhgj6f4Csl8hHbM5MrgEk vaQmy6fbNbV30UR1iyfFLgQmCnI3vr+4x/cUk= 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=z//IH+L1MScA+SEuDakUe8k9UwWVvLfOyv2G0z+aGRU=; b=lMGZ6gVe/xpj80v+DjQi109fapv7GlrTEWVGJgBe8nOm7xz0ixQbSU3LPhZe/MFeNh TOCsPbSNrFd6meCKuFiFCxBTRDQ0lpopasH3V9cS8pdOrrAAV6QyBNydH6mJvpP18Xv/ mVBNW99Thh5m5rmJGAzXtMK6YnUoU0rIPQWRh08BVhj72JS0qEaWWTTYekdK0H27G01L QetkzuPhkBWDEqlPptGsVpLdJD7I+et18r37qHvS/Wn4hh5wF3EokrC/scG237C2G3AX WPeazTWHJg/VSF/SKNnNO+7Rcp66JlZp8Ta5ONXcTTacx2PUn+RAQ0G9nIV5NVHExNUz a7JA== X-Gm-Message-State: ALyK8tK50672WrOniV+tvGRyUJYhswSVnHUdLusjyeST3Q7TJ8qtmZd/gl1azLFpkyr8OZcE X-Received: by 10.25.196.200 with SMTP id u191mr784568lff.129.1464172343773; Wed, 25 May 2016 03:32:23 -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.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:23 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:50 +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::232 Subject: [Qemu-devel] [PULL 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+patch=linaro.org@nongnu.org Sender: "Qemu-devel" 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(-) -- 2.1.4 diff --git a/linux-user/main.c b/linux-user/main.c index 834974a..1f604a7 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 */