From patchwork Fri Aug 22 13:24:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35809 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-pa0-f72.google.com (mail-pa0-f72.google.com [209.85.220.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 6DEFF20540 for ; Fri, 22 Aug 2014 13:32:00 +0000 (UTC) Received: by mail-pa0-f72.google.com with SMTP id eu11sf85262968pac.3 for ; Fri, 22 Aug 2014 06:31:59 -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=rEz5p34axmglr3HqPitXHH54rkKxcQyKM/Q76VuHekQ=; b=Biy3V5qgYJlJO4y4eTcRXzIcEXnKZCH2Zwu7rEWaTtU6WMvztOoID7BmcHeKfgKQG8 4FPCMR0+U0SvqVZNViJWh9VP9BdYO3TCLK/Z2y6jQNsl0kVRY2NEY1w4rzvkYoOboTyi VkTkgeWVuIabDwLAbGJHMlYlzmvAU5xaM8+KtgtTtTBh6yL2O/rCCMB2G+tLHSQY/Fp8 qJ75GtX66gQnh7uN4Dau7237JdhKI59YdkKjY5XjwD+ibNXoQXhkRpKHy/3WvvXw8PfM ZD6tZmqI89W4me6vHprxhwSrlhSiQX68kaCRFGIXN3POPmOoy3OiDZpClGgq3UePMMy1 lsTg== X-Gm-Message-State: ALoCoQmSE5b4MoWgrRGWyoCGu0hHAKR+w1K2BYNY1rhEMBCdDC+AIiBg1O/zETYID4VMtWCgnox3 X-Received: by 10.66.141.48 with SMTP id rl16mr3275904pab.1.1408714319765; Fri, 22 Aug 2014 06:31:59 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.42.133 with SMTP id c5ls1210956qga.38.gmail; Fri, 22 Aug 2014 06:31:59 -0700 (PDT) X-Received: by 10.220.127.17 with SMTP id e17mr85333vcs.56.1408714319662; Fri, 22 Aug 2014 06:31:59 -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 n4si13561960vda.71.2014.08.22.06.31.59 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:31:59 -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 la4so12315361vcb.37 for ; Fri, 22 Aug 2014 06:31:59 -0700 (PDT) X-Received: by 10.220.96.137 with SMTP id h9mr179396vcn.46.1408714319593; Fri, 22 Aug 2014 06:31:59 -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.45.67 with SMTP id uj3csp17121vcb; Fri, 22 Aug 2014 06:31:59 -0700 (PDT) X-Received: by 10.140.83.17 with SMTP id i17mr7645481qgd.16.1408714318500; Fri, 22 Aug 2014 06:31:58 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id j49si42242567qga.126.2014.08.22.06.31.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:31:58 -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]:37129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKowg-0006Jz-2V for patch@linaro.org; Fri, 22 Aug 2014 09:31:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55442) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopq-0006Zr-9c for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:25:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKoph-0002Cq-6z for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:54 -0400 Received: from afflict.kos.to ([92.243.29.197]:39323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKoph-0002BC-1J for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:45 -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 59FF4265F1; Fri, 22 Aug 2014 15:24:43 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:37 +0300 Message-Id: <8fbe8fdfbc7576c58c59b605354457cc02076304.1408712881.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 v3 19/22] 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 ed32f97..450f22d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -9033,6 +9033,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