From patchwork Mon Jun 23 13:26:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 32369 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-oa0-f71.google.com (mail-oa0-f71.google.com [209.85.219.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A8B34203AC for ; Mon, 23 Jun 2014 14:34:24 +0000 (UTC) Received: by mail-oa0-f71.google.com with SMTP id n16sf43585861oag.10 for ; Mon, 23 Jun 2014 07:34:24 -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=Hq1MpFpMDKCKpBRw0svnZT3LKLn8OtDRcavIJoMV2yk=; b=lb+bgu7rAhWk7mnEoRi+BsQ/apnGKrKliP4lsVIOs5PPi+N14zMmpFI8WnFApyacfP k9O9MYxu35mmsNCU73+30SQaM8AFOegBLEFYRWSUNMdci5c/u/3ofyv6ivm+VlzCslmZ ShdjF5o+0GvC7dbZDdRIDAkao/jzPJotAs+RNyC8SdJH7V3l7kPaBJ7gxYgSh4aaAQFt gxLjmm47KBMJn2QVSQ94Bvit8CjklBwHW815FjPBwCU934uVs3ItGw0y0Z6gGaW+aGUN qIaoDrZOBLl4329FHqkY2joqA1AzZh6XUEdhY0KJhnHSULjB0lWexmD7EoiyB7QK4J/L TNDw== X-Gm-Message-State: ALoCoQnjw2CyWLqD37M3bOSO4JVmSC8Pv4M0Z1ZcYQHGNwU+ezm2JXfDVrulhWWM/ljDDjATO9yq X-Received: by 10.182.241.33 with SMTP id wf1mr6428269obc.37.1403534064204; Mon, 23 Jun 2014 07:34:24 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.80.114 with SMTP id b105ls498216qgd.16.gmail; Mon, 23 Jun 2014 07:34:24 -0700 (PDT) X-Received: by 10.220.167.2 with SMTP id o2mr19575580vcy.8.1403534064062; Mon, 23 Jun 2014 07:34:24 -0700 (PDT) Received: from mail-vc0-f173.google.com (mail-vc0-f173.google.com [209.85.220.173]) by mx.google.com with ESMTPS id bo12si8212662veb.23.2014.06.23.07.34.24 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 23 Jun 2014 07:34:24 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.173 as permitted sender) client-ip=209.85.220.173; Received: by mail-vc0-f173.google.com with SMTP id lf12so6058866vcb.32 for ; Mon, 23 Jun 2014 07:34:24 -0700 (PDT) X-Received: by 10.58.29.164 with SMTP id l4mr19835515veh.8.1403534063974; Mon, 23 Jun 2014 07:34:23 -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 tc5csp135188vcb; Mon, 23 Jun 2014 07:34:23 -0700 (PDT) X-Received: by 10.224.8.9 with SMTP id f9mr6068607qaf.102.1403534063390; Mon, 23 Jun 2014 07:34:23 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id cj2si12753307qcb.5.2014.06.23.07.34.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 23 Jun 2014 07:34:23 -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]:53550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4N3-0003yp-9h for patch@linaro.org; Mon, 23 Jun 2014 09:33:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4Gn-0003iS-IR for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wz4Gd-0001BN-Kp for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:49 -0400 Received: from afflict.kos.to ([92.243.29.197]:50464) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wz4Gd-0001Ae-D9 for qemu-devel@nongnu.org; Mon, 23 Jun 2014 09:26:39 -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 6BC002658A; Mon, 23 Jun 2014 15:26:36 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Mon, 23 Jun 2014 16:26:26 +0300 Message-Id: <11de144bf9437dfe41e0a5672a545a93b0df9db1.1403529800.git.riku.voipio@linaro.org> 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: 92.243.29.197 Cc: Paul Burton Subject: [Qemu-devel] [PULL 11/19] 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.220.173 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;