From patchwork Tue Mar 24 10:03:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 184768 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5165909ile; Tue, 24 Mar 2020 03:11:12 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuVfXG5/fzOh+rUzuTV3aajzA/uNc5nIWzqbcqfLYatdkf5kfUZAj0U+FkC2qFWo3v8fdYH X-Received: by 2002:ac8:31af:: with SMTP id h44mr19505853qte.252.1585044672518; Tue, 24 Mar 2020 03:11:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585044672; cv=none; d=google.com; s=arc-20160816; b=zcWaoiSoloUnBFjRLGLPdaoczV+8CcrYvkJZmjCj7fFsgyGTasjHqOLnoXfSiUpbfV fPViQ30zygJfYw/AeWcguQou3odQP57V36xUqiSFL/pcJ2aUgvWQvZ1dQNk9bTpnQHbd Q+v40QCLNMVBPYoRTN7b9QrsmAyD3F3euMWAilrVs7eWW1+E6GAO0XwSWvMjEuc2RoJg vQREQ0IKvnJfGJNHjS3zpPFUaHnC2V758c/BIj7O+qKVFrsWI/707Ss/2I+FsqbVw83U cN9PXekJG5BXXJRlpAyAU4/VDr6zTZ48SgblUtb0NrLuD9I5mTDE5qvjl1Q3u4wLbmV7 JJpg== 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; bh=SgXfwN8X4ZTcMhyYWfjN1uvHUfIe1HSiFAkhFnRW288=; b=eoFF+YPyCT590qwE1882WHLmbE0me6FpRDMNlnb/ydkmgdRIX7pMyjrR8gLRQMK1qb +/EYueD70esX4gTyk5ShYewuvn6xhy7LQBraPCQ/Jp5+Ty3PG9TMEy3vnuVifd42BztC x39V8dLtmuHXPXl7Uzr+k/7SxoyRGiTCKsXJ/mBkuY/6K/YIP8ODWPmPyg5SgxvyO9+C yZITqmzSOoIixmUB+BfJrq/e3M2x30PTIO8riGP0UdeROjP655qpOCHkDj01Qif393za sD5UtP+dA573U4ZSMVz224x8dVft8ql9kd6xKU4jYnBIca+iXMr4vHLCvjN87JAYFxgz bgyQ== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id n9si8730536qvi.153.2020.03.24.03.11.12 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 03:11:12 -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; 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" Received: from localhost ([::1]:45442 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGgWe-0008Pl-0c for patch@linaro.org; Tue, 24 Mar 2020 06:11:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49474) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGgPC-0006AP-Uo for qemu-devel@nongnu.org; Tue, 24 Mar 2020 06:03:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGgPB-0000fE-Qv for qemu-devel@nongnu.org; Tue, 24 Mar 2020 06:03:30 -0400 Received: from mout.kundenserver.de ([212.227.17.13]:45343) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGgPB-0000ev-I1 for qemu-devel@nongnu.org; Tue, 24 Mar 2020 06:03:29 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue109 [212.227.15.183]) with ESMTPSA (Nemesis) id 1MNbtF-1isfD40MKh-00P4OT; Tue, 24 Mar 2020 11:03:17 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 5/5] linux-user: Flush out implementation of gettimeofday Date: Tue, 24 Mar 2020 11:03:11 +0100 Message-Id: <20200324100311.588288-6-laurent@vivier.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324100311.588288-1-laurent@vivier.eu> References: <20200324100311.588288-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:BDgKtJ3PdH38sT4Jmsw0Fn45Lmg9valKYxqr6lfeLDh3VR6EOxW QkdRhqFTqyMzdapPI1bsoGxPg/rh165/6KTEAAVh3U0C3UsBgIZQfiAwU9dChvEq956NInB BKUY1n/9Niflk/85K9MiU+mTPhm53uSZfgFAAMLSRe00P7OxiLNCyhskWGaU0DBTdTZBCuE 9Y5C3pzg1lyWAeXqe/p6g== X-UI-Out-Filterresults: notjunk:1; V03:K0:YA3TI2wChNg=:Zvy9njpM/w82aGvMT1aNE9 v+sEmeupzbMp7WAjjkSfUWzP9VSu7vaHKDrfy7GclHAb7co5WQhxMwd3PNSmQYWUgEQURT5c6 kBH3uZKXzNfaSeEygsvXCC2zqHWCzvGmkCF1SQaADaNEHqnAi6tcm1PI0E44S0OQKOAxHzy5D VBcPTAySslMqDnitHajcDdZgVcYHVkojPpWGhN/qI857fSmueWnb3nANxmokc+oTn4QROc3vI tKQLzRUJPqPZoNL++nWxpKchUXKzLHojoglhuLZVY9ekyxxL31raiAmfmJa77aCsefj2Kx7SH SaPDo4AmO/z1DI+MFOABzyXUberenh59lnLMpEp/YmXMFhE9u9BOw1lKU2QYs3GBkSFcdVN25 nR2333e5/rTnk41cHHkTkFd4gL0KpX62FSr77IVg4avzqGZPxv9/6IWftfWXB6XLF065Le5SA 0971qXlNDRAsSXtPxPJe1467R1Oy4UOwCk1pIjZ456Vvjp1jo2YDfTfgOeojEIAhExFN8Dszj ZSHhZu729beTG7Mc/XhOA+rNaLGywxKAXgCsH/jvx6FRNHO4pXSigAsSsprCGi1L/QXMyuQta NJJVPxwIaPbxZgSeq/aNQUBctSiZp/bVvCOe2lc1XW+giZ8ZrX+x+zWZLG+iu/l6dzH3PGWdk U9rEqawb+b1805Ml/KmAMet5pxY6VChaKebtOgf3LmTyjtfyPOm002MdKvoyxesgq+bAFutqc WeeEp7E4SYBAIfkFToMqyALMwtK2X5tJifhPgp0dFdummiEzYyAyPeERWDmrzwdy90nJDU2rh LT0tO1tbqlWAsPQT8C1/QnlvMtJiJq0t/4gTllO8yzZC9MEZq4QVR+3pWgDXAb1WceGJiMW X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.17.13 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: =?utf-8?q?Alex_Benn=C3=A9e?= , Riku Voipio , Richard Henderson , Laurent Vivier , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?b?w6k=?= Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Richard Henderson The first argument, timeval, is allowed to be NULL. The second argument, timezone, was missing. While its use is deprecated, it is still present in the syscall. Reviewed-by: Alex Bennée Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Richard Henderson Message-Id: <20200213032223.14643-6-richard.henderson@linaro.org> [lv: add "#if defined(TARGET_NR_gettimeofday)"] Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) -- 2.25.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5675eca962d7..b7e8a98d4dc6 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1273,6 +1273,25 @@ static inline abi_long host_to_target_timespec64(abi_ulong target_addr, return 0; } +#if defined(TARGET_NR_gettimeofday) +static inline abi_long copy_to_user_timezone(abi_ulong target_tz_addr, + struct timezone *tz) +{ + struct target_timezone *target_tz; + + if (!lock_user_struct(VERIFY_WRITE, target_tz, target_tz_addr, 1)) { + return -TARGET_EFAULT; + } + + __put_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); + __put_user(tz->tz_dsttime, &target_tz->tz_dsttime); + + unlock_user_struct(target_tz, target_tz_addr, 1); + + return 0; +} +#endif + #if defined(TARGET_NR_settimeofday) static inline abi_long copy_from_user_timezone(struct timezone *tz, abi_ulong target_tz_addr) @@ -8710,10 +8729,16 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, case TARGET_NR_gettimeofday: { struct timeval tv; - ret = get_errno(gettimeofday(&tv, NULL)); + struct timezone tz; + + ret = get_errno(gettimeofday(&tv, &tz)); if (!is_error(ret)) { - if (copy_to_user_timeval(arg1, &tv)) + if (arg1 && copy_to_user_timeval(arg1, &tv)) { + return -TARGET_EFAULT; + } + if (arg2 && copy_to_user_timezone(arg2, &tz)) { return -TARGET_EFAULT; + } } } return ret;