From patchwork Mon Jul 27 12:23:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Alex_Benn=C3=A9e?= X-Patchwork-Id: 247176 Delivered-To: patch@linaro.org Received: by 2002:a92:d244:0:0:0:0:0 with SMTP id v4csp4758507ilg; Mon, 27 Jul 2020 05:31:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxgQnb4Ylicnld3cmfcuM3WeXXkf01rFW3uq/VuOTH2mWp96ZEpjfU3a2tB4oUToFxHVIUI X-Received: by 2002:a25:5545:: with SMTP id j66mr7262027ybb.232.1595853080978; Mon, 27 Jul 2020 05:31:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595853080; cv=none; d=google.com; s=arc-20160816; b=ltLMx9f9fm8syL/7sJfZqTz/CbiGheSOV85wD1tBKBeP+UhOYHzcEZOonnwHBfe97/ J1OP4B0jErOFxhxfdxAogROlLabe8GldHRbs+ySIB/jx7rDXLZ0PkiUEobKZz3ol8vDa 3UdRSkKCj3KPren1eadGCRvSJnpKEsf+ofK+2ygP17QEBcGmAN6HF0VXBNTbnPLle00M KLzhNjkjnaqPgVq1S3Cu5Ibf8TEnsiFo85Xw+j7OuMsjMx0Xjl8CYFCKRcCZ0PGvtzJ6 eiQ11cQs2qB9EoUJMt+4H5KhNinnEoxvrsKwXwx2wxDg6LDwtyK5YVMbuQDmk3/SD5Is MNJw== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=A1EXBcwTpNFpPkUTTl0N+dnXsHPfdMclDDa4XH/uy3c=; b=AujJsoNSMudZ5vZJWGHuMe0ZjCOAmvYEC02/bkcpViPew7x5qZAgBZO+vwxqUxixxy FbypQGKXTNFtgXLpTokDZ0GPo9z8yfqlc4r2ph+6S6qkmbADbaH1vALMSksGJ54CM1Fd xPt1tjxdoxvKEUC9pgeaFDVIItukDSiJ59cEzRIR/Ew454or9l3kjXmcRswn1nLuyBu5 Jf+8rV52a9VEW21VJri9eNCyIFL71cg9suR34r3xNeiwPq5rkQqCxT7Z1WgusIQRK7kf iF/yJ3tOfc2sR1ux16F9Nyx0O35L4yXmWkt0Pkox1cCHoovTFSIWki+Wn4msjNNzAs7r X97A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GpDxS6kJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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. [209.51.188.17]) by mx.google.com with ESMTPS id i3si9648739ybq.145.2020.07.27.05.31.20 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 27 Jul 2020 05:31:20 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=GpDxS6kJ; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 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]:38810 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k02Ho-00015B-EU for patch@linaro.org; Mon, 27 Jul 2020 08:31:20 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37072) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k02Ay-0007Hl-0p for qemu-devel@nongnu.org; Mon, 27 Jul 2020 08:24:16 -0400 Received: from mail-wr1-x443.google.com ([2a00:1450:4864:20::443]:39735) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1k02Aw-0006RT-7f for qemu-devel@nongnu.org; Mon, 27 Jul 2020 08:24:15 -0400 Received: by mail-wr1-x443.google.com with SMTP id a5so4689632wrm.6 for ; Mon, 27 Jul 2020 05:24:13 -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 :mime-version:content-transfer-encoding; bh=A1EXBcwTpNFpPkUTTl0N+dnXsHPfdMclDDa4XH/uy3c=; b=GpDxS6kJwD6PpBilKFPpAq0t7I7YaSo7GEP5XxSugJv2CnQkFEJv4K5ZqFMEv6NTSD ClqBtKPxjY2aFrolaWyO+UwQQUMHdhFZ7+t0Euo9EjvvBuyDXOLt0GCnHwBuNa8LNc6t NCibKexDPzrteSoaxwlhUPYatsmlKm/eISas3HHODoA8YMIeidk8i4yTwNfxWT4mBNbF 5INJN7wUlsuQe4dv26lCwf3EGGeM8foRJlxpceBnmWstFHYK53ZWWvdi31lxwgJ+qjKr KDGSKPFDV/Vc85nDdpioFA6fwAaZGAzlji20WAfcPAy1V6/ldXJZuF2xAVMeuFiyHvof /GbA== 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:mime-version:content-transfer-encoding; bh=A1EXBcwTpNFpPkUTTl0N+dnXsHPfdMclDDa4XH/uy3c=; b=Jehq1maJYkT0mjIIilYRVlfNz+6Tc4E7te8QinNFCkLvALhMYsztiKcmwZewYLi/vJ 0FYS7sbGrZfxAs11lNoiXNDAWc/Hp5Mq0rifgDHgjX/+/8A3OfvSdNhHrSu7dzG8A0nq UZHyXpmNf5d9TOm2XCIzuGXFz4SJ5WHH2MKyOMn4e0VZcQ+Mmke/kaD9sYPU8xEdFItp vZ86TYxsfIUsQFonOvwVB9GaeHMF280wrrtYhAKCkY7hGb3a7YNsKDkLFeW4eH/gLhr8 pVd8Zgg5vrC1QJ4d5jMo5Gf3I7VQBBtX5kk/I/TFxDYb6Lu7uSoqaZMrVmRIy9OWWkmL YlyQ== X-Gm-Message-State: AOAM530Ean0TEPS79lLdhwr7AjtLgMabs5aybO5C3Jm8BGfQPBS+uNaY hbj+Nq6HdoNhqr3LKBO3dXjdvw== X-Received: by 2002:adf:e902:: with SMTP id f2mr11465106wrm.174.1595852652822; Mon, 27 Jul 2020 05:24:12 -0700 (PDT) Received: from zen.linaroharston ([51.148.130.216]) by smtp.gmail.com with ESMTPSA id h14sm7341410wml.30.2020.07.27.05.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 27 Jul 2020 05:24:06 -0700 (PDT) Received: from zen.lan (localhost [127.0.0.1]) by zen.linaroharston (Postfix) with ESMTP id 7EAA41FF9B; Mon, 27 Jul 2020 13:23:58 +0100 (BST) From: =?utf-8?q?Alex_Benn=C3=A9e?= To: peter.maydell@linaro.org Subject: [PULL 12/16] linux-user: fix clock_nanosleep() Date: Mon, 27 Jul 2020 13:23:53 +0100 Message-Id: <20200727122357.31263-13-alex.bennee@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200727122357.31263-1-alex.bennee@linaro.org> References: <20200727122357.31263-1-alex.bennee@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::443; envelope-from=alex.bennee@linaro.org; helo=mail-wr1-x443.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Richard Henderson , =?utf-8?q?Philippe_M?= =?utf-8?q?athieu-Daud=C3=A9?= , =?utf-8?q?Alex_Benn=C3=A9e?= , qemu-devel@nongnu.org, Laurent Vivier Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier If the call is interrupted by a signal handler, it fails with error EINTR and if "remain" is not NULL and "flags" is not TIMER_ABSTIME, it returns the remaining unslept time in "remain". Update linux-user to not overwrite the "remain" structure if there is no error. Found with "make check-tcg", linux-test fails on nanosleep test: TEST linux-test on x86_64 .../tests/tcg/multiarch/linux-test.c:242: nanosleep Reported-by: Philippe Mathieu-Daudé Signed-off-by: Laurent Vivier Signed-off-by: Alex Bennée Reviewed-by: Richard Henderson Message-Id: <20200722174612.2917566-2-laurent@vivier.eu> Message-Id: <20200724064509.331-13-alex.bennee@linaro.org> -- 2.20.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 1211e759c26..43a6e283961 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -11831,8 +11831,14 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, target_to_host_timespec(&ts, arg3); ret = get_errno(safe_clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); - if (arg4) + /* + * if the call is interrupted by a signal handler, it fails + * with error -TARGET_EINTR and if arg4 is not NULL and arg2 is not + * TIMER_ABSTIME, it returns the remaining unslept time in arg4. + */ + if (ret == -TARGET_EINTR && arg4 && arg2 != TIMER_ABSTIME) { host_to_target_timespec(arg4, &ts); + } #if defined(TARGET_PPC) /* clock_nanosleep is odd in that it returns positive errno values.