From patchwork Tue Aug 19 08:32:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35568 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pd0-f198.google.com (mail-pd0-f198.google.com [209.85.192.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E6FE72136C for ; Tue, 19 Aug 2014 08:44:17 +0000 (UTC) Received: by mail-pd0-f198.google.com with SMTP id fp1sf48059131pdb.5 for ; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Mb0NKT8juJ6nvSFQGYc63j3ofxwiEfl9nNu9IMPF2P4=; b=NMbhvjGR+oi/uYvMAdaKizKjY8dGydpDgKbNJnkIP6UBMRvp+XI/4dl+fAvUcOtf+X wkGiOS11z0SVrsi8Ijg/dzAndzAWVzH3mXPKWhayYp5XdJyb9u3Gqb1egkpJy+u7bXTZ k35QUhphLm7qR9tt2wlUg0lifUq/qUjG2h2vAozCAzPGXRXsC04PGHy6D76+d2pUVpz/ 574BdCnJi0jqDgMfmpAi+d7Q9fB4zo/NQGC5glHe5aah8hoD73bMJCY03nbJC3I3ruo+ aAoXOhubIQpszOuW6/DHNvLNNMtfkeIHr6ilqtYPwDy0MfiL4LX319/9ybIUfIvUSiuj re9w== X-Gm-Message-State: ALoCoQn6Svu9jGSGSQF36Wo0HTWGnzzUK3d/wj2bIvRR/HRBqsG9+riq+1oKmx79JC0s4YLOxET+ X-Received: by 10.66.241.104 with SMTP id wh8mr21340278pac.33.1408437850311; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.89.5 with SMTP id u5ls2894290qgd.72.gmail; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) X-Received: by 10.52.106.198 with SMTP id gw6mr8464288vdb.23.1408437850145; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) Received: from mail-vc0-f178.google.com (mail-vc0-f178.google.com [209.85.220.178]) by mx.google.com with ESMTPS id xc7si8354675vcb.32.2014.08.19.01.44.10 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:44:10 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) client-ip=209.85.220.178; Received: by mail-vc0-f178.google.com with SMTP id la4so6952243vcb.23 for ; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) X-Received: by 10.53.12.225 with SMTP id et1mr29181607vdd.5.1408437850055; Tue, 19 Aug 2014 01:44:10 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp220853vcb; Tue, 19 Aug 2014 01:44:09 -0700 (PDT) X-Received: by 10.224.51.197 with SMTP id e5mr12474313qag.48.1408437849429; Tue, 19 Aug 2014 01:44:09 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id z2si10078381qgd.101.2014.08.19.01.44.09 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:44:09 -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; Received: from localhost ([::1]:49155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJf1U-0002O2-Qr for patch@linaro.org; Tue, 19 Aug 2014 04:44:08 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeqv-000151-0a for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJeql-0001aY-Rz for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:12 -0400 Received: from afflict.kos.to ([92.243.29.197]:35154) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeql-0001YY-MH for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:03 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 6AA5A2668B; Tue, 19 Aug 2014 10:33:02 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 19 Aug 2014 11:32:55 +0300 Message-Id: <784a0cac9e5d25bbde4ae9844d54785c5457bed2.1408436940.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Tom Musta Subject: [Qemu-devel] [PULL v2 20/23] linux-user: clock_nanosleep errno Handling on PPC X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.178 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Tom Musta The clock_nanosleep syscall is unusual in that it returns positive numbers in error handling situations, versus returning -1 and setting errno, or returning a negative errno value. On POWER, the kernel will set the SO bit of CR0 to indicate failure in a syscall. QEMU has generic handling to do this for syscalls with standard return values. Add special case code for clock_nanosleep to handle CR0 properly. Signed-off-by: Tom Musta Reviewed-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index a24356d..e4be32c 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9103,6 +9103,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); if (arg4) host_to_target_timespec(arg4, &ts); + +#if defined(TARGET_PPC) + /* clock_nanosleep is odd in that it returns positive errno values. + * On PPC, CR0 bit 3 should be set in such a situation. */ + if (ret) { + ((CPUPPCState *)cpu_env)->crf[0] |= 1; + } +#endif break; } #endif