From patchwork Thu Mar 26 07:23:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Laurent Vivier X-Patchwork-Id: 184841 Delivered-To: patch@linaro.org Received: by 2002:a92:1f12:0:0:0:0:0 with SMTP id i18csp1532305ile; Thu, 26 Mar 2020 00:25:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vvleAoVp0+Z8BSozrkzZtxjDqV94x8b2qE3f5FP8azk9jaNkfUZhfc2EHOh2pvdeWt2TwSZ X-Received: by 2002:a37:b285:: with SMTP id b127mr6613614qkf.413.1585207547029; Thu, 26 Mar 2020 00:25:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585207547; cv=none; d=google.com; s=arc-20160816; b=FK7+rPWAEixwapF84mekngnGbnqTJzM5bmttc8JJEV5T/xAIptheVmMTxWFKC5tXU5 mRmovxqXzj7eIlKvyVTIC5eE/att9tOn3mkn0hkYwCHraVfj8iJQjvyu0GNRcKz3lBTb ciI4xE19ctbrJT4FOWhh6woeJg8bxAJfhipyVbiM3pmGrFp/sh8tT1KiUQmCX/cpsMSL uai8fmzuCEtqq9EndKkcCK9sLz5ka7MF6r0LZneuRJZcAS4KWiVfGjyw/eUnpdO8cEBq 30sbIo33bvux1gEsApSe1IGUEaOazKzjgElyPlGvdJKMb+Hbr09mq2XiAmUcAjKJIH65 rBUw== 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=JbCoMnS15YyWTDAfYJHz3Tzv2eQY1bfJmbpo5wAElYc6R9fSC1LSG+uDz9pBwDQoUb dEHkHqvhaLL4E5fyV1MEH4dWXOqTAEI4i6U4L0aPTj7Bpr5/YUa0oMWZ6gkD4KnPwGw9 7q1hOP+pnWBM9EVg0KbUQvccTurb796etE/oPh0Du9NzqDH4k2ouuTsK9DF9s2zbrFT6 DUD+dQulvbTc5yQd8GqqsJYi22/ZUNdQ/L+XTa2oHCfU7fSz2CC/VTi6/Gmtu3lOV9vb sD6g5D0UIhqYVRx9qR9nDXVZTOv8CynES3lMbkrH3mTnwWhFYhk1HmqslmM0UHaPZ4n5 oziQ== 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 m1si776568qtc.342.2020.03.26.00.25.46 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 26 Mar 2020 00:25:47 -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]:47494 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHMte-0007Vh-GU for patch@linaro.org; Thu, 26 Mar 2020 03:25:46 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:57148) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jHMs7-0005Lt-HZ for qemu-devel@nongnu.org; Thu, 26 Mar 2020 03:24:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jHMs6-0007tS-Fu for qemu-devel@nongnu.org; Thu, 26 Mar 2020 03:24:11 -0400 Received: from mout.kundenserver.de ([212.227.126.187]:36039) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jHMs6-0007t8-75 for qemu-devel@nongnu.org; Thu, 26 Mar 2020 03:24:10 -0400 Received: from localhost.localdomain ([82.252.135.106]) by mrelayeu.kundenserver.de (mreue011 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MLzSD-1izybm4957-00HuPH; Thu, 26 Mar 2020 08:24:00 +0100 From: Laurent Vivier To: qemu-devel@nongnu.org Subject: [PULL 6/6] linux-user: Flush out implementation of gettimeofday Date: Thu, 26 Mar 2020 08:23:52 +0100 Message-Id: <20200326072352.2056553-7-laurent@vivier.eu> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200326072352.2056553-1-laurent@vivier.eu> References: <20200326072352.2056553-1-laurent@vivier.eu> MIME-Version: 1.0 X-Provags-ID: V03:K1:AyMp/m+qTp+pVhOJ5OilOky2MM/a0E7P1fmBAFPFBNqJUzH/eqf z6fa9u7kayN6my2rQDVSxgacYH9x4Hb9y4jQsFE48Mg6clu12yJqpMzp4wCXC6CN7y4749A AqVkYQ0gfEvskjMouQovGbdNF459vI3JkGDDaR5B6Qm0dIL2H1GwMzntz8rzYetNanGVMWC dw8735EZa2a+erF5N8Lkg== X-UI-Out-Filterresults: notjunk:1; V03:K0:HZRrY2G2UEM=:LhOmrJb75zcWC2H7jLNcHX nEvfvu6K/8TN+cKpRbx93xe5VyrxXQQrVBOebGrggvhnsluz5o+RC5VbfUKvB9ybOnW4PdzCJ 3iOaVjbxenF/BJKUP49Cq8dDU87hm7G9tWRXRVXliB9P/KB5SDotfi0YIZWwW8XIrH1kKHh4p PM7wCL6C04m0z08S87+JMJl7zLBqoZcRn2JyD8cJak99N6SGiDJo9iP4bhDBszGM7huTCvYxe RhoGiX9ed7rzXR0CU9kfDyHakqhQFia4ct0QEPMzGPZF3kRcFRnkdmuIHeoeeLHYNkYmuZsem klpY+ZQG3UYy2HxorEKbR7iNTSn5cxVFXSkdev7O6TkeQR0EHbVU0iZUM+zZtG9jKPU0X9JDk 7Gs7HjLVgmwP5VBC4+ivmU3QNeMFtwsyOvCBj/M33lPwz4mc1EQDkBeLe6VoEzeJmIg9lzH26 2adeTkiqZigL8i0xMuiY4mkgI0AAmXFSDKjBrR4ySqnTcTJEVnGqAS+S6h8CjcYbYzyzVrPaC mFTK99o8ulMAHU7XAsw3FxoTVU8mUlYqyXtf2KNMYrd/Np5IuT3/Zh5Q+TFzZGNWOixuMqdRG xNw2FtQva4fIK/5eLgkDFPRKEycTdlRxxq8K19/prk2rpnfk5juMm9sB3M6a8RiIQntXcE4u+ mfWR/hkmH4bY4CbT3jIxEOe3rbLld7v/lbf37vcc8ozOwxqOZWY72gD5YuvoAQr638XEENsIz e0agLsSS/dq18nAjQapBRSMIK2d7CUJPCmlzY5H/ieET1aPgY/TI9M+RcvIuSMML5INczJSgw QJChRHj/rYYsdBgpLNAeBavaNQybZ0I8c0/FG+ekSo+SVYsXIoXw8E5yn7HT1W7kGKnt0Jr X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 212.227.126.187 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;