From patchwork Wed Jun 8 13:30:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 9164795 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4B95604DB for ; Wed, 8 Jun 2016 14:13:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA767265B9 for ; Wed, 8 Jun 2016 14:13:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF4A127BE5; Wed, 8 Jun 2016 14:13:54 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, FSL_HELO_HOME, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 57A4B265B9 for ; Wed, 8 Jun 2016 14:13:54 +0000 (UTC) Received: from localhost ([::1]:57250 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAeEz-000289-DS for patchwork-qemu-devel@patchwork.kernel.org; Wed, 08 Jun 2016 10:13:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37195) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZg-0004Y2-FQ for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZe-0005qx-F0 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:11 -0400 Received: from mail-lf0-x233.google.com ([2a00:1450:4010:c07::233]:35703) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZe-0005qe-73 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:10 -0400 Received: by mail-lf0-x233.google.com with SMTP id u74so5856928lff.2 for ; Wed, 08 Jun 2016 06:31:10 -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=N/npdIAyPdGn6iSKT9xjbsEqluu2y5fpK4lBtKuIi5s=; b=U7RTVti4XBzYPUzwNvfJcRiKdsi0oahrDgiDHgrn+IJ4xGbTPLuwXHCn9XYmh+u8+P dJOtRpRmIXAa2JqV7Hq6XujSqiPXCLRjYn4PFUhK9fEY/G4E0wg0NnVt5BnRwnGZ8/wr 5R6huv5zCTNvHRV49FUeOZD6ZNFwoe9Kf9OAk= 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=N/npdIAyPdGn6iSKT9xjbsEqluu2y5fpK4lBtKuIi5s=; b=Rgb18t23WdFU2AqqfYE9kAkMe6Nwvl8Rok3A90HC2QKIzQTK/Q9z+xzJiDF2lgFPsZ ALqUj5srOFTl07vJ7wMd7ABZRy8S/LSdMlFZkwch2gdvyrnL4FvEpSspTQcT09nNoCCY P11O8pR96dP6ot7GUBgAI663uBPx4nggi9Fqhu1TdZ7IioKNhNhF3nY16E/KTuQNdDPx 660POOH2GlPtEfhqHkoyMqEgbd0g5i49spIgOkIz1UlmzN9MhOKK2wrecT1RwXARHtAe ZMODHZRYKFm/wa4uLwNz9oDxnPp0jjV1FXTsLShl/JRNop8qjJ+GZwDcaK1AnKPe2tu8 TtjQ== X-Gm-Message-State: ALyK8tJBU2mGIFxKiHGS/lGm7p59lsD9M3neVIqMqbPNKTYkzT5Oo1rz1AB76XRGkFT+B5L4 X-Received: by 10.25.86.79 with SMTP id k76mr4733063lfb.189.1465392669522; Wed, 08 Jun 2016 06:31:09 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.31.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:31:08 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:30:16 +0300 Message-Id: <9e518226f431454ce2d4d01051593b32515b3b55.1465392531.git.riku.voipio@linaro.org> 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::233 Subject: [Qemu-devel] [PULL 35/44] linux-user: Use safe_syscall wrapper for sleep syscalls 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: Peter Maydell Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Peter Maydell Use the safe_syscall wrapper for the clock_nanosleep and nanosleep syscalls. Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- linux-user/syscall.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cecd96c..a931919 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -725,6 +725,12 @@ safe_syscall3(ssize_t, recvmsg, int, fd, struct msghdr *, msg, int, flags) safe_syscall2(int, flock, int, fd, int, operation) safe_syscall4(int, rt_sigtimedwait, const sigset_t *, these, siginfo_t *, uinfo, const struct timespec *, uts, size_t, sigsetsize) +safe_syscall2(int, nanosleep, const struct timespec *, req, + struct timespec *, rem) +#ifdef TARGET_NR_clock_nanosleep +safe_syscall4(int, clock_nanosleep, const clockid_t, clock, int, flags, + const struct timespec *, req, struct timespec *, rem) +#endif #ifdef __NR_msgsnd safe_syscall4(int, msgsnd, int, msgid, const void *, msgp, size_t, sz, int, flags) @@ -9205,7 +9211,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { struct timespec req, rem; target_to_host_timespec(&req, arg1); - ret = get_errno(nanosleep(&req, &rem)); + ret = get_errno(safe_nanosleep(&req, &rem)); if (is_error(ret) && arg2) { host_to_target_timespec(arg2, &rem); } @@ -10473,14 +10479,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { struct timespec ts; target_to_host_timespec(&ts, arg3); - ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL)); + ret = get_errno(safe_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) { + if (ret && ret != -TARGET_ERESTARTSYS) { ((CPUPPCState *)cpu_env)->crf[0] |= 1; } #endif