From patchwork Mon Mar 16 16:15:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 184584 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp3110158ile; Mon, 16 Mar 2020 11:05:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vt5Ak4U6fpwQHSEUUAkQ5LHxTX28D+g16GqvSsoQ928kkTKFQ5fyIsjE1dZmouSNgp5KpNO X-Received: by 2002:a37:ac19:: with SMTP id e25mr964510qkm.54.1584381929657; Mon, 16 Mar 2020 11:05:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584381929; cv=none; d=google.com; s=arc-20160816; b=bCA7dOhvD5HDOtqXhBY3xcADFJQkhLjgvWD7M2oqyfou+4df53pgnzoRdG8OIgSKyO 38PF6BuZ71J+oYzfWbKIIDyPOU+15wTJ/lK66b/Dv3m0dJTBPOIR3Zi2ZZXCGukDKush THueo6cz/Q8arbMdgBJPm5vLBoVGg9SFAOzzvUTIOrr2ihLw1E5lCWwBtg0Jbs1EO8Hk BivRxdwq8pDv5PMeexYOokSXnTBZdO+S1Gzs8s26MDh9m/5HuyHi+ooJfviGMAtBe1R8 GbVmGtBwDlsLURmWc8/F8kLtz8EjbZllily90IBOGih64MYbiwvaX8Qiw2OETLwOp/Uo lYoA== 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=i4YHaSqDqOSpUB9V6QUIT7Ej3Vzz/Y8QuNSGvrOpfjA=; b=J0B9TAv1mmjAfZPaq7smDus4mx5Sa0kh0VDPC3n7h0GicMNhy/c/JwxKP/VDOVv1ls 9XqHfQwHjvVT8ImZlzteQwmROK1r/CxJZYbN7xX53IZDRuXlDtwZTic5tSZa6QrDPsgZ DPlFLnUpz/cHug2Z85PKNIoytYPC1LUdeC404r6IDwPyX0MvL1IjpIDo70qcq9sYN0X5 4WHcQ3IYslygqFD1izNWhtEJty3xMDSlrqjTr4/shknilrmcJwfyZYcE8YEJ80B+XTjQ japsGGfEvz0zPZYS9/fRFvKhnztX/aLXazNlo9yrXejtrl2lci0eaynu7L0j6ownZrna iLng== 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 13si504827qkv.290.2020.03.16.11.05.29 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 16 Mar 2020 11:05:29 -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]:45240 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDu7F-0001hK-3g for patch@linaro.org; Mon, 16 Mar 2020 14:05:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:40314) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jDsPe-0007uS-E5 for qemu-devel@nongnu.org; Mon, 16 Mar 2020 12:16:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jDsPd-0008Jz-7p for qemu-devel@nongnu.org; Mon, 16 Mar 2020 12:16:22 -0400 Received: from mout.kundenserver.de ([212.227.126.131]:44111) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jDsPc-00089c-Sw for qemu-devel@nongnu.org; Mon, 16 Mar 2020 12:16:21 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue012 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MJWgK-1iu9fF0v5k-00JtBP; Mon, 16 Mar 2020 17:16:09 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 05/38] linux-user: Flush out implementation of gettimeofday Date: Mon, 16 Mar 2020 17:15:17 +0100 Message-Id: <20200316161550.336150-6-laurent@vivier.eu> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200316161550.336150-1-laurent@vivier.eu> References: <20200316161550.336150-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:2+OnKEYWuZtt3LxPwxgWv2MmMh5zFI/qbCEo/Y0vnYsZo1wgRYE XNrFQkaN5nIM6oooTEeFIYSAFrRg38LDumZGna+54GdMhnqhq/41MZ5xndr3aCitIgC+T7Z yrztQN6I19hQXnoOz+hQLkfBEEiYILpfXEl8nJx1+xkVzYqm+lRJ3riYujlsC7jHygr28fP Fl8LsgikLMxCRAqgVWZvw== X-UI-Out-Filterresults: notjunk:1; V03:K0:1lgY4n/pUaE=:1ivdzdwoXUHX6ENjH6hC9+ 2ByfVFANsSd27UMZmS4JEQw0ZJu/hqzsAJvOCmNaNPZmwWwdb79/LQbng227raBS2r+my/K2L DrWjuJ7BQtBy4H8XU4p7cfDVfeajz1b2pRIcRpvc03lLqEYTRdrXXdMYfZ+oBROa8gnNHoITj gJJ4koCHS93o9lI6sVO11j2Egjl6ar8bFKtMv7Wn6xF6pgXS7Dd2NGhqA9Gzw1xc8yl4rv283 zvt1JPS+NWCp29Pd8+bMtMkmrWsElboxajHPZYwOsLAjRKV+YGQrKKwZyUcz1cea78r7/Wwun rlRxyRNfq6P157K/0GpKMDxH2mxlbtNTolhwfwmbokn3a901hww5Gk5yg1bzaToMp3mm0ntXg A3Oci06rf12zs2HHwav58gYG4uwmuyLCkUqi3X6nowP93qr1iF/QcTXxas1jz5Bqj2uSqmSZF g8mUkREfORnPM4TIMWfc9zb7/uKzZWWDF4Nc01WZqwiKGlWmakad6aKZY96p1rMrbnU+ZPE0Q 4KkyWxR3E/H/6BhKcz+2U7g3COtxmmNZivjOzGEjlaMDAczItcT6TGEDEaORxn81fTDhEat9B KeyDNCqAeg6rY7yNHHvmLbljWNsqTUj6q2dIl3z5lywbV4cKKBC2V4M3clvFeowz4Z+KyMb6G z7pcCYPnD+x3sD8gXiXyQSGUGuATWGcdrI+lq7i+aKPzsV4U4iMusKem84EyPp+CKvjHJEoh+ qkElwRxUZ11ebBIioxOzXueQ9LS2b72RPN68D65gyG0nqbDsCXff1EAdWSFkf/ZsFzsqujYAn VtHcXm65RV03EA0WigD/eVxeO3RsZVTbUqAkC00bVwR6+MdsyOn3cipSyWnvJkcTLM36Kn7 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.131 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> Signed-off-by: Laurent Vivier --- linux-user/syscall.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) -- 2.24.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5479d67a10be..811495c3a0bc 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1228,6 +1228,23 @@ static inline abi_long host_to_target_timespec64(abi_ulong target_addr, return 0; } +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; +} + static inline abi_long copy_from_user_timezone(struct timezone *tz, abi_ulong target_tz_addr) { @@ -8642,10 +8659,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;