From patchwork Wed May 25 10:31:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 626101 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rF83y2Xtgz9sBf for ; Wed, 25 May 2016 20:42:22 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=Xz+/85+M; dkim-atps=neutral Received: from localhost ([::1]:58853 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5WGZ-0001tf-DI for incoming@patchwork.ozlabs.org; Wed, 25 May 2016 06:42:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41310) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W73-000178-QI for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b5W6w-00038y-CJ for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:28 -0400 Received: from mail-lf0-x230.google.com ([2a00:1450:4010:c07::230]:32952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b5W6w-00038c-3j for qemu-devel@nongnu.org; Wed, 25 May 2016 06:32:22 -0400 Received: by mail-lf0-x230.google.com with SMTP id e131so16310209lfb.0 for ; Wed, 25 May 2016 03:32:21 -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=tGAx9bzvizifq6o+i5qt7qg4ZsT63dx00DzIoV7T3fE=; b=Xz+/85+MYo6guAzWqdXYCtl0szKIEOjymCfkELfDndhe7XE3seXVUM+yNKliRZV19e ct75cRLjtV5+QIVsZcd5PH6y9m8RHYs/scnsLhSM7UlLDrVseT4xpKCVo1RM5kIc/sCL YfNrgIsBPNZ9cw4QOwHN68NhNQOu88Kz86uHU= 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=tGAx9bzvizifq6o+i5qt7qg4ZsT63dx00DzIoV7T3fE=; b=Lai2b3D4aCz+BYpQRO8Chq5TQoayS99H5RVPlBC86pvztsUSIsiCtBJ85gs49V3OaU GIi/GyKOqoRdz851+6jRwcj5Y58tUd6YbknzsRnKfkHt77tep/KBd1NdEWvEB3JolkEP FcQv8HJEa12CxLuamgK6PgLFZryWlaiA4fjLm5ElQ4R2lIGQC0Loas2TBUpYFa9enZhG yGthFQlC6joVwwJNFMyEbX/uxK8kQhHrPnSAyfYj69cvUFF4n80Hiurzrk5tzyG9rwF9 g068h23HkXK8UVZfkZwzo6FSI2xv5kPL/m1oL6ENTifHC/DAfhYXGFwHU14Kq2zHahv0 22+Q== X-Gm-Message-State: ALyK8tIWrPx1HkI30uOfXC13siO1D/Tplpx+aDg5YfgqhK5QsL1ISB7O4Q9Ry5EBEIJ37Aji X-Received: by 10.25.17.197 with SMTP id 66mr609991lfr.113.1464172341316; Wed, 25 May 2016 03:32:21 -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.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 25 May 2016 03:32:20 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 25 May 2016 13:31:48 +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::230 Subject: [Qemu-devel] [PULL 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 05a44ea..2bd620c 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);