From patchwork Wed Sep 14 20:19:55 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aleksandar Markovic X-Patchwork-Id: 9332453 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 933586077F for ; Wed, 14 Sep 2016 20:21:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 84FA729EF6 for ; Wed, 14 Sep 2016 20:21:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79AF329FD2; Wed, 14 Sep 2016 20:21:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E9AD729EF6 for ; Wed, 14 Sep 2016 20:21:38 +0000 (UTC) Received: from localhost ([::1]:58564 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkGgc-0005Xh-6P for patchwork-qemu-devel@patchwork.kernel.org; Wed, 14 Sep 2016 16:21:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37868) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkGg7-0005WE-CT for qemu-devel@nongnu.org; Wed, 14 Sep 2016 16:21:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bkGg2-0000pB-9t for qemu-devel@nongnu.org; Wed, 14 Sep 2016 16:21:07 -0400 Received: from mx2.rt-rk.com ([89.216.37.149]:43805 helo=mail.rt-rk.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bkGg1-0000oj-TT for qemu-devel@nongnu.org; Wed, 14 Sep 2016 16:21:02 -0400 Received: from localhost (localhost [127.0.0.1]) by mail.rt-rk.com (Postfix) with ESMTP id 2184C1A45E4; Wed, 14 Sep 2016 22:21:01 +0200 (CEST) X-Virus-Scanned: amavisd-new at rt-rk.com Received: from mcs19.domain.local (mcs19.domain.local [10.10.13.51]) by mail.rt-rk.com (Postfix) with ESMTPSA id F0ABE1A211A; Wed, 14 Sep 2016 22:21:00 +0200 (CEST) From: Aleksandar Markovic To: qemu-devel@nongnu.org, riku.voipio@iki.fi, peter.maydell@linaro.org, petar.jovanovic@imgtec.com, miodrag.dinic@imgtec.com, aleksandar.rikalo@imgtec.com, aleksandar.markovic@imgtec.com Date: Wed, 14 Sep 2016 22:19:55 +0200 Message-Id: <20160914202008.14119-3-aleksandar.markovic@rt-rk.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20160914202008.14119-1-aleksandar.markovic@rt-rk.com> References: <20160914202008.14119-1-aleksandar.markovic@rt-rk.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 89.216.37.149 Subject: [Qemu-devel] [PATCH v5 2/8] linux-user: Add support for clock_adjtime() syscall X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Aleksandar Markovic This patch implements Qemu user mode clock_adjtime() syscall support. The implementation is based on invocation of host's clock_adjtime(), and is very similar to the implementation of adjtimex() syscall support. The main difference is the presence of "clockid_t" argument in clock_adjtime(). Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic --- linux-user/strace.c | 13 +++++++++++++ linux-user/strace.list | 3 +++ linux-user/syscall.c | 19 ++++++++++++++++++- 3 files changed, 34 insertions(+), 1 deletion(-) diff --git a/linux-user/strace.c b/linux-user/strace.c index 7ddcaf8..4524c70 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -968,6 +968,19 @@ print_chmod(const struct syscallname *name, } #endif +#ifdef TARGET_NR_clock_adjtime +static void +print_clock_adjtime(const struct syscallname *name, + abi_long arg0, abi_long arg1, abi_long arg2, + abi_long arg3, abi_long arg4, abi_long arg5) +{ + print_syscall_prologue(name); + print_raw_param("%d", arg0, 0); + print_pointer(arg1, 1); + print_syscall_epilogue(name); +} +#endif + #ifdef TARGET_NR_clone static void do_print_clone(unsigned int flags, abi_ulong newsp, abi_ulong parent_tidptr, target_ulong newtls, diff --git a/linux-user/strace.list b/linux-user/strace.list index 9a665a8..00b2e9b 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -72,6 +72,9 @@ #ifdef TARGET_NR_chroot { TARGET_NR_chroot, "chroot" , NULL, NULL, NULL }, #endif +#ifdef TARGET_NR_clock_adjtime +{ TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NULL }, +#endif #ifdef TARGET_NR_clock_getres { TARGET_NR_clock_getres, "clock_getres" , NULL, NULL, NULL }, #endif diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5643840..eab9207 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -6579,7 +6579,7 @@ static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, } #endif -#ifdef TARGET_NR_adjtimex +#if defined(TARGET_NR_adjtimex) || defined(TARGET_NR_clock_adjtime) static inline abi_long target_to_host_timex(struct timex *host_buf, abi_long target_addr) { @@ -9509,6 +9509,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } break; #endif +#ifdef TARGET_NR_clock_adjtime + case TARGET_NR_clock_adjtime: + { + struct timex host_buf; + + if (target_to_host_timex(&host_buf, arg2) != 0) { + goto efault; + } + ret = get_errno(clock_adjtime(arg1, &host_buf)); + if (!is_error(ret) && arg1) { + if (host_to_target_timex(arg2, &host_buf) != 0) { + goto efault; + } + } + } + break; +#endif #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif