From patchwork Tue Oct 18 13:21:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 78046 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp888565qge; Tue, 18 Oct 2016 06:35:03 -0700 (PDT) X-Received: by 10.55.121.131 with SMTP id u125mr641592qkc.114.1476797703242; Tue, 18 Oct 2016 06:35:03 -0700 (PDT) Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id x35si21004347qta.107.2016.10.18.06.35.02 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:35:03 -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; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:41553 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwUXm-0000G4-70 for patch@linaro.org; Tue, 18 Oct 2016 09:35:02 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwULN-0006NL-Jk for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwULL-0000ix-Ov for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:13 -0400 Received: from mail-lf0-x235.google.com ([2a00:1450:4010:c07::235]:36009) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwULL-0000hR-Bx for qemu-devel@nongnu.org; Tue, 18 Oct 2016 09:22:11 -0400 Received: by mail-lf0-x235.google.com with SMTP id b75so346725987lfg.3 for ; Tue, 18 Oct 2016 06:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pf/z8K+8e2M8iaCLF2PszzTOmEcs8aadaFfIF2wNUu4=; b=a/lBMGfXe4GvrZivgn/kjHlqcbCuUlCxu7ltd3o41+xU5rn702My4mQB6rUoRnyM2B uQmhIedkTQTrVNdzRFqfokK8m+6JH9hAzljKbklOX+dL+sVc2PiUdwiKu36IX2aGNaLp EylVCoGBvpSoycFZrbys+mp0FRg2WYGiH5o0U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pf/z8K+8e2M8iaCLF2PszzTOmEcs8aadaFfIF2wNUu4=; b=Sd6QG7kovgXbiOz3M9j3Z4jUEGENxJCv14dE+Cxu/ARvW4n94rXWki3aML3of8BPNi C0GV2YUAsWlDBaOpmgDJmrSDGmRbCc8/weLdN2EPHYHBYs/oS1/yJJ+Ijom0omWg00nZ WkVi7hZF1Bux3oFFRaK0ceE3/qtviyDzv+o5SmSMzsu0Nz8YIVWyMsOHhjWOCS0YK70M JWFaYB+ZYkcxbR9Ds6YVYbj7GETsBHiDyzB1t9dDtCDMvaEB8B727pz5DXkeKEX8lsRF csgZWaRMKlJd7/4VtZp6IQAq6x7wKP2kJfdjHJmxnDV2ErqWDziCTnTqfdGktZaLLBDK eEPA== X-Gm-Message-State: AA6/9RmgPmrJnZxIJSXXWQFi7ORdAr+ZQYg2N36PboSecP6yaUJmyQ3fDYA/VA2uLeP44g4s X-Received: by 10.25.99.4 with SMTP id x4mr559048lfb.128.1476796928799; Tue, 18 Oct 2016 06:22:08 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 201sm9535359ljf.48.2016.10.18.06.22.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 18 Oct 2016 06:22:08 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:21:42 +0300 Message-Id: <2e4b5348fed150d169ca9b0af1d7ba75ba5f5470.1476796525.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::235 Subject: [Qemu-devel] [PULL v2 14/22] 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: , Cc: Peter Maydell , Aleksandar Markovic Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Aleksandar Markovic This patch implements Qemu user mode clock_adjtime() syscall support. The implementation is based on invocation of host's clock_adjtime(). Signed-off-by: Aleksandar Rikalo Signed-off-by: Aleksandar Markovic Signed-off-by: Riku Voipio --- configure | 18 ++++++++++++ linux-user/strace.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++ linux-user/strace.list | 3 ++ linux-user/syscall.c | 18 ++++++++++++ 4 files changed, 115 insertions(+) -- 2.1.4 diff --git a/configure b/configure index dd9e679..1ce3d00 100755 --- a/configure +++ b/configure @@ -3911,6 +3911,21 @@ if compile_prog "" "" ; then setns=yes fi +# clock_adjtime probe +clock_adjtime=no +cat > $TMPC < + +int main(void) +{ + return clock_adjtime(0, 0); +} +EOF +clock_adjtime=no +if compile_prog "" "" ; then + clock_adjtime=yes +fi + # Check if tools are available to build documentation. if test "$docs" != "no" ; then if has makeinfo && has pod2man; then @@ -5196,6 +5211,9 @@ fi if test "$setns" = "yes" ; then echo "CONFIG_SETNS=y" >> $config_host_mak fi +if test "$clock_adjtime" = "yes" ; then + echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak +fi if test "$inotify" = "yes" ; then echo "CONFIG_INOTIFY=y" >> $config_host_mak fi diff --git a/linux-user/strace.c b/linux-user/strace.c index 679f840..489dbc9 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -435,6 +435,69 @@ print_fdset(int n, abi_ulong target_fds_addr) } #endif +#ifdef TARGET_NR_clock_adjtime +/* IDs of the various system clocks */ +#define TARGET_CLOCK_REALTIME 0 +#define TARGET_CLOCK_MONOTONIC 1 +#define TARGET_CLOCK_PROCESS_CPUTIME_ID 2 +#define TARGET_CLOCK_THREAD_CPUTIME_ID 3 +#define TARGET_CLOCK_MONOTONIC_RAW 4 +#define TARGET_CLOCK_REALTIME_COARSE 5 +#define TARGET_CLOCK_MONOTONIC_COARSE 6 +#define TARGET_CLOCK_BOOTTIME 7 +#define TARGET_CLOCK_REALTIME_ALARM 8 +#define TARGET_CLOCK_BOOTTIME_ALARM 9 +#define TARGET_CLOCK_SGI_CYCLE 10 +#define TARGET_CLOCK_TAI 11 + +static void +print_clockid(int clockid, int last) +{ + switch (clockid) { + case TARGET_CLOCK_REALTIME: + gemu_log("CLOCK_REALTIME"); + break; + case TARGET_CLOCK_MONOTONIC: + gemu_log("CLOCK_MONOTONIC"); + break; + case TARGET_CLOCK_PROCESS_CPUTIME_ID: + gemu_log("CLOCK_PROCESS_CPUTIME_ID"); + break; + case TARGET_CLOCK_THREAD_CPUTIME_ID: + gemu_log("CLOCK_THREAD_CPUTIME_ID"); + break; + case TARGET_CLOCK_MONOTONIC_RAW: + gemu_log("CLOCK_MONOTONIC_RAW"); + break; + case TARGET_CLOCK_REALTIME_COARSE: + gemu_log("CLOCK_REALTIME_COARSE"); + break; + case TARGET_CLOCK_MONOTONIC_COARSE: + gemu_log("CLOCK_MONOTONIC_COARSE"); + break; + case TARGET_CLOCK_BOOTTIME: + gemu_log("CLOCK_BOOTTIME"); + break; + case TARGET_CLOCK_REALTIME_ALARM: + gemu_log("CLOCK_REALTIME_ALARM"); + break; + case TARGET_CLOCK_BOOTTIME_ALARM: + gemu_log("CLOCK_BOOTTIME_ALARM"); + break; + case TARGET_CLOCK_SGI_CYCLE: + gemu_log("CLOCK_SGI_CYCLE"); + break; + case TARGET_CLOCK_TAI: + gemu_log("CLOCK_TAI"); + break; + default: + gemu_log("%d", clockid); + break; + } + gemu_log("%s", get_comma(last)); +} +#endif + /* * Sysycall specific output functions */ @@ -1096,6 +1159,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_clockid(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 4bbe0d3..dcd3812 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -79,6 +79,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 fb56fed..28d2b8e 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -49,6 +49,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base, #include #include #include +#include #include #include #include @@ -9700,6 +9701,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } } break; +#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME) + case TARGET_NR_clock_adjtime: + { + struct timex htx, *phtx = &htx; + + if (target_to_host_timex(phtx, arg2) != 0) { + goto efault; + } + ret = get_errno(clock_adjtime(arg1, phtx)); + if (!is_error(ret) && phtx) { + if (host_to_target_timex(arg2, phtx) != 0) { + goto efault; + } + } + } + break; +#endif #ifdef TARGET_NR_create_module case TARGET_NR_create_module: #endif