From patchwork Sun Jun 29 12:14:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 32670 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f197.google.com (mail-ie0-f197.google.com [209.85.223.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 21A0C23577 for ; Sun, 29 Jun 2014 12:18:50 +0000 (UTC) Received: by mail-ie0-f197.google.com with SMTP id lx4sf44829600iec.4 for ; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=CyXw4/i4LJRMpzybZt/7tPxECAyNNM3Zus5CzEYSP/8=; b=LEqjBFlv2mhr+Ilmqldu7/5JfVrtkQjl9KzZWzoaDoFZhbU/g1cLFd25OWdxYGWs4K dEfyxfTd7Oohe2AmL1Vh27UMu1yc8Y8w+EV/7FCcFWc9OjcxlrQ64GWvxQk2KOGkee+q vNpjgsIKrp1jWA7Em+/w0NrgxdTNrQ6X9+QSs/bVHiJ1TyUk8Wtk02ZlH+GbiYcTpRb2 cutejWqrKRDytAQTe/tZp4veClIHJguRslwtT/cmzXl2BlPmwxNJqZMybx9R2+XEIyEU hjCbwoPMENuY+Qc9Bm0VWK8L8nDcrJ8/1ykH89iZJd8WLP92GKbqPooUaoOYvTUjEzDj 1Rmw== X-Gm-Message-State: ALoCoQlLqCdPPK/Xy5olB395D2CehlT+i3aa1qlay7q/FyK07INYh9xlIp9TbY2HPPbMhzYeSQZV X-Received: by 10.182.181.35 with SMTP id dt3mr19750925obc.9.1404044329645; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.94.129 with SMTP id g1ls1180806qge.17.gmail; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) X-Received: by 10.221.49.200 with SMTP id vb8mr18480170vcb.17.1404044329495; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) Received: from mail-ve0-f177.google.com (mail-ve0-f177.google.com [209.85.128.177]) by mx.google.com with ESMTPS id ob8si8831870vcb.22.2014.06.29.05.18.49 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 29 Jun 2014 05:18:49 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) client-ip=209.85.128.177; Received: by mail-ve0-f177.google.com with SMTP id i13so7038046veh.22 for ; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) X-Received: by 10.52.242.105 with SMTP id wp9mr26881765vdc.21.1404044329366; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.37.5 with SMTP id tc5csp72469vcb; Sun, 29 Jun 2014 05:18:49 -0700 (PDT) X-Received: by 10.140.81.16 with SMTP id e16mr47145813qgd.110.1404044328774; Sun, 29 Jun 2014 05:18:48 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id g7si21160039qgd.86.2014.06.29.05.18.48 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Sun, 29 Jun 2014 05:18:48 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:57521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E4F-0001se-VF for patch@linaro.org; Sun, 29 Jun 2014 08:18:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47648) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E0h-0004Ab-2A for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:15:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1X1E0X-0000bx-Or for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:15:06 -0400 Received: from [2001:4b98:dc0:45:216:3eff:fe3d:166f] (port=41891 helo=afflict.kos.to) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1X1E0X-0000bJ-HT for qemu-devel@nongnu.org; Sun, 29 Jun 2014 08:14:57 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 4829B26589; Sun, 29 Jun 2014 14:14:56 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Sun, 29 Jun 2014 15:14:50 +0300 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:4b98:dc0:45:216:3eff:fe3d:166f Cc: Peter Maydell , Anthony Liguori , Paul Burton Subject: [Qemu-devel] [PULL v2 10/13] linux-user: respect timezone for settimeofday X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.128.177 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Paul Burton The settimeofday syscall accepts a tz argument indicating the desired timezone to the kernel. QEMU previously ignored any argument provided by the target program & always passed NULL to the kernel. Instead, translate the argument & pass along the data userland provided. Although this argument is described by the settimeofday man page as obsolete, it is used by systemd as of version 213. Signed-off-by: Paul Burton Signed-off-by: Riku Voipio --- linux-user/syscall.c | 29 ++++++++++++++++++++++++++++- linux-user/syscall_defs.h | 5 +++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 4e48af6..0ce1a4e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -935,6 +935,23 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr, return 0; } +static inline abi_long copy_from_user_timezone(struct timezone *tz, + abi_ulong target_tz_addr) +{ + struct target_timezone *target_tz; + + if (!lock_user_struct(VERIFY_READ, target_tz, target_tz_addr, 1)) { + return -TARGET_EFAULT; + } + + __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest); + __get_user(tz->tz_dsttime, &target_tz->tz_dsttime); + + unlock_user_struct(target_tz, target_tz_addr, 0); + + return 0; +} + #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open) #include @@ -6385,9 +6402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_settimeofday: { struct timeval tv; + struct timezone tz, *ptz = NULL; + if (copy_from_user_timeval(&tv, arg1)) goto efault; - ret = get_errno(settimeofday(&tv, NULL)); + + if (arg2) { + if (copy_from_user_timezone(&tz, arg2)) { + goto efault; + } + ptz = &tz; + } + + ret = get_errno(settimeofday(&tv, ptz)); } break; #if defined(TARGET_NR_select) diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e379b45..a1f1fce 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -165,6 +165,11 @@ struct target_timespec { abi_long tv_nsec; }; +struct target_timezone { + abi_int tz_minuteswest; + abi_int tz_dsttime; +}; + struct target_itimerval { struct target_timeval it_interval; struct target_timeval it_value;