Re: [Qemu-devel] [PATCH v5 2/8] linux-user: Add support for clock_adjtime() syscall

2016-09-17 Thread Laurent Vivier


Le 14/09/2016 à 22:19, Aleksandar Markovic a écrit :
> 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(_buf, arg2) != 0) {
> +goto efault;
> +}
> +ret = get_errno(clock_adjtime(arg1, _buf));
> +if (!is_error(ret) && arg1) {

Why do you check arg1 here ?

> +if (host_to_target_timex(arg2, _buf) != 0) {
> +goto efault;
> +}
> +}
> +}
> +break;
> +#endif
>  #ifdef TARGET_NR_create_module
>  case TARGET_NR_create_module:
>  #endif
> 

Laurent



[Qemu-devel] [PATCH v5 2/8] linux-user: Add support for clock_adjtime() syscall

2016-09-14 Thread Aleksandar Markovic
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(_buf, arg2) != 0) {
+goto efault;
+}
+ret = get_errno(clock_adjtime(arg1, _buf));
+if (!is_error(ret) && arg1) {
+if (host_to_target_timex(arg2, _buf) != 0) {
+goto efault;
+}
+}
+}
+break;
+#endif
 #ifdef TARGET_NR_create_module
 case TARGET_NR_create_module:
 #endif
-- 
2.9.3