From patchwork Sun Jun 10 03:02:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138172 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2613487lji; Sat, 9 Jun 2018 21:13:41 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLJxOMcSG1KjQ/BwqQiUHgwdkO7quHpBGipMws7AHw0Et1fO2NkYBDaa4I5vz3F3OwgIiPq X-Received: by 2002:a37:7285:: with SMTP id n127-v6mr10422930qkc.115.1528604021531; Sat, 09 Jun 2018 21:13:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528604021; cv=none; d=google.com; s=arc-20160816; b=IE1ImgCwvyV5dIQ+oCEKpVjmp3bZ59A9MZaJ5NK7RdvSHk9V6at9f5UjA+Q8SipU/w V1Y8jJ1xIzlxa1+za5ch4UkECuLcSD+xUbvqTnFDBXm+i47ugZN8b5nBO6Ut2rdsir8d PjmyfQj1/SlzfPih0YSyyEQL7lou4F7ARholdcDd5yqyym+IUdxgH540slUZMhx+/osd OWZkJbBXMZqXCmz2i2H0doS1bDrMVNTNkxj9X0qdtG0QSCz2EPFreRwVv3A+nR+BiHjL 3veQ/WRaBsOHazwleRsfUOJzoRYMAbEgOCvD/auVKYldiHxsvxYDSqUSKPOOyhivv32T 9WXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=LuvTD7CGllnEl8qTnYb+xCP77n4plav94tEHWy+prGt84zdzKbhIJCyW0iOe/IJxyp v4HXo0OAtyR2x5jXI/ygMqliw6dU1uTcJ7ee4C7P6NaROYQUQ6/ZDQmb7u+KJB8mmTbc mvjterya2O/mfQUsretmC5dmeZNYMKLYr//U9uKnYnz8qYxVX4v3cfBezQtqtpoOVdaO gFv6goOwOEGAEKu27y3PgGDI2B+mdMKY+e1a07/Ep8a1LK1CkJKTXAEKn9u+V8sZolg/ Oy/p4WC5EVzDkLhRck7QlJk1Xy9UBmSkO3Jqo0ADExlvSISnrDmRZBsngDnjX8JH945C gnDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=Ct+1fZPL; 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 sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 19-v6si3940797qvh.164.2018.06.09.21.13.41 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 21:13:41 -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 header.s=google header.b=Ct+1fZPL; 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 sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42571 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrjZ-0007v1-0B for patch@linaro.org; Sun, 10 Jun 2018 00:13:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqfg-0004LR-28 for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqfe-0004eh-1Y for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:35 -0400 Received: from mail-pl0-x241.google.com ([2607:f8b0:400e:c01::241]:46239) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqfd-0004dh-RS for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:05:33 -0400 Received: by mail-pl0-x241.google.com with SMTP id 30-v6so10377909pld.13 for ; Sat, 09 Jun 2018 20:05:33 -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=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=Ct+1fZPLqhdNSI8sq9W/MvvS9ROLxs5vxipxzEHEqx1FZAt4RqVO0V4XrWRc+YVzXq 0f6XXG9cpJjNGcktaMmCqp6x1tRko22eDVglM9Dvs02APGCRnnY4fsAuH4S9ou4OesRb TQBcwz4iAN73pi2ADkJmc777OCHw/Jn9wbzP0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=8Y8kZFXegldiuJhWMbnQBcSjLznnrPjyMoEA0SOXIxM=; b=ozjeqz111XdnjYH6z0hfoUFUcDGOITvP9fYJTg/h64xO8xuU5eCk5WdD4vVgBtSo4T EsCmXQaJqKspl2aWdtuzdBaIm8SgYY3hToqbc0L/GMQk9Ic1Qvplq4VH/3DZlBBtYrpm Q2V0HQkjHoZGpomltUhuLLjJD8gmVDSdmTnQQlNSVbEyEBVHDhfN19hRooEOj1tAsSAS 9e20qMifS0573r+m3jtp7Qh63GwNFxTaaCzjeTbQcwKMUT2AlIgUfMEXBuObLvLBxrB2 0tkZ1KP68yZRUHj+Cthlrb65A2V/5G8FX1BhC3HfqSOIbd4TN0l1/FJGosujKeJ3T88i 5uAg== X-Gm-Message-State: APt69E1+LRwO3P4Zi/0zmrGgiD0L2I9d6u2SLS9yCncFJPjZnxKgjm0h jwYswhk52+OPPdqtCPJqUYk5vC5xNMw= X-Received: by 2002:a17:902:9f84:: with SMTP id g4-v6mr12924340plq.339.1528599932656; Sat, 09 Jun 2018 20:05:32 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.05.30 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:05:31 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:02:02 -1000 Message-Id: <20180610030220.3777-91-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c01::241 Subject: [Qemu-devel] [PATCH v2 090/108] linux-user: Fix clock_nanosleep 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: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" When we switched from using clock_nanosleep to safe_clock_nanosleep, we changed from the user-level API to the kernel-level ABI. These have different senses of the errno value. The special handling for PowerPC is not requied while we're following the kernel ABI. Fixes: 9e518226f43 Signed-off-by: Richard Henderson --- linux-user/syscall.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 6f19f75c67..1c1e05dc26 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -7884,18 +7884,20 @@ IMPL(clock_nanosleep) struct timespec ts; abi_long ret; - target_to_host_timespec(&ts, arg3); - ret = get_errno(safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); - if (arg4) { - host_to_target_timespec(arg4, &ts); + /* Note that while the user-level api for clock_nanosleep + * returns a positive errno values, the kernel-level api + * continues to return negative errno values. Also note + * that safe_clock_nanosleep mirrors the kernel api. + */ + ret = target_to_host_timespec(&ts, arg3); + if (ret == 0) { + ret = safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL); + if (ret) { + ret = -host_to_target_errno(-ret); + } else if (arg4) { + ret = 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 && ret != -TARGET_ERESTARTSYS) { - ((CPUPPCState *)cpu_env)->crf[0] |= 1; - } -#endif return ret; }