All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements
@ 2022-09-18 19:45 Helge Deller
  2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
                   ` (12 more replies)
  0 siblings, 13 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Here is a bunch of patches for linux-user.

Most of them add missing syscalls and enhance the tracing/logging.
Some of the patches are target-hppa specific.
I've tested those on productive hppa debian buildd servers (running qemu-user).

Thanks!
Helge

Changes to v2:
- Fix build of close_range() and pidfd_*() patches on older Linux
  distributions (noticed by Stefan Hajnoczi)

Changes to v1:
- Dropped the faccessat2() syscall patch in favour of Richard's patch
- Various changes to the "missing signals in strace output" patch based on
  Richard's feedback, e.g. static arrays, fixed usage of _NSIG, fix build when
  TARGET_SIGIOT does not exist
- Use FUTEX_CMD_MASK in "Show timespec on strace for futex" patch
  unconditionally and turn into a switch statement - as suggested by Richard

Helge Deller (12):
  linux-user: Add missing signals in strace output
  linux-user: Add missing clock_gettime64() syscall strace
  linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd()
    syscalls
  linux-user: Log failing executable in EXCP_DUMP()
  linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
  linux-user/hppa: Dump IIR on register dump
  linux-user: Fix strace of chmod() if mode == 0
  linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch
  linux-user: Add strace for clock_nanosleep()
  linux-user: Show timespec on strace for futex()
  linux-user: Add close_range() syscall
  linux-user: Add parameters of getrandom() syscall for strace

 linux-user/cpu_loop-common.h |   2 +
 linux-user/hppa/cpu_loop.c   |   6 +-
 linux-user/mmap.c            |   4 +
 linux-user/signal-common.h   |  46 ++++++++++++
 linux-user/signal.c          |  37 +--------
 linux-user/strace.c          | 142 ++++++++++++++++++++++++++++++-----
 linux-user/strace.list       |  21 +++++-
 linux-user/syscall.c         |  50 ++++++++++++
 target/hppa/helper.c         |   6 +-
 9 files changed, 255 insertions(+), 59 deletions(-)

--
2.37.3



^ permalink raw reply	[flat|nested] 35+ messages in thread

* [PATCH v3 01/12] linux-user: Add missing signals in strace output
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:00   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace Helge Deller
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Some of the guest signal numbers are currently not converted to
their representative names in the strace output, e.g. SIGVTALRM.

This patch introduces a smart way to generate and keep in sync the
host-to-guest and guest-to-host signal conversion tables for usage in
the qemu signal and strace code. This ensures that any signals
will now show up in both tables.

There is no functional change in this patch - with the exception that yet
missing signal names now show up in the strace code too.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/signal-common.h | 46 ++++++++++++++++++++++++++++++++++++++
 linux-user/signal.c        | 37 +++---------------------------
 linux-user/strace.c        | 30 +++++++++----------------
 3 files changed, 60 insertions(+), 53 deletions(-)

diff --git a/linux-user/signal-common.h b/linux-user/signal-common.h
index 6a7e4a93fc..3e2dc604c2 100644
--- a/linux-user/signal-common.h
+++ b/linux-user/signal-common.h
@@ -118,4 +118,50 @@ static inline void finish_sigsuspend_mask(int ret)
     }
 }

+#if defined(SIGSTKFLT) && defined(TARGET_SIGSTKFLT)
+#define MAKE_SIG_ENTRY_SIGSTKFLT        MAKE_SIG_ENTRY(SIGSTKFLT)
+#else
+#define MAKE_SIG_ENTRY_SIGSTKFLT
+#endif
+
+#if defined(SIGIOT) && defined(TARGET_SIGIOT)
+#define MAKE_SIG_ENTRY_SIGIOT           MAKE_SIG_ENTRY(SIGIOT)
+#else
+#define MAKE_SIG_ENTRY_SIGIOT
+#endif
+
+#define MAKE_SIGNAL_LIST \
+        MAKE_SIG_ENTRY(SIGHUP) \
+        MAKE_SIG_ENTRY(SIGINT) \
+        MAKE_SIG_ENTRY(SIGQUIT) \
+        MAKE_SIG_ENTRY(SIGILL) \
+        MAKE_SIG_ENTRY(SIGTRAP) \
+        MAKE_SIG_ENTRY(SIGABRT) \
+        MAKE_SIG_ENTRY(SIGBUS) \
+        MAKE_SIG_ENTRY(SIGFPE) \
+        MAKE_SIG_ENTRY(SIGKILL) \
+        MAKE_SIG_ENTRY(SIGUSR1) \
+        MAKE_SIG_ENTRY(SIGSEGV) \
+        MAKE_SIG_ENTRY(SIGUSR2) \
+        MAKE_SIG_ENTRY(SIGPIPE) \
+        MAKE_SIG_ENTRY(SIGALRM) \
+        MAKE_SIG_ENTRY(SIGTERM) \
+        MAKE_SIG_ENTRY(SIGCHLD) \
+        MAKE_SIG_ENTRY(SIGCONT) \
+        MAKE_SIG_ENTRY(SIGSTOP) \
+        MAKE_SIG_ENTRY(SIGTSTP) \
+        MAKE_SIG_ENTRY(SIGTTIN) \
+        MAKE_SIG_ENTRY(SIGTTOU) \
+        MAKE_SIG_ENTRY(SIGURG) \
+        MAKE_SIG_ENTRY(SIGXCPU) \
+        MAKE_SIG_ENTRY(SIGXFSZ) \
+        MAKE_SIG_ENTRY(SIGVTALRM) \
+        MAKE_SIG_ENTRY(SIGPROF) \
+        MAKE_SIG_ENTRY(SIGWINCH) \
+        MAKE_SIG_ENTRY(SIGIO) \
+        MAKE_SIG_ENTRY(SIGPWR) \
+        MAKE_SIG_ENTRY(SIGSYS) \
+        MAKE_SIG_ENTRY_SIGSTKFLT \
+        MAKE_SIG_ENTRY_SIGIOT
+
 #endif
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 8d29bfaa6b..61c6fa3fcf 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -53,40 +53,9 @@ abi_ulong default_rt_sigreturn;
 QEMU_BUILD_BUG_ON(__SIGRTMAX + 1 != _NSIG);
 #endif
 static uint8_t host_to_target_signal_table[_NSIG] = {
-    [SIGHUP] = TARGET_SIGHUP,
-    [SIGINT] = TARGET_SIGINT,
-    [SIGQUIT] = TARGET_SIGQUIT,
-    [SIGILL] = TARGET_SIGILL,
-    [SIGTRAP] = TARGET_SIGTRAP,
-    [SIGABRT] = TARGET_SIGABRT,
-/*    [SIGIOT] = TARGET_SIGIOT,*/
-    [SIGBUS] = TARGET_SIGBUS,
-    [SIGFPE] = TARGET_SIGFPE,
-    [SIGKILL] = TARGET_SIGKILL,
-    [SIGUSR1] = TARGET_SIGUSR1,
-    [SIGSEGV] = TARGET_SIGSEGV,
-    [SIGUSR2] = TARGET_SIGUSR2,
-    [SIGPIPE] = TARGET_SIGPIPE,
-    [SIGALRM] = TARGET_SIGALRM,
-    [SIGTERM] = TARGET_SIGTERM,
-#ifdef SIGSTKFLT
-    [SIGSTKFLT] = TARGET_SIGSTKFLT,
-#endif
-    [SIGCHLD] = TARGET_SIGCHLD,
-    [SIGCONT] = TARGET_SIGCONT,
-    [SIGSTOP] = TARGET_SIGSTOP,
-    [SIGTSTP] = TARGET_SIGTSTP,
-    [SIGTTIN] = TARGET_SIGTTIN,
-    [SIGTTOU] = TARGET_SIGTTOU,
-    [SIGURG] = TARGET_SIGURG,
-    [SIGXCPU] = TARGET_SIGXCPU,
-    [SIGXFSZ] = TARGET_SIGXFSZ,
-    [SIGVTALRM] = TARGET_SIGVTALRM,
-    [SIGPROF] = TARGET_SIGPROF,
-    [SIGWINCH] = TARGET_SIGWINCH,
-    [SIGIO] = TARGET_SIGIO,
-    [SIGPWR] = TARGET_SIGPWR,
-    [SIGSYS] = TARGET_SIGSYS,
+#define MAKE_SIG_ENTRY(sig)     [sig] = TARGET_##sig,
+        MAKE_SIGNAL_LIST
+#undef MAKE_SIG_ENTRY
     /* next signals stay the same */
 };

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 7d882526da..a4eeef7ae1 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -17,6 +17,7 @@
 #include "qemu.h"
 #include "user-internals.h"
 #include "strace.h"
+#include "signal-common.h"

 struct syscallname {
     int nr;
@@ -141,30 +142,21 @@ if( cmd == val ) { \
     qemu_log("%d", cmd);
 }

+static const char * const target_signal_name[] = {
+#define MAKE_SIG_ENTRY(sig)     [TARGET_##sig] = #sig,
+        MAKE_SIGNAL_LIST
+#undef MAKE_SIG_ENTRY
+};
+
 static void
 print_signal(abi_ulong arg, int last)
 {
     const char *signal_name = NULL;
-    switch(arg) {
-    case TARGET_SIGHUP: signal_name = "SIGHUP"; break;
-    case TARGET_SIGINT: signal_name = "SIGINT"; break;
-    case TARGET_SIGQUIT: signal_name = "SIGQUIT"; break;
-    case TARGET_SIGILL: signal_name = "SIGILL"; break;
-    case TARGET_SIGABRT: signal_name = "SIGABRT"; break;
-    case TARGET_SIGFPE: signal_name = "SIGFPE"; break;
-    case TARGET_SIGKILL: signal_name = "SIGKILL"; break;
-    case TARGET_SIGSEGV: signal_name = "SIGSEGV"; break;
-    case TARGET_SIGPIPE: signal_name = "SIGPIPE"; break;
-    case TARGET_SIGALRM: signal_name = "SIGALRM"; break;
-    case TARGET_SIGTERM: signal_name = "SIGTERM"; break;
-    case TARGET_SIGUSR1: signal_name = "SIGUSR1"; break;
-    case TARGET_SIGUSR2: signal_name = "SIGUSR2"; break;
-    case TARGET_SIGCHLD: signal_name = "SIGCHLD"; break;
-    case TARGET_SIGCONT: signal_name = "SIGCONT"; break;
-    case TARGET_SIGSTOP: signal_name = "SIGSTOP"; break;
-    case TARGET_SIGTTIN: signal_name = "SIGTTIN"; break;
-    case TARGET_SIGTTOU: signal_name = "SIGTTOU"; break;
+
+    if (arg < ARRAY_SIZE(target_signal_name)) {
+        signal_name = target_signal_name[arg];
     }
+
     if (signal_name == NULL) {
         print_raw_param("%ld", arg, last);
         return;
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
  2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:09   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Helge Deller
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Allow linux-user to strace the clock_gettime64() syscall.
This syscall is used a lot on 32-bit guest architectures which use newer
glibc versions.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
 linux-user/strace.list |  4 ++++
 2 files changed, 57 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index a4eeef7ae1..816e679995 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
 UNUSED static void print_raw_param(const char *, abi_long, int);
 UNUSED static void print_timeval(abi_ulong, int);
 UNUSED static void print_timespec(abi_ulong, int);
+UNUSED static void print_timespec64(abi_ulong, int);
 UNUSED static void print_timezone(abi_ulong, int);
 UNUSED static void print_itimerval(abi_ulong, int);
 UNUSED static void print_number(abi_long, int);
@@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
 #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
 #endif

+#if defined(TARGET_NR_clock_gettime64)
+static void
+print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
+                                abi_long ret, abi_long arg0, abi_long arg1,
+                                abi_long arg2, abi_long arg3, abi_long arg4,
+                                abi_long arg5)
+{
+    if (!print_syscall_err(ret)) {
+        qemu_log(TARGET_ABI_FMT_ld, ret);
+        qemu_log(" (");
+        print_timespec64(arg1, 1);
+        qemu_log(")");
+    }
+
+    qemu_log("\n");
+}
+#endif
+
 #ifdef TARGET_NR_gettimeofday
 static void
 print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
@@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
     }
 }

+static void
+print_timespec64(abi_ulong ts_addr, int last)
+{
+    if (ts_addr) {
+        struct target__kernel_timespec *ts;
+
+        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
+        if (!ts) {
+            print_pointer(ts_addr, last);
+            return;
+        }
+        qemu_log("{tv_sec = %lld"
+                 ",tv_nsec = %lld}%s",
+                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
+                 get_comma(last));
+        unlock_user(ts, ts_addr, 0);
+    } else {
+        qemu_log("NULL%s", get_comma(last));
+    }
+}
+
 static void
 print_timezone(abi_ulong tz_addr, int last)
 {
@@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
 #define print_clock_getres     print_clock_gettime
 #endif

+#if defined(TARGET_NR_clock_gettime64)
+static void
+print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
+    print_pointer(arg1, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_clock_settime
 static void
 print_clock_settime(CPUArchState *cpu_env, const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 72e17b1acf..a78cdf3cdf 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1676,3 +1676,7 @@
 #ifdef TARGET_NR_copy_file_range
 { TARGET_NR_copy_file_range, "copy_file_range", "%s(%d,%p,%d,%p,"TARGET_ABI_FMT_lu",%u)", NULL, NULL },
 #endif
+#ifdef TARGET_NR_clock_gettime64
+{ TARGET_NR_clock_gettime64, "clock_gettime64" , NULL, print_clock_gettime64,
+                           print_syscall_ret_clock_gettime64 },
+#endif
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
  2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
  2022-09-18 19:45 ` [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:25   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
                   ` (9 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

I noticed those were missing when running the glib2.0 testsuite.
Add the syscalls including the strace output.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c    | 28 ++++++++++++++++++++++++++++
 linux-user/strace.list |  9 +++++++++
 linux-user/syscall.c   | 34 ++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 816e679995..5ac64df02b 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3317,6 +3317,34 @@ print_openat(CPUArchState *cpu_env, const struct syscallname *name,
 }
 #endif

+#ifdef TARGET_NR_pidfd_send_signal
+static void
+print_pidfd_send_signal(CPUArchState *cpu_env, const struct syscallname *name,
+                abi_long arg0, abi_long arg1, abi_long arg2,
+                abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    void *p;
+    target_siginfo_t uinfo;
+
+    print_syscall_prologue(name);
+    print_raw_param("%d", arg0, 0);
+    print_signal(arg1, 0);
+
+    p = lock_user(VERIFY_READ, arg2, sizeof(target_siginfo_t), 1);
+    if (p) {
+        get_target_siginfo(&uinfo, p);
+        print_siginfo(&uinfo);
+
+        unlock_user(p, arg2, 0);
+    } else {
+        print_pointer(arg2, 1);
+    }
+
+    print_raw_param("%u", arg3, 0);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_mq_unlink
 static void
 print_mq_unlink(CPUArchState *cpu_env, const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index a78cdf3cdf..4d8b7f6a5e 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1664,6 +1664,15 @@
 #ifdef TARGET_NR_pipe2
 { TARGET_NR_pipe2, "pipe2", NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_pidfd_open
+{ TARGET_NR_pidfd_open, "pidfd_open", "%s(%d,%u)", NULL, NULL },
+#endif
+#ifdef TARGET_NR_pidfd_send_signal
+{ TARGET_NR_pidfd_send_signal, "pidfd_send_signal", NULL, print_pidfd_send_signal, NULL },
+#endif
+#ifdef TARGET_NR_pidfd_getfd
+{ TARGET_NR_pidfd_getfd, "pidfd_getfd", "%s(%d,%d,%u)", NULL, NULL },
+#endif
 #ifdef TARGET_NR_atomic_cmpxchg_32
 { TARGET_NR_atomic_cmpxchg_32, "atomic_cmpxchg_32", NULL, NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index f409121202..ca39acfceb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -346,6 +346,16 @@ _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
 _syscall6(int,sys_futex_time64,int *,uaddr,int,op,int,val,
           const struct timespec *,timeout,int *,uaddr2,int,val3)
 #endif
+#if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open)
+_syscall2(int, pidfd_open, pid_t, pid, unsigned int, flags);
+#endif
+#if defined(__NR_pidfd_send_signal) && defined(TARGET_NR_pidfd_send_signal)
+_syscall4(int, pidfd_send_signal, int, pidfd, int, sig, siginfo_t *, info,
+                             unsigned int, flags);
+#endif
+#if defined(__NR_pidfd_getfd) && defined(TARGET_NR_pidfd_getfd)
+_syscall3(int, pidfd_getfd, int, pidfd, int, targetfd, unsigned int, flags);
+#endif
 #define __NR_sys_sched_getaffinity __NR_sched_getaffinity
 _syscall3(int, sys_sched_getaffinity, pid_t, pid, unsigned int, len,
           unsigned long *, user_mask_ptr);
@@ -8683,6 +8693,30 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
         ret = do_open_by_handle_at(arg1, arg2, arg3);
         fd_trans_unregister(ret);
         return ret;
+#endif
+#if defined(__NR_pidfd_open) && defined(TARGET_NR_pidfd_open)
+    case TARGET_NR_pidfd_open:
+        return get_errno(pidfd_open(arg1, arg2));
+#endif
+#if defined(__NR_pidfd_send_signal) && defined(TARGET_NR_pidfd_send_signal)
+    case TARGET_NR_pidfd_send_signal:
+        {
+            siginfo_t uinfo;
+
+            p = lock_user(VERIFY_READ, arg3, sizeof(target_siginfo_t), 1);
+            if (!p) {
+                return -TARGET_EFAULT;
+            }
+            target_to_host_siginfo(&uinfo, p);
+            unlock_user(p, arg3, 0);
+            ret = get_errno(pidfd_send_signal(arg1, target_to_host_signal(arg2),
+                &uinfo, arg4));
+        }
+        return ret;
+#endif
+#if defined(__NR_pidfd_getfd) && defined(TARGET_NR_pidfd_getfd)
+    case TARGET_NR_pidfd_getfd:
+        return get_errno(pidfd_getfd(arg1, arg2, arg3));
 #endif
     case TARGET_NR_close:
         fd_trans_unregister(arg1);
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP()
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (2 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-18 20:37   ` Philippe Mathieu-Daudé via
  2022-09-25 15:26   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Helge Deller
                   ` (8 subsequent siblings)
  12 siblings, 2 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Enhance the EXCP_DUMP() macro to print out the failing program too.
During debugging it's sometimes hard to track down the actual failing
program if you are e.g. building a whole debian package.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/cpu_loop-common.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/cpu_loop-common.h b/linux-user/cpu_loop-common.h
index dc0042e4de..36ff5b14f2 100644
--- a/linux-user/cpu_loop-common.h
+++ b/linux-user/cpu_loop-common.h
@@ -27,9 +27,11 @@
 do {                                                                    \
     CPUState *cs = env_cpu(env);                                        \
     fprintf(stderr, fmt , ## __VA_ARGS__);                              \
+    fprintf(stderr, "Failing executable: %s\n", exec_path);             \
     cpu_dump_state(cs, stderr, 0);                                      \
     if (qemu_log_separate()) {                                          \
         qemu_log(fmt, ## __VA_ARGS__);                                  \
+        qemu_log("Failing executable: %s\n", exec_path);                \
         log_cpu_state(cs, 0);                                           \
     }                                                                   \
 } while (0)
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (3 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:26   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
                   ` (7 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Enhance the hppa linux-user cpu_loop() to show more debugging info
on hard errors.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/hppa/cpu_loop.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/linux-user/hppa/cpu_loop.c b/linux-user/hppa/cpu_loop.c
index 64263c3dc4..1ef3b46191 100644
--- a/linux-user/hppa/cpu_loop.c
+++ b/linux-user/hppa/cpu_loop.c
@@ -147,12 +147,15 @@ void cpu_loop(CPUHPPAState *env)
             force_sig_fault(TARGET_SIGSEGV, TARGET_SEGV_MAPERR, env->iaoq_f);
             break;
         case EXCP_ILL:
+            EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
             force_sig_fault(TARGET_SIGILL, TARGET_ILL_ILLOPN, env->iaoq_f);
             break;
         case EXCP_PRIV_OPR:
+            EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
             force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVOPC, env->iaoq_f);
             break;
         case EXCP_PRIV_REG:
+            EXCP_DUMP(env, "qemu: got CPU exception 0x%x - aborting\n", trapnr);
             force_sig_fault(TARGET_SIGILL, TARGET_ILL_PRVREG, env->iaoq_f);
             break;
         case EXCP_OVERFLOW:
@@ -171,7 +174,8 @@ void cpu_loop(CPUHPPAState *env)
             /* just indicate that signals should be handled asap */
             break;
         default:
-            g_assert_not_reached();
+            EXCP_DUMP(env, "qemu: unhandled CPU exception 0x%x - aborting\n", trapnr);
+            abort();
         }
         process_pending_signals(env);
     }
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (4 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-18 20:38   ` Philippe Mathieu-Daudé via
  2022-09-25 15:27   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
                   ` (6 subsequent siblings)
  12 siblings, 2 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Include the IIR register (which holds the opcode of the failing
instruction) when dumping the hppa registers.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/helper.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/target/hppa/helper.c b/target/hppa/helper.c
index e2758d8df3..74b8747083 100644
--- a/target/hppa/helper.c
+++ b/target/hppa/helper.c
@@ -85,9 +85,11 @@ void hppa_cpu_dump_state(CPUState *cs, FILE *f, int flags)
     char psw_c[20];
     int i;

-    qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx "\n",
+    qemu_fprintf(f, "IA_F " TARGET_FMT_lx " IA_B " TARGET_FMT_lx
+                 " IIR " TREG_FMT_lx  "\n",
                  hppa_form_gva_psw(psw, env->iasq_f, env->iaoq_f),
-                 hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b));
+                 hppa_form_gva_psw(psw, env->iasq_b, env->iaoq_b),
+                 env->cr[CR_IIR]);

     psw_c[0]  = (psw & PSW_W ? 'W' : '-');
     psw_c[1]  = (psw & PSW_E ? 'E' : '-');
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (5 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-18 20:46   ` Philippe Mathieu-Daudé via
  2022-09-25 15:29   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 08/12] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch Helge Deller
                   ` (5 subsequent siblings)
  12 siblings, 2 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

If the mode parameter of chmod() is zero, this value isn't shown
when stracing a program:
    chmod("filename",)
This patch fixes it up to show the zero-value as well:
    chmod("filename",000)

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 5ac64df02b..2f539845bb 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
     const char *sep = "";
     const struct flags *m;

+    if (mode == 0) {
+        qemu_log("000%s", get_comma(last));
+        return;
+    }
+
     for (m = &mode_flags[0]; m->f_string != NULL; m++) {
         if ((m->f_value & mode) == m->f_value) {
             qemu_log("%s%s", m->f_string, sep);
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 08/12] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (6 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-18 19:45 ` [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep() Helge Deller
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

On the parisc architecture the stack grows upwards.
Move the TASK_UNMAPPED_BASE to high memory area as it's done by the
kernel on physical machines.

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/mmap.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/linux-user/mmap.c b/linux-user/mmap.c
index 048c4135af..dba6823668 100644
--- a/linux-user/mmap.c
+++ b/linux-user/mmap.c
@@ -251,8 +251,12 @@ static int mmap_frag(abi_ulong real_start,
 # define TASK_UNMAPPED_BASE  (1ul << 38)
 #endif
 #else
+#ifdef TARGET_HPPA
+# define TASK_UNMAPPED_BASE  0xfa000000
+#else
 # define TASK_UNMAPPED_BASE  0x40000000
 #endif
+#endif
 abi_ulong mmap_next_start = TASK_UNMAPPED_BASE;

 unsigned long last_brk;
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep()
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (7 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 08/12] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:36   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 10/12] linux-user: Show timespec on strace for futex() Helge Deller
                   ` (3 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c    | 15 +++++++++++++++
 linux-user/strace.list |  3 ++-
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 2f539845bb..6f818212d5 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3567,6 +3567,21 @@ print_unshare(CPUArchState *cpu_env, const struct syscallname *name,
 }
 #endif

+#ifdef TARGET_NR_clock_nanosleep
+static void
+print_clock_nanosleep(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
+    print_raw_param("%d", arg1, 0);
+    print_timespec(arg2, 0);
+    print_timespec(arg3, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 #ifdef TARGET_NR_utime
 static void
 print_utime(CPUArchState *cpu_env, const struct syscallname *name,
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 4d8b7f6a5e..215d971b2a 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -91,7 +91,8 @@
                            print_syscall_ret_clock_gettime },
 #endif
 #ifdef TARGET_NR_clock_nanosleep
-{ TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, NULL, NULL },
+{ TARGET_NR_clock_nanosleep, "clock_nanosleep" , NULL, print_clock_nanosleep,
+                            NULL },
 #endif
 #ifdef TARGET_NR_clock_settime
 { TARGET_NR_clock_settime, "clock_settime" , NULL, print_clock_settime, NULL },
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 10/12] linux-user: Show timespec on strace for futex()
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (8 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep() Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:38   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 11/12] linux-user: Add close_range() syscall Helge Deller
                   ` (2 subsequent siblings)
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index 6f818212d5..b6b9abaea4 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -3714,11 +3714,20 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name,
             abi_long arg0, abi_long arg1, abi_long arg2,
             abi_long arg3, abi_long arg4, abi_long arg5)
 {
+    abi_long op = arg1 & FUTEX_CMD_MASK;
     print_syscall_prologue(name);
     print_pointer(arg0, 0);
     print_futex_op(arg1, 0);
     print_raw_param(",%d", arg2, 0);
-    print_pointer(arg3, 0); /* struct timespec */
+    switch (op) {
+        case FUTEX_WAIT:
+        case FUTEX_WAIT_BITSET:
+            print_timespec(arg3, 0);
+            break;
+        default:
+            print_pointer(arg3, 0);
+            break;
+    }
     print_pointer(arg4, 0);
     print_raw_param("%d", arg4, 1);
     print_syscall_epilogue(name);
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 11/12] linux-user: Add close_range() syscall
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (9 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 10/12] linux-user: Show timespec on strace for futex() Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-25 15:42   ` Laurent Vivier
  2022-09-18 19:45 ` [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
  2022-09-27  7:32 ` [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Laurent Vivier
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.list |  3 +++
 linux-user/syscall.c   | 16 ++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 215d971b2a..ad9ef94689 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -103,6 +103,9 @@
 #ifdef TARGET_NR_close
 { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
 #endif
+#ifdef TARGET_NR_close_range
+{ TARGET_NR_close_range, "close_range" , "%s(%d,%d,%d)", NULL, NULL },
+#endif
 #ifdef TARGET_NR_connect
 { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ca39acfceb..2e0e974562 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -338,6 +338,10 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
 #ifdef __NR_exit_group
 _syscall1(int,exit_group,int,error_code)
 #endif
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+#define __NR_sys_close_range __NR_close_range
+_syscall3(int,sys_close_range,int,first,int,last,int,flags)
+#endif
 #if defined(__NR_futex)
 _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
           const struct timespec *,timeout,int *,uaddr2,int,val3)
@@ -8721,6 +8725,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
     case TARGET_NR_close:
         fd_trans_unregister(arg1);
         return get_errno(close(arg1));
+#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
+    case TARGET_NR_close_range:
+        {
+            abi_long fd;
+            abi_long maxfd = (arg2 == (abi_long)-1) ? target_fd_max : arg2;
+
+            for (fd = arg1; fd <= maxfd; fd++) {
+                fd_trans_unregister(fd);
+            }
+        }
+        return get_errno(sys_close_range(arg1, arg2, arg3));
+#endif

     case TARGET_NR_brk:
         return do_brk(arg1);
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (10 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 11/12] linux-user: Add close_range() syscall Helge Deller
@ 2022-09-18 19:45 ` Helge Deller
  2022-09-18 20:49   ` Philippe Mathieu-Daudé via
  2022-09-27  7:32 ` [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Laurent Vivier
  12 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-18 19:45 UTC (permalink / raw)
  To: Stefan Hajnoczi, Richard Henderson, Laurent Vivier, qemu-devel; +Cc: deller

Signed-off-by: Helge Deller <deller@gmx.de>
---
 linux-user/strace.list | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index ad9ef94689..97d8ccadac 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -355,7 +355,7 @@
 { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_getrandom
-{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL },
+{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_getresgid
 { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },
--
2.37.3



^ permalink raw reply related	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP()
  2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
@ 2022-09-18 20:37   ` Philippe Mathieu-Daudé via
  2022-09-25 15:26   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-09-18 20:37 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, Laurent Vivier,
	qemu-devel

On 18/9/22 21:45, Helge Deller wrote:
> Enhance the EXCP_DUMP() macro to print out the failing program too.
> During debugging it's sometimes hard to track down the actual failing
> program if you are e.g. building a whole debian package.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/cpu_loop-common.h | 2 ++
>   1 file changed, 2 insertions(+)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump
  2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
@ 2022-09-18 20:38   ` Philippe Mathieu-Daudé via
  2022-09-25 15:27   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-09-18 20:38 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, Laurent Vivier,
	qemu-devel

On 18/9/22 21:45, Helge Deller wrote:
> Include the IIR register (which holds the opcode of the failing
> instruction) when dumping the hppa registers.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   target/hppa/helper.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)

Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
  2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
@ 2022-09-18 20:46   ` Philippe Mathieu-Daudé via
  2022-09-25 15:29   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-09-18 20:46 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, Laurent Vivier,
	qemu-devel

On 18/9/22 21:45, Helge Deller wrote:
> If the mode parameter of chmod() is zero, this value isn't shown
> when stracing a program:
>      chmod("filename",)
> This patch fixes it up to show the zero-value as well:
>      chmod("filename",000)
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 5ac64df02b..2f539845bb 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
>       const char *sep = "";
>       const struct flags *m;
> 
> +    if (mode == 0) {
> +        qemu_log("000%s", get_comma(last));

I'd use either 0 or 0000, not 000...

Preferably using a single 0:
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>


> +        return;
> +    }
> +
>       for (m = &mode_flags[0]; m->f_string != NULL; m++) {
>           if ((m->f_value & mode) == m->f_value) {
>               qemu_log("%s%s", m->f_string, sep);
> --
> 2.37.3
> 
> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace
  2022-09-18 19:45 ` [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
@ 2022-09-18 20:49   ` Philippe Mathieu-Daudé via
  0 siblings, 0 replies; 35+ messages in thread
From: Philippe Mathieu-Daudé via @ 2022-09-18 20:49 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, Laurent Vivier,
	qemu-devel

On 18/9/22 21:45, Helge Deller wrote:
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index ad9ef94689..97d8ccadac 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -355,7 +355,7 @@
>   { TARGET_NR_getpriority, "getpriority", "%s(%#x,%#x)", NULL, NULL },
>   #endif
>   #ifdef TARGET_NR_getrandom
> -{ TARGET_NR_getrandom, "getrandom", NULL, NULL, NULL },
> +{ TARGET_NR_getrandom, "getrandom", "%s(%p,%u,%d)", NULL, NULL },

The last argument is unsigned.

Conditional to using "%s(%p,%u,%u)":
Reviewed-by: Philippe Mathieu-Daudé <f4bug@amsat.org>

>   #endif
>   #ifdef TARGET_NR_getresgid
>   { TARGET_NR_getresgid, "getresgid" , NULL, NULL, NULL },
> --
> 2.37.3
> 
> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 01/12] linux-user: Add missing signals in strace output
  2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
@ 2022-09-25 15:00   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:00 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Some of the guest signal numbers are currently not converted to
> their representative names in the strace output, e.g. SIGVTALRM.
> 
> This patch introduces a smart way to generate and keep in sync the
> host-to-guest and guest-to-host signal conversion tables for usage in
> the qemu signal and strace code. This ensures that any signals
> will now show up in both tables.
> 
> There is no functional change in this patch - with the exception that yet
> missing signal names now show up in the strace code too.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/signal-common.h | 46 ++++++++++++++++++++++++++++++++++++++
>   linux-user/signal.c        | 37 +++---------------------------
>   linux-user/strace.c        | 30 +++++++++----------------
>   3 files changed, 60 insertions(+), 53 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-18 19:45 ` [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace Helge Deller
@ 2022-09-25 15:09   ` Laurent Vivier
  2022-09-25 15:27     ` Helge Deller
  0 siblings, 1 reply; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:09 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Allow linux-user to strace the clock_gettime64() syscall.
> This syscall is used a lot on 32-bit guest architectures which use newer
> glibc versions.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>   linux-user/strace.list |  4 ++++
>   2 files changed, 57 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index a4eeef7ae1..816e679995 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>   UNUSED static void print_raw_param(const char *, abi_long, int);
>   UNUSED static void print_timeval(abi_ulong, int);
>   UNUSED static void print_timespec(abi_ulong, int);
> +UNUSED static void print_timespec64(abi_ulong, int);
>   UNUSED static void print_timezone(abi_ulong, int);
>   UNUSED static void print_itimerval(abi_ulong, int);
>   UNUSED static void print_number(abi_long, int);
> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>   #endif
> 
> +#if defined(TARGET_NR_clock_gettime64)
> +static void
> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
> +                                abi_long ret, abi_long arg0, abi_long arg1,
> +                                abi_long arg2, abi_long arg3, abi_long arg4,
> +                                abi_long arg5)
> +{
> +    if (!print_syscall_err(ret)) {
> +        qemu_log(TARGET_ABI_FMT_ld, ret);
> +        qemu_log(" (");
> +        print_timespec64(arg1, 1);
> +        qemu_log(")");
> +    }
> +
> +    qemu_log("\n");
> +}
> +#endif
> +
>   #ifdef TARGET_NR_gettimeofday
>   static void
>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>       }
>   }
> 
> +static void
> +print_timespec64(abi_ulong ts_addr, int last)
> +{
> +    if (ts_addr) {
> +        struct target__kernel_timespec *ts;
> +
> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
> +        if (!ts) {
> +            print_pointer(ts_addr, last);
> +            return;
> +        }
> +        qemu_log("{tv_sec = %lld"
> +                 ",tv_nsec = %lld}%s",
> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
> +                 get_comma(last));
> +        unlock_user(ts, ts_addr, 0);
> +    } else {
> +        qemu_log("NULL%s", get_comma(last));
> +    }
> +}
> +
>   static void
>   print_timezone(abi_ulong tz_addr, int last)
>   {
> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>   #define print_clock_getres     print_clock_gettime
>   #endif
> 
> +#if defined(TARGET_NR_clock_gettime64)
> +static void
> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
> +    print_pointer(arg1, 1);
> +    print_syscall_epilogue(name);
> +}
> +#endif

I think it could be simply:

#define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.

except that:

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls
  2022-09-18 19:45 ` [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Helge Deller
@ 2022-09-25 15:25   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:25 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> I noticed those were missing when running the glib2.0 testsuite.
> Add the syscalls including the strace output.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c    | 28 ++++++++++++++++++++++++++++
>   linux-user/strace.list |  9 +++++++++
>   linux-user/syscall.c   | 34 ++++++++++++++++++++++++++++++++++
>   3 files changed, 71 insertions(+)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP()
  2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
  2022-09-18 20:37   ` Philippe Mathieu-Daudé via
@ 2022-09-25 15:26   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:26 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Enhance the EXCP_DUMP() macro to print out the failing program too.
> During debugging it's sometimes hard to track down the actual failing
> program if you are e.g. building a whole debian package.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/cpu_loop-common.h | 2 ++
>   1 file changed, 2 insertions(+)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
  2022-09-18 19:45 ` [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Helge Deller
@ 2022-09-25 15:26   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:26 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Enhance the hppa linux-user cpu_loop() to show more debugging info
> on hard errors.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/hppa/cpu_loop.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
>

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-25 15:09   ` Laurent Vivier
@ 2022-09-25 15:27     ` Helge Deller
  2022-09-25 15:47       ` Laurent Vivier
  0 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-25 15:27 UTC (permalink / raw)
  To: Laurent Vivier, Stefan Hajnoczi, Richard Henderson, qemu-devel

On 9/25/22 17:09, Laurent Vivier wrote:
> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>> Allow linux-user to strace the clock_gettime64() syscall.
>> This syscall is used a lot on 32-bit guest architectures which use newer
>> glibc versions.
>>
>> Signed-off-by: Helge Deller <deller@gmx.de>
>> ---
>>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>>   linux-user/strace.list |  4 ++++
>>   2 files changed, 57 insertions(+)
>>
>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>> index a4eeef7ae1..816e679995 100644
>> --- a/linux-user/strace.c
>> +++ b/linux-user/strace.c
>> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>>   UNUSED static void print_raw_param(const char *, abi_long, int);
>>   UNUSED static void print_timeval(abi_ulong, int);
>>   UNUSED static void print_timespec(abi_ulong, int);
>> +UNUSED static void print_timespec64(abi_ulong, int);
>>   UNUSED static void print_timezone(abi_ulong, int);
>>   UNUSED static void print_itimerval(abi_ulong, int);
>>   UNUSED static void print_number(abi_long, int);
>> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
>>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>>   #endif
>>
>> +#if defined(TARGET_NR_clock_gettime64)
>> +static void
>> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
>> +                                abi_long ret, abi_long arg0, abi_long arg1,
>> +                                abi_long arg2, abi_long arg3, abi_long arg4,
>> +                                abi_long arg5)
>> +{
>> +    if (!print_syscall_err(ret)) {
>> +        qemu_log(TARGET_ABI_FMT_ld, ret);
>> +        qemu_log(" (");
>> +        print_timespec64(arg1, 1);
>> +        qemu_log(")");
>> +    }
>> +
>> +    qemu_log("\n");
>> +}
>> +#endif
>> +
>>   #ifdef TARGET_NR_gettimeofday
>>   static void
>>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
>> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>>       }
>>   }
>>
>> +static void
>> +print_timespec64(abi_ulong ts_addr, int last)
>> +{
>> +    if (ts_addr) {
>> +        struct target__kernel_timespec *ts;
>> +
>> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
>> +        if (!ts) {
>> +            print_pointer(ts_addr, last);
>> +            return;
>> +        }
>> +        qemu_log("{tv_sec = %lld"
>> +                 ",tv_nsec = %lld}%s",
>> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
>> +                 get_comma(last));
>> +        unlock_user(ts, ts_addr, 0);
>> +    } else {
>> +        qemu_log("NULL%s", get_comma(last));
>> +    }
>> +}
>> +
>>   static void
>>   print_timezone(abi_ulong tz_addr, int last)
>>   {
>> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>>   #define print_clock_getres     print_clock_gettime
>>   #endif
>>
>> +#if defined(TARGET_NR_clock_gettime64)
>> +static void
>> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
>> +    print_pointer(arg1, 1);
>> +    print_syscall_epilogue(name);
>> +}
>> +#endif
>
> I think it could be simply:
>
> #define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.

Unfortunately not, because one uses print_timespec() while the other uses print_timespec64().

> except that:
>
> Reviewed-by: Laurent Vivier <laurent@vivier.eu>

Thanks!
Helge


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump
  2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
  2022-09-18 20:38   ` Philippe Mathieu-Daudé via
@ 2022-09-25 15:27   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:27 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Include the IIR register (which holds the opcode of the failing
> instruction) when dumping the hppa registers.
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   target/hppa/helper.c | 6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>




^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0
  2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
  2022-09-18 20:46   ` Philippe Mathieu-Daudé via
@ 2022-09-25 15:29   ` Laurent Vivier
  1 sibling, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:29 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> If the mode parameter of chmod() is zero, this value isn't shown
> when stracing a program:
>      chmod("filename",)
> This patch fixes it up to show the zero-value as well:
>      chmod("filename",000)
> 
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c | 5 +++++
>   1 file changed, 5 insertions(+)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 5ac64df02b..2f539845bb 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -1505,6 +1505,11 @@ print_file_mode(abi_long mode, int last)
>       const char *sep = "";
>       const struct flags *m;
> 
> +    if (mode == 0) {
> +        qemu_log("000%s", get_comma(last));
> +        return;
> +    }
> +
>       for (m = &mode_flags[0]; m->f_string != NULL; m++) {
>           if ((m->f_value & mode) == m->f_value) {
>               qemu_log("%s%s", m->f_string, sep);
> --
> 2.37.3
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>
> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep()
  2022-09-18 19:45 ` [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep() Helge Deller
@ 2022-09-25 15:36   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:36 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c    | 15 +++++++++++++++
>   linux-user/strace.list |  3 ++-
>   2 files changed, 17 insertions(+), 1 deletion(-)
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 10/12] linux-user: Show timespec on strace for futex()
  2022-09-18 19:45 ` [PATCH v3 10/12] linux-user: Show timespec on strace for futex() Helge Deller
@ 2022-09-25 15:38   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:38 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.c | 11 ++++++++++-
>   1 file changed, 10 insertions(+), 1 deletion(-)
> 
> diff --git a/linux-user/strace.c b/linux-user/strace.c
> index 6f818212d5..b6b9abaea4 100644
> --- a/linux-user/strace.c
> +++ b/linux-user/strace.c
> @@ -3714,11 +3714,20 @@ print_futex(CPUArchState *cpu_env, const struct syscallname *name,
>               abi_long arg0, abi_long arg1, abi_long arg2,
>               abi_long arg3, abi_long arg4, abi_long arg5)
>   {
> +    abi_long op = arg1 & FUTEX_CMD_MASK;
>       print_syscall_prologue(name);
>       print_pointer(arg0, 0);
>       print_futex_op(arg1, 0);
>       print_raw_param(",%d", arg2, 0);
> -    print_pointer(arg3, 0); /* struct timespec */
> +    switch (op) {
> +        case FUTEX_WAIT:
> +        case FUTEX_WAIT_BITSET:
> +            print_timespec(arg3, 0);
> +            break;
> +        default:
> +            print_pointer(arg3, 0);
> +            break;
> +    }
>       print_pointer(arg4, 0);
>       print_raw_param("%d", arg4, 1);
>       print_syscall_epilogue(name);
> --
> 2.37.3
> 

Reviewed-by: Laurent Vivier <laurent@vivier.eu>

> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 11/12] linux-user: Add close_range() syscall
  2022-09-18 19:45 ` [PATCH v3 11/12] linux-user: Add close_range() syscall Helge Deller
@ 2022-09-25 15:42   ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:42 UTC (permalink / raw)
  To: qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Signed-off-by: Helge Deller <deller@gmx.de>
> ---
>   linux-user/strace.list |  3 +++
>   linux-user/syscall.c   | 16 ++++++++++++++++
>   2 files changed, 19 insertions(+)
> 
> diff --git a/linux-user/strace.list b/linux-user/strace.list
> index 215d971b2a..ad9ef94689 100644
> --- a/linux-user/strace.list
> +++ b/linux-user/strace.list
> @@ -103,6 +103,9 @@
>   #ifdef TARGET_NR_close
>   { TARGET_NR_close, "close" , "%s(%d)", NULL, NULL },
>   #endif
> +#ifdef TARGET_NR_close_range
> +{ TARGET_NR_close_range, "close_range" , "%s(%d,%d,%d)", NULL, NULL },
> +#endif
>   #ifdef TARGET_NR_connect
>   { TARGET_NR_connect, "connect" , "%s(%d,%#x,%d)", NULL, NULL },
>   #endif
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index ca39acfceb..2e0e974562 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -338,6 +338,10 @@ _syscall3(int,sys_syslog,int,type,char*,bufp,int,len)
>   #ifdef __NR_exit_group
>   _syscall1(int,exit_group,int,error_code)
>   #endif
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +#define __NR_sys_close_range __NR_close_range
> +_syscall3(int,sys_close_range,int,first,int,last,int,flags)
> +#endif
>   #if defined(__NR_futex)
>   _syscall6(int,sys_futex,int *,uaddr,int,op,int,val,
>             const struct timespec *,timeout,int *,uaddr2,int,val3)
> @@ -8721,6 +8725,18 @@ static abi_long do_syscall1(CPUArchState *cpu_env, int num, abi_long arg1,
>       case TARGET_NR_close:
>           fd_trans_unregister(arg1);
>           return get_errno(close(arg1));
> +#if defined(__NR_close_range) && defined(TARGET_NR_close_range)
> +    case TARGET_NR_close_range:
> +        {
> +            abi_long fd;
> +            abi_long maxfd = (arg2 == (abi_long)-1) ? target_fd_max : arg2;
> +
> +            for (fd = arg1; fd <= maxfd; fd++) {
> +                fd_trans_unregister(fd);
> +            }
> +        }
> +        return get_errno(sys_close_range(arg1, arg2, arg3));

if flags is CLOSE_RANGE_CLOEXEC, the fd is not closed so you don't want to call 
fd_trans_unregister() in this case.

It would be better to call fd_trans_unregister() loop only if sys_close_range() doesn't fail.

Thanks,
Laurent

> +#endif
> 
>       case TARGET_NR_brk:
>           return do_brk(arg1);
> --
> 2.37.3
> 
> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-25 15:27     ` Helge Deller
@ 2022-09-25 15:47       ` Laurent Vivier
  2022-09-25 15:53         ` Helge Deller
  0 siblings, 1 reply; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:47 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 25/09/2022 à 17:27, Helge Deller a écrit :
> On 9/25/22 17:09, Laurent Vivier wrote:
>> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>>> Allow linux-user to strace the clock_gettime64() syscall.
>>> This syscall is used a lot on 32-bit guest architectures which use newer
>>> glibc versions.
>>>
>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>> ---
>>>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>>>   linux-user/strace.list |  4 ++++
>>>   2 files changed, 57 insertions(+)
>>>
>>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>>> index a4eeef7ae1..816e679995 100644
>>> --- a/linux-user/strace.c
>>> +++ b/linux-user/strace.c
>>> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>>>   UNUSED static void print_raw_param(const char *, abi_long, int);
>>>   UNUSED static void print_timeval(abi_ulong, int);
>>>   UNUSED static void print_timespec(abi_ulong, int);
>>> +UNUSED static void print_timespec64(abi_ulong, int);
>>>   UNUSED static void print_timezone(abi_ulong, int);
>>>   UNUSED static void print_itimerval(abi_ulong, int);
>>>   UNUSED static void print_number(abi_long, int);
>>> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
>>>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>>>   #endif
>>>
>>> +#if defined(TARGET_NR_clock_gettime64)
>>> +static void
>>> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
>>> +                                abi_long ret, abi_long arg0, abi_long arg1,
>>> +                                abi_long arg2, abi_long arg3, abi_long arg4,
>>> +                                abi_long arg5)
>>> +{
>>> +    if (!print_syscall_err(ret)) {
>>> +        qemu_log(TARGET_ABI_FMT_ld, ret);
>>> +        qemu_log(" (");
>>> +        print_timespec64(arg1, 1);
>>> +        qemu_log(")");
>>> +    }
>>> +
>>> +    qemu_log("\n");
>>> +}
>>> +#endif
>>> +
>>>   #ifdef TARGET_NR_gettimeofday
>>>   static void
>>>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
>>> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>>>       }
>>>   }
>>>
>>> +static void
>>> +print_timespec64(abi_ulong ts_addr, int last)
>>> +{
>>> +    if (ts_addr) {
>>> +        struct target__kernel_timespec *ts;
>>> +
>>> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
>>> +        if (!ts) {
>>> +            print_pointer(ts_addr, last);
>>> +            return;
>>> +        }
>>> +        qemu_log("{tv_sec = %lld"
>>> +                 ",tv_nsec = %lld}%s",
>>> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
>>> +                 get_comma(last));
>>> +        unlock_user(ts, ts_addr, 0);
>>> +    } else {
>>> +        qemu_log("NULL%s", get_comma(last));
>>> +    }
>>> +}
>>> +
>>>   static void
>>>   print_timezone(abi_ulong tz_addr, int last)
>>>   {
>>> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>>>   #define print_clock_getres     print_clock_gettime
>>>   #endif
>>>
>>> +#if defined(TARGET_NR_clock_gettime64)
>>> +static void
>>> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
>>> +    print_pointer(arg1, 1);
>>> +    print_syscall_epilogue(name);
>>> +}
>>> +#endif
>>
>> I think it could be simply:
>>
>> #define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.
> 
> Unfortunately not, because one uses print_timespec() while the other uses print_timespec64().
> 

The syscall_ret part cannot be shared, but the prefix function can, they are identical.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-25 15:47       ` Laurent Vivier
@ 2022-09-25 15:53         ` Helge Deller
  2022-09-25 15:58           ` Laurent Vivier
  0 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-25 15:53 UTC (permalink / raw)
  To: Laurent Vivier, Stefan Hajnoczi, Richard Henderson, qemu-devel

On 9/25/22 17:47, Laurent Vivier wrote:
> Le 25/09/2022 à 17:27, Helge Deller a écrit :
>> On 9/25/22 17:09, Laurent Vivier wrote:
>>> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>>>> Allow linux-user to strace the clock_gettime64() syscall.
>>>> This syscall is used a lot on 32-bit guest architectures which use newer
>>>> glibc versions.
>>>>
>>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>>> ---
>>>>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>>>>   linux-user/strace.list |  4 ++++
>>>>   2 files changed, 57 insertions(+)
>>>>
>>>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>>>> index a4eeef7ae1..816e679995 100644
>>>> --- a/linux-user/strace.c
>>>> +++ b/linux-user/strace.c
>>>> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>>>>   UNUSED static void print_raw_param(const char *, abi_long, int);
>>>>   UNUSED static void print_timeval(abi_ulong, int);
>>>>   UNUSED static void print_timespec(abi_ulong, int);
>>>> +UNUSED static void print_timespec64(abi_ulong, int);
>>>>   UNUSED static void print_timezone(abi_ulong, int);
>>>>   UNUSED static void print_itimerval(abi_ulong, int);
>>>>   UNUSED static void print_number(abi_long, int);
>>>> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
>>>>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>>>>   #endif
>>>>
>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>> +static void
>>>> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
>>>> +                                abi_long ret, abi_long arg0, abi_long arg1,
>>>> +                                abi_long arg2, abi_long arg3, abi_long arg4,
>>>> +                                abi_long arg5)
>>>> +{
>>>> +    if (!print_syscall_err(ret)) {
>>>> +        qemu_log(TARGET_ABI_FMT_ld, ret);
>>>> +        qemu_log(" (");
>>>> +        print_timespec64(arg1, 1);
>>>> +        qemu_log(")");
>>>> +    }
>>>> +
>>>> +    qemu_log("\n");
>>>> +}
>>>> +#endif
>>>> +
>>>>   #ifdef TARGET_NR_gettimeofday
>>>>   static void
>>>>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
>>>> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>>>>       }
>>>>   }
>>>>
>>>> +static void
>>>> +print_timespec64(abi_ulong ts_addr, int last)
>>>> +{
>>>> +    if (ts_addr) {
>>>> +        struct target__kernel_timespec *ts;
>>>> +
>>>> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
>>>> +        if (!ts) {
>>>> +            print_pointer(ts_addr, last);
>>>> +            return;
>>>> +        }
>>>> +        qemu_log("{tv_sec = %lld"
>>>> +                 ",tv_nsec = %lld}%s",
>>>> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
>>>> +                 get_comma(last));
>>>> +        unlock_user(ts, ts_addr, 0);
>>>> +    } else {
>>>> +        qemu_log("NULL%s", get_comma(last));
>>>> +    }
>>>> +}
>>>> +
>>>>   static void
>>>>   print_timezone(abi_ulong tz_addr, int last)
>>>>   {
>>>> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>>>>   #define print_clock_getres     print_clock_gettime
>>>>   #endif
>>>>
>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>> +static void
>>>> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
>>>> +    print_pointer(arg1, 1);
>>>> +    print_syscall_epilogue(name);
>>>> +}
>>>> +#endif
>>>
>>> I think it could be simply:
>>>
>>> #define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.
>>
>> Unfortunately not, because one uses print_timespec() while the other uses print_timespec64().
>
> The syscall_ret part cannot be shared, but the prefix function can, they are identical.

Ah.. right. I don't know any longer why I didn't that.
Maybe because of too much #ifdeffery or to keep the patch simple.
Will we leave as-is, will you clean up, or shall I resend that patch?

Helge


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-25 15:53         ` Helge Deller
@ 2022-09-25 15:58           ` Laurent Vivier
  2022-09-25 16:09             ` Helge Deller
  0 siblings, 1 reply; 35+ messages in thread
From: Laurent Vivier @ 2022-09-25 15:58 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 25/09/2022 à 17:53, Helge Deller a écrit :
> On 9/25/22 17:47, Laurent Vivier wrote:
>> Le 25/09/2022 à 17:27, Helge Deller a écrit :
>>> On 9/25/22 17:09, Laurent Vivier wrote:
>>>> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>>>>> Allow linux-user to strace the clock_gettime64() syscall.
>>>>> This syscall is used a lot on 32-bit guest architectures which use newer
>>>>> glibc versions.
>>>>>
>>>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>>>> ---
>>>>>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>>>>>   linux-user/strace.list |  4 ++++
>>>>>   2 files changed, 57 insertions(+)
>>>>>
>>>>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>>>>> index a4eeef7ae1..816e679995 100644
>>>>> --- a/linux-user/strace.c
>>>>> +++ b/linux-user/strace.c
>>>>> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>>>>>   UNUSED static void print_raw_param(const char *, abi_long, int);
>>>>>   UNUSED static void print_timeval(abi_ulong, int);
>>>>>   UNUSED static void print_timespec(abi_ulong, int);
>>>>> +UNUSED static void print_timespec64(abi_ulong, int);
>>>>>   UNUSED static void print_timezone(abi_ulong, int);
>>>>>   UNUSED static void print_itimerval(abi_ulong, int);
>>>>>   UNUSED static void print_number(abi_long, int);
>>>>> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct 
>>>>> syscallname
>>>>>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>>>>>   #endif
>>>>>
>>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>>> +static void
>>>>> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
>>>>> +                                abi_long ret, abi_long arg0, abi_long arg1,
>>>>> +                                abi_long arg2, abi_long arg3, abi_long arg4,
>>>>> +                                abi_long arg5)
>>>>> +{
>>>>> +    if (!print_syscall_err(ret)) {
>>>>> +        qemu_log(TARGET_ABI_FMT_ld, ret);
>>>>> +        qemu_log(" (");
>>>>> +        print_timespec64(arg1, 1);
>>>>> +        qemu_log(")");
>>>>> +    }
>>>>> +
>>>>> +    qemu_log("\n");
>>>>> +}
>>>>> +#endif
>>>>> +
>>>>>   #ifdef TARGET_NR_gettimeofday
>>>>>   static void
>>>>>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
>>>>> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>>>>>       }
>>>>>   }
>>>>>
>>>>> +static void
>>>>> +print_timespec64(abi_ulong ts_addr, int last)
>>>>> +{
>>>>> +    if (ts_addr) {
>>>>> +        struct target__kernel_timespec *ts;
>>>>> +
>>>>> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
>>>>> +        if (!ts) {
>>>>> +            print_pointer(ts_addr, last);
>>>>> +            return;
>>>>> +        }
>>>>> +        qemu_log("{tv_sec = %lld"
>>>>> +                 ",tv_nsec = %lld}%s",
>>>>> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
>>>>> +                 get_comma(last));
>>>>> +        unlock_user(ts, ts_addr, 0);
>>>>> +    } else {
>>>>> +        qemu_log("NULL%s", get_comma(last));
>>>>> +    }
>>>>> +}
>>>>> +
>>>>>   static void
>>>>>   print_timezone(abi_ulong tz_addr, int last)
>>>>>   {
>>>>> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>>>>>   #define print_clock_getres     print_clock_gettime
>>>>>   #endif
>>>>>
>>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>>> +static void
>>>>> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
>>>>> +    print_pointer(arg1, 1);
>>>>> +    print_syscall_epilogue(name);
>>>>> +}
>>>>> +#endif
>>>>
>>>> I think it could be simply:
>>>>
>>>> #define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.
>>>
>>> Unfortunately not, because one uses print_timespec() while the other uses print_timespec64().
>>
>> The syscall_ret part cannot be shared, but the prefix function can, they are identical.
> 
> Ah.. right. I don't know any longer why I didn't that.
> Maybe because of too much #ifdeffery or to keep the patch simple.
> Will we leave as-is, will you clean up, or shall I resend that patch?

As you prefer...

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace
  2022-09-25 15:58           ` Laurent Vivier
@ 2022-09-25 16:09             ` Helge Deller
  0 siblings, 0 replies; 35+ messages in thread
From: Helge Deller @ 2022-09-25 16:09 UTC (permalink / raw)
  To: Laurent Vivier, Stefan Hajnoczi, Richard Henderson, qemu-devel

On 9/25/22 17:58, Laurent Vivier wrote:
> Le 25/09/2022 à 17:53, Helge Deller a écrit :
>> On 9/25/22 17:47, Laurent Vivier wrote:
>>> Le 25/09/2022 à 17:27, Helge Deller a écrit :
>>>> On 9/25/22 17:09, Laurent Vivier wrote:
>>>>> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>>>>>> Allow linux-user to strace the clock_gettime64() syscall.
>>>>>> This syscall is used a lot on 32-bit guest architectures which use newer
>>>>>> glibc versions.
>>>>>>
>>>>>> Signed-off-by: Helge Deller <deller@gmx.de>
>>>>>> ---
>>>>>>   linux-user/strace.c    | 53 ++++++++++++++++++++++++++++++++++++++++++
>>>>>>   linux-user/strace.list |  4 ++++
>>>>>>   2 files changed, 57 insertions(+)
>>>>>>
>>>>>> diff --git a/linux-user/strace.c b/linux-user/strace.c
>>>>>> index a4eeef7ae1..816e679995 100644
>>>>>> --- a/linux-user/strace.c
>>>>>> +++ b/linux-user/strace.c
>>>>>> @@ -82,6 +82,7 @@ UNUSED static void print_buf(abi_long addr, abi_long len, int last);
>>>>>>   UNUSED static void print_raw_param(const char *, abi_long, int);
>>>>>>   UNUSED static void print_timeval(abi_ulong, int);
>>>>>>   UNUSED static void print_timespec(abi_ulong, int);
>>>>>> +UNUSED static void print_timespec64(abi_ulong, int);
>>>>>>   UNUSED static void print_timezone(abi_ulong, int);
>>>>>>   UNUSED static void print_itimerval(abi_ulong, int);
>>>>>>   UNUSED static void print_number(abi_long, int);
>>>>>> @@ -795,6 +796,24 @@ print_syscall_ret_clock_gettime(CPUArchState *cpu_env, const struct syscallname
>>>>>>   #define print_syscall_ret_clock_getres     print_syscall_ret_clock_gettime
>>>>>>   #endif
>>>>>>
>>>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>>>> +static void
>>>>>> +print_syscall_ret_clock_gettime64(CPUArchState *cpu_env, const struct syscallname *name,
>>>>>> +                                abi_long ret, abi_long arg0, abi_long arg1,
>>>>>> +                                abi_long arg2, abi_long arg3, abi_long arg4,
>>>>>> +                                abi_long arg5)
>>>>>> +{
>>>>>> +    if (!print_syscall_err(ret)) {
>>>>>> +        qemu_log(TARGET_ABI_FMT_ld, ret);
>>>>>> +        qemu_log(" (");
>>>>>> +        print_timespec64(arg1, 1);
>>>>>> +        qemu_log(")");
>>>>>> +    }
>>>>>> +
>>>>>> +    qemu_log("\n");
>>>>>> +}
>>>>>> +#endif
>>>>>> +
>>>>>>   #ifdef TARGET_NR_gettimeofday
>>>>>>   static void
>>>>>>   print_syscall_ret_gettimeofday(CPUArchState *cpu_env, const struct syscallname *name,
>>>>>> @@ -1652,6 +1671,27 @@ print_timespec(abi_ulong ts_addr, int last)
>>>>>>       }
>>>>>>   }
>>>>>>
>>>>>> +static void
>>>>>> +print_timespec64(abi_ulong ts_addr, int last)
>>>>>> +{
>>>>>> +    if (ts_addr) {
>>>>>> +        struct target__kernel_timespec *ts;
>>>>>> +
>>>>>> +        ts = lock_user(VERIFY_READ, ts_addr, sizeof(*ts), 1);
>>>>>> +        if (!ts) {
>>>>>> +            print_pointer(ts_addr, last);
>>>>>> +            return;
>>>>>> +        }
>>>>>> +        qemu_log("{tv_sec = %lld"
>>>>>> +                 ",tv_nsec = %lld}%s",
>>>>>> +                 (long long)tswap64(ts->tv_sec), (long long)tswap64(ts->tv_nsec),
>>>>>> +                 get_comma(last));
>>>>>> +        unlock_user(ts, ts_addr, 0);
>>>>>> +    } else {
>>>>>> +        qemu_log("NULL%s", get_comma(last));
>>>>>> +    }
>>>>>> +}
>>>>>> +
>>>>>>   static void
>>>>>>   print_timezone(abi_ulong tz_addr, int last)
>>>>>>   {
>>>>>> @@ -2267,6 +2307,19 @@ print_clock_gettime(CPUArchState *cpu_env, const struct syscallname *name,
>>>>>>   #define print_clock_getres     print_clock_gettime
>>>>>>   #endif
>>>>>>
>>>>>> +#if defined(TARGET_NR_clock_gettime64)
>>>>>> +static void
>>>>>> +print_clock_gettime64(CPUArchState *cpu_env, 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_enums(clockids, arg0, 0);
>>>>>> +    print_pointer(arg1, 1);
>>>>>> +    print_syscall_epilogue(name);
>>>>>> +}
>>>>>> +#endif
>>>>>
>>>>> I think it could be simply:
>>>>>
>>>>> #define print_clock_gettime64 print_clock_gettime where print_clock_gettime() is defined.
>>>>
>>>> Unfortunately not, because one uses print_timespec() while the other uses print_timespec64().
>>>
>>> The syscall_ret part cannot be shared, but the prefix function can, they are identical.
>>
>> Ah.. right. I don't know any longer why I didn't that.
>> Maybe because of too much #ifdeffery or to keep the patch simple.
>> Will we leave as-is, will you clean up, or shall I resend that patch?
>
> As you prefer...

I'd suggest to leave as-is for now.

Helge


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements
  2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
                   ` (11 preceding siblings ...)
  2022-09-18 19:45 ` [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
@ 2022-09-27  7:32 ` Laurent Vivier
  2022-09-27  8:56   ` Helge Deller
  12 siblings, 1 reply; 35+ messages in thread
From: Laurent Vivier @ 2022-09-27  7:32 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 18/09/2022 à 21:45, Helge Deller a écrit :
> Here is a bunch of patches for linux-user.
> 
> Most of them add missing syscalls and enhance the tracing/logging.
> Some of the patches are target-hppa specific.
> I've tested those on productive hppa debian buildd servers (running qemu-user).
> 
> Thanks!
> Helge
> 
> Changes to v2:
> - Fix build of close_range() and pidfd_*() patches on older Linux
>    distributions (noticed by Stefan Hajnoczi)
> 
> Changes to v1:
> - Dropped the faccessat2() syscall patch in favour of Richard's patch
> - Various changes to the "missing signals in strace output" patch based on
>    Richard's feedback, e.g. static arrays, fixed usage of _NSIG, fix build when
>    TARGET_SIGIOT does not exist
> - Use FUTEX_CMD_MASK in "Show timespec on strace for futex" patch
>    unconditionally and turn into a switch statement - as suggested by Richard
> 
> Helge Deller (12):
>    linux-user: Add missing signals in strace output
>    linux-user: Add missing clock_gettime64() syscall strace
>    linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd()
>      syscalls
>    linux-user: Log failing executable in EXCP_DUMP()
>    linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
>    linux-user/hppa: Dump IIR on register dump
>    linux-user: Fix strace of chmod() if mode == 0
>    linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch
>    linux-user: Add strace for clock_nanosleep()
>    linux-user: Show timespec on strace for futex()
>    linux-user: Add close_range() syscall
>    linux-user: Add parameters of getrandom() syscall for strace
> 
>   linux-user/cpu_loop-common.h |   2 +
>   linux-user/hppa/cpu_loop.c   |   6 +-
>   linux-user/mmap.c            |   4 +
>   linux-user/signal-common.h   |  46 ++++++++++++
>   linux-user/signal.c          |  37 +--------
>   linux-user/strace.c          | 142 ++++++++++++++++++++++++++++++-----
>   linux-user/strace.list       |  21 +++++-
>   linux-user/syscall.c         |  50 ++++++++++++
>   target/hppa/helper.c         |   6 +-
>   9 files changed, 255 insertions(+), 59 deletions(-)
> 
> --
> 2.37.3
> 

Series applied to my linux-user-for-7.2 branch,
except PATCH 11 and 12 that have comments.

Thanks,
Laurent
> 



^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements
  2022-09-27  7:32 ` [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Laurent Vivier
@ 2022-09-27  8:56   ` Helge Deller
  2022-09-27  9:12     ` Laurent Vivier
  0 siblings, 1 reply; 35+ messages in thread
From: Helge Deller @ 2022-09-27  8:56 UTC (permalink / raw)
  To: Laurent Vivier, Stefan Hajnoczi, Richard Henderson, qemu-devel

On 9/27/22 09:32, Laurent Vivier wrote:
> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>> Here is a bunch of patches for linux-user.
>>
>> Most of them add missing syscalls and enhance the tracing/logging.
>> Some of the patches are target-hppa specific.
>> I've tested those on productive hppa debian buildd servers (running qemu-user).
>>
>> Thanks!
>> Helge
>>
>> Changes to v2:
>> - Fix build of close_range() and pidfd_*() patches on older Linux
>>    distributions (noticed by Stefan Hajnoczi)
>>
>> Changes to v1:
>> - Dropped the faccessat2() syscall patch in favour of Richard's patch
>> - Various changes to the "missing signals in strace output" patch based on
>>    Richard's feedback, e.g. static arrays, fixed usage of _NSIG, fix build when
>>    TARGET_SIGIOT does not exist
>> - Use FUTEX_CMD_MASK in "Show timespec on strace for futex" patch
>>    unconditionally and turn into a switch statement - as suggested by Richard
>>
>> Helge Deller (12):
>>    linux-user: Add missing signals in strace output
>>    linux-user: Add missing clock_gettime64() syscall strace
>>    linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd()
>>      syscalls
>>    linux-user: Log failing executable in EXCP_DUMP()
>>    linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
>>    linux-user/hppa: Dump IIR on register dump
>>    linux-user: Fix strace of chmod() if mode == 0
>>    linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch
>>    linux-user: Add strace for clock_nanosleep()
>>    linux-user: Show timespec on strace for futex()
>>    linux-user: Add close_range() syscall
>>    linux-user: Add parameters of getrandom() syscall for strace
>>
>>   linux-user/cpu_loop-common.h |   2 +
>>   linux-user/hppa/cpu_loop.c   |   6 +-
>>   linux-user/mmap.c            |   4 +
>>   linux-user/signal-common.h   |  46 ++++++++++++
>>   linux-user/signal.c          |  37 +--------
>>   linux-user/strace.c          | 142 ++++++++++++++++++++++++++++++-----
>>   linux-user/strace.list       |  21 +++++-
>>   linux-user/syscall.c         |  50 ++++++++++++
>>   target/hppa/helper.c         |   6 +-
>>   9 files changed, 255 insertions(+), 59 deletions(-)
>>
>
> Series applied to my linux-user-for-7.2 branch,
> except PATCH 11 and 12 that have comments.

Thank you !!
I'll send updated versions for patches 11 and 12 asap.
Btw, where can I find your linux-user-for-7.2 branch?
It would help me to diff the new patches against this branch...

Helge


^ permalink raw reply	[flat|nested] 35+ messages in thread

* Re: [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements
  2022-09-27  8:56   ` Helge Deller
@ 2022-09-27  9:12     ` Laurent Vivier
  0 siblings, 0 replies; 35+ messages in thread
From: Laurent Vivier @ 2022-09-27  9:12 UTC (permalink / raw)
  To: Helge Deller, Stefan Hajnoczi, Richard Henderson, qemu-devel

Le 27/09/2022 à 10:56, Helge Deller a écrit :
> On 9/27/22 09:32, Laurent Vivier wrote:
>> Le 18/09/2022 à 21:45, Helge Deller a écrit :
>>> Here is a bunch of patches for linux-user.
>>>
>>> Most of them add missing syscalls and enhance the tracing/logging.
>>> Some of the patches are target-hppa specific.
>>> I've tested those on productive hppa debian buildd servers (running qemu-user).
>>>
>>> Thanks!
>>> Helge
>>>
>>> Changes to v2:
>>> - Fix build of close_range() and pidfd_*() patches on older Linux
>>>    distributions (noticed by Stefan Hajnoczi)
>>>
>>> Changes to v1:
>>> - Dropped the faccessat2() syscall patch in favour of Richard's patch
>>> - Various changes to the "missing signals in strace output" patch based on
>>>    Richard's feedback, e.g. static arrays, fixed usage of _NSIG, fix build when
>>>    TARGET_SIGIOT does not exist
>>> - Use FUTEX_CMD_MASK in "Show timespec on strace for futex" patch
>>>    unconditionally and turn into a switch statement - as suggested by Richard
>>>
>>> Helge Deller (12):
>>>    linux-user: Add missing signals in strace output
>>>    linux-user: Add missing clock_gettime64() syscall strace
>>>    linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd()
>>>      syscalls
>>>    linux-user: Log failing executable in EXCP_DUMP()
>>>    linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info
>>>    linux-user/hppa: Dump IIR on register dump
>>>    linux-user: Fix strace of chmod() if mode == 0
>>>    linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch
>>>    linux-user: Add strace for clock_nanosleep()
>>>    linux-user: Show timespec on strace for futex()
>>>    linux-user: Add close_range() syscall
>>>    linux-user: Add parameters of getrandom() syscall for strace
>>>
>>>   linux-user/cpu_loop-common.h |   2 +
>>>   linux-user/hppa/cpu_loop.c   |   6 +-
>>>   linux-user/mmap.c            |   4 +
>>>   linux-user/signal-common.h   |  46 ++++++++++++
>>>   linux-user/signal.c          |  37 +--------
>>>   linux-user/strace.c          | 142 ++++++++++++++++++++++++++++++-----
>>>   linux-user/strace.list       |  21 +++++-
>>>   linux-user/syscall.c         |  50 ++++++++++++
>>>   target/hppa/helper.c         |   6 +-
>>>   9 files changed, 255 insertions(+), 59 deletions(-)
>>>
>>
>> Series applied to my linux-user-for-7.2 branch,
>> except PATCH 11 and 12 that have comments.
> 
> Thank you !!
> I'll send updated versions for patches 11 and 12 asap.
> Btw, where can I find your linux-user-for-7.2 branch?
> It would help me to diff the new patches against this branch...
> 

https://gitlab.com/laurent_vivier/qemu/-/commits/linux-user-for-7.2/

But I can update and remove some patches if they appear to be broken when I test them.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 35+ messages in thread

end of thread, other threads:[~2022-09-27 10:06 UTC | newest]

Thread overview: 35+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-18 19:45 [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Helge Deller
2022-09-18 19:45 ` [PATCH v3 01/12] linux-user: Add missing signals in strace output Helge Deller
2022-09-25 15:00   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 02/12] linux-user: Add missing clock_gettime64() syscall strace Helge Deller
2022-09-25 15:09   ` Laurent Vivier
2022-09-25 15:27     ` Helge Deller
2022-09-25 15:47       ` Laurent Vivier
2022-09-25 15:53         ` Helge Deller
2022-09-25 15:58           ` Laurent Vivier
2022-09-25 16:09             ` Helge Deller
2022-09-18 19:45 ` [PATCH v3 03/12] linux-user: Add pidfd_open(), pidfd_send_signal() and pidfd_getfd() syscalls Helge Deller
2022-09-25 15:25   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 04/12] linux-user: Log failing executable in EXCP_DUMP() Helge Deller
2022-09-18 20:37   ` Philippe Mathieu-Daudé via
2022-09-25 15:26   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 05/12] linux-user/hppa: Use EXCP_DUMP() to show enhanced debug info Helge Deller
2022-09-25 15:26   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 06/12] linux-user/hppa: Dump IIR on register dump Helge Deller
2022-09-18 20:38   ` Philippe Mathieu-Daudé via
2022-09-25 15:27   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 07/12] linux-user: Fix strace of chmod() if mode == 0 Helge Deller
2022-09-18 20:46   ` Philippe Mathieu-Daudé via
2022-09-25 15:29   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 08/12] linux-user/hppa: Set TASK_UNMAPPED_BASE to 0xfa000000 for hppa arch Helge Deller
2022-09-18 19:45 ` [PATCH v3 09/12] linux-user: Add strace for clock_nanosleep() Helge Deller
2022-09-25 15:36   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 10/12] linux-user: Show timespec on strace for futex() Helge Deller
2022-09-25 15:38   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 11/12] linux-user: Add close_range() syscall Helge Deller
2022-09-25 15:42   ` Laurent Vivier
2022-09-18 19:45 ` [PATCH v3 12/12] linux-user: Add parameters of getrandom() syscall for strace Helge Deller
2022-09-18 20:49   ` Philippe Mathieu-Daudé via
2022-09-27  7:32 ` [PATCH v3 00/12] linux-user: Add more syscalls, enhance tracing & logging enhancements Laurent Vivier
2022-09-27  8:56   ` Helge Deller
2022-09-27  9:12     ` Laurent Vivier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.