From patchwork Tue Mar 24 11:17:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 184773 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp5231486ile; Tue, 24 Mar 2020 04:21:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvSpyI4gs85hv8mLUUJBlIpjzSgAbazYB31/hQVzWffCUuIqrFwtmF4PCrBBWLyxcuEpK7b X-Received: by 2002:ac8:7c8c:: with SMTP id y12mr13073969qtv.125.1585048864252; Tue, 24 Mar 2020 04:21:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585048864; cv=none; d=google.com; s=arc-20160816; b=xCx3ns3U8jU6mnFB/8ybbRc5hsrucKFsZozoOcOial5ob7sKE9SrmnPRtylX86XJ2J +iWSguCNNcLy1oiQpUpL3887GgaLSBdv4XP/cC/k/e8AU/7mV1tgXeOeG0+y6xb1vcKG W6Mp6T7w+o6iBxiy0Mbd2sTwVcZo7Bgc756rCWYKUqgZqx2S8g7Xn9mhe1BzZLKSIcq2 5wqBMTaYkND8WKxrzabFvxQ0pu9dbWRxJpVcCL6mqbP6/n3fqFkdMgrwaoH5rGSI5rZD 63BEpCbGbV7ulersckWfHSqVXE75O22rwVRl+XpfinlZZgbAidF8wkxEssW1jP5bIuFh V0sA== 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=YkItsWsh646TTO0fzSehG+84gTKI50FwAt3l4hA2Gu0=; b=ziDrjj8T0XCpb+Fl4eBt5LGRwCWgppqJUpcbif1f7xkx9QLzVkDovKgBNneiYOQHql vgQMYKznddP1U0ApLGZdNnW7p5j4+M1dtcJftZRKjxjQA7uuNFCPFP6VscrsitTjCucL rzcXbUGHuWt7T7OGGxfgAxPuiF/Kmqu7w7zAxpuiBcDxsd8OcaXmzE20qEQzs3+PusAi xWbqNB7uxIeB925BxQJnHbEtNBh/XaTGifM9i2nx3ZYnF1/5gNyZrcy8jGdfaL7hLDUC E6z61VWo/MtRcPMZtgAnZVlRb/3L6iBX/YUKehtXj3N2EDNeagfzln53+5uEGn+sPT4V +3fg== 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 n7si12032716qvm.205.2020.03.24.04.21.04 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Tue, 24 Mar 2020 04:21:04 -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]:46934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGhcF-0007ba-Qh for patch@linaro.org; Tue, 24 Mar 2020 07:21:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33526) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jGhZJ-00035w-L4 for qemu-devel@nongnu.org; Tue, 24 Mar 2020 07:18:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jGhZI-0007bt-Eo for qemu-devel@nongnu.org; Tue, 24 Mar 2020 07:18:01 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:44447) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jGhZI-0007bi-65 for qemu-devel@nongnu.org; Tue, 24 Mar 2020 07:18:00 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N49xZ-1jOzGE40vp-0100ec; Tue, 24 Mar 2020 12:17:08 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL v2 5/5] linux-user: Flush out implementation of gettimeofday Date: Tue, 24 Mar 2020 12:17:00 +0100 Message-Id: <20200324111700.595531-6-laurent@vivier.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200324111700.595531-1-laurent@vivier.eu> References: <20200324111700.595531-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:nxNTZT40BDeQWB/pCBr2MQyPGlh4spQuOikUnuwKc+qNYYzVl9H tZdUzBP9eldOdp55TCExUBUEE+oRP6NZpOPG/LIsF/OaEbEpFQmA9buPBx5gHkJEGnmfVZ4 YG39jT6DsusHQbhflTUqsccaqCHkfag5/WPsJJaF34HiSNXLZxSEHm/Fsq2Kazdvm90F1VP i7di1p3fOh+Sw+EtAJ8OQ== X-UI-Out-Filterresults: notjunk:1; V03:K0:Rhltnc+KlBU=:4IxLpHu/oKnm8CSNwBba6b 6DhFB7DqW4tSd89qrxpZyBV7Kgglh4bOYPw5RYjJEMdwqoxMtYzNXE+NAjvx2O5z1K0Pjviul YkeQcLqQzomLkin62DYzjYGIsP+ZjjqL7G2Rq3CUh42U608Tvu6P1qB2LLBYoeZ+N1zXre1W5 7H8uwyHVGscU60R60bqY+GPy3jECm4EaMfsGm2NXTLwR1xTr3ZoEvcZVmpIc21Lj9ff29L0Gk 1PS96VkICBekF3IWA47pjQV3XjtkqsOPycu41u87d/uynWTqL+MbWlkbTwYdwkaN1vZjRbUf8 NCz79J/j/7r1ZIiTKKZgwpYkX1soynkdxaUZoqn+2LkrGRrCL5yCDmwx9Xn25hVKnxeK8LJ2G knnygqmV1IpUjumjv23tmqsc0ZfAgNQ9dqyLh13l8cQimWaZZcx/U6R3J1fal0xQZl8LuDH1I eY6o1Q7PkI7I0Sst/AeGIlEUIC6RIxel1lBY/oxeJ4LhwOjx7EHPDSePz7w7ZWoXJy92RvN5G iRx1irjv/JMJ6SryBkl4mZlGhuIbCklGMGmgP1GTkOYuqhoq7fKCunmXu6V3w7dnxDRCBXydl jrpC5p77lAgwHLTFpXcbIaMSnvKFMKfwh6ZLBYwJp9GLL47fC6I0bTPOnK8mXhCEu93/qsTI9 +XgDQ5lc7KQ/Bi8hXW1POA/RoL/iKb4L8xwdzOPEeRSVuEM787107/dWm5o72Dy6FTGb9HTM+ kGadevAtZwU5PydCVrN1ZMRZJFhBXxW7PdyUPPLKvVOcNt1WONYwKQL30Yv55WWzeT+zwRgps 14/lE6s7qJR9ekw8/5um2BAe635gVyL9mwVlzusrB30l1tcQQmiHMGyGcu+OhEWiZgaJOTc X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.135 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 dbdd56e42077..49395dcea978 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;