Skip to contentSkip to conversation

linux-user: Fix assorted Qemu user mode issues

PATCH New Aleksandar Markovic 1 participant 3 messages Oct 10, 2016

lore
Share & tools
lore
#0 lore raw

v9 cover linux-user: Fix assorted Qemu user mode issues

From: Aleksandar Markovic <[email protected]>

v8->v9:

- for clock_adjtime() handling, -EFAULT is returned if copying of structure times from target to host fails

v7->v8:

- patches for clock_adjtime() and syncfs() fixed so that certain older system can detect absence of support for these system calls and exclude appropriate code segments from building
- implemented better error condition handling for clock_adjtime()
- added strace support for syncfs()
- improved commit messages

NOTE: v8 contains only these two patches, since it was noticed that older
systems may have build problems with such support; other patches are fine in that sense. Also, these two patches in v8 assume that patch 1 from v7 (adjtimex() support) is already applied.

v6->v7:

- rebased to the latest code (there was a large linux-user change since v6, consisting of 26 patches)
- slightly changed order of patches
- changed PATH_MAX to 128 in sysfs() patch (last remaining item that was supposed to be in the previous version)

v5->v6:

- rebased to the latest code
- reworked all patches according to review feedback
- added two new patches on syncfs() and mq_open()
- some improvements in commit messages

v4->v5:

- removed three cleanup patches

v3->v4:

- rebased to the latest code
- added patch on clock_adjtime() support
- minor commit messages improvements

v2->v3:

- rebased to the latest code
- merged patches on adjtimex(), sysfs(), and ustat() from another series
- added patch on socketcall() support
- cleanup patches reorganized

v1->v2:

- improved usage of "#ifdefs" in patch on syslog()
- removed EIDRM-related code from patch on msgrcv(), since this error code is already handled well
- added three cleanup patches

(v1 for some reason did not appear on qemu-devel, but mails are sent)

This series fixes certain Qemu user mode issues. The fixes mainly originate from observation of LTP tests failures for execution in Qemu user mode on various platforms.

Aleksandar Markovic (2):
linux-user: Add support for clock_adjtime() syscall
linux-user: Add support for syncfs() syscall

 configure              | 36 ++++++++++++++++++++++++
 linux-user/strace.c    | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 linux-user/strace.list |  5 +++-
 linux-user/syscall.c   | 23 +++++++++++++++
 4 files changed, 139 insertions(+), 1 deletion(-)
Signature · 1 line
2.9.3
#1 lore raw

PATCH v9 1/2 linux-user: Add support for clock_adjtime() syscall

From: Aleksandar Markovic <[email protected]>

This patch implements Qemu user mode clock_adjtime() syscall support.

The implementation is based on invocation of host's clock_adjtime().

---
 configure              | 18 ++++++++++++
 linux-user/strace.c    | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++
 linux-user/strace.list |  3 ++
 linux-user/syscall.c   | 18 ++++++++++++
 4 files changed, 115 insertions(+)
configure +18 -0
index 5751d8e..044e0cd 100755
@@ -3898,6 +3898,21 @@ if compile_prog "" "" ; then
   setns=yes
 fi
 
+# clock_adjtime probe
+clock_adjtime=no
+cat > $TMPC <<EOF
+#include <time.h>
+
+int main(void)
+{
+    return clock_adjtime(0, 0);
+}
+EOF
+clock_adjtime=no
+if compile_prog "" "" ; then
+  clock_adjtime=yes
+fi
+
 # Check if tools are available to build documentation.
 if test "$docs" != "no" ; then
   if has makeinfo && has pod2man; then
@@ -5183,6 +5198,9 @@ fi
 if test "$setns" = "yes" ; then
   echo "CONFIG_SETNS=y" >> $config_host_mak
 fi
+if test "$clock_adjtime" = "yes" ; then
+  echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
+fi
 if test "$inotify" = "yes" ; then
   echo "CONFIG_INOTIFY=y" >> $config_host_mak
 fi
linux-user/strace.c +76 -0

88 lines not on this page · raw message

linux-user/strace.list +3 -0
index f6dd044..9355075 100644
@@ -79,6 +79,9 @@
 #ifdef TARGET_NR_chroot
 { TARGET_NR_chroot, "chroot" , NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_clock_adjtime
+{ TARGET_NR_clock_adjtime, "clock_adjtime" , NULL, print_clock_adjtime, NULL },
+#endif
 #ifdef TARGET_NR_clock_getres
 { TARGET_NR_clock_getres, "clock_getres" , NULL, NULL, NULL },
 #endif
linux-user/syscall.c +18 -0
index 35363cc..c4e2641 100644
@@ -48,6 +48,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <sys/shm.h>
 #include <sys/sem.h>
 #include <sys/statfs.h>
+#include <time.h>
 #include <utime.h>
 #include <sys/sysinfo.h>
 #include <sys/signalfd.h>
@@ -9624,6 +9625,23 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
             }
         }
         break;
+#if defined(TARGET_NR_clock_adjtime) && defined(CONFIG_CLOCK_ADJTIME)
+    case TARGET_NR_clock_adjtime:
+        {
+            struct timex htx, *phtx = &htx;
+
+            if (target_to_host_timex(phtx, arg2) != 0) {
+                goto efault;
+            }
+            ret = get_errno(clock_adjtime(arg1, phtx));
+            if (!is_error(ret) && phtx) {
+                if (host_to_target_timex(arg2, phtx) != 0) {
+                    goto efault;
+                }
+            }
+        }
+        break;
+#endif
 #ifdef TARGET_NR_create_module
     case TARGET_NR_create_module:
 #endif
Signature · 1 line
2.9.3
#2 lore raw

PATCH v9 2/2 linux-user: Add support for syncfs() syscall

In reply to Aleksandar Markovic

From: Aleksandar Markovic <[email protected]>

This patch implements Qemu user mode syncfs() syscall support. Syscall syncfs() syncs the filesystem containing file determined by the open file descriptor passed as the argument to syncfs().

The implementation consists of a straightforward invocation of host's syncfs(). Configure and strace support is included as well.

---
 configure              | 18 ++++++++++++++++++
 linux-user/strace.list |  2 +-
 linux-user/syscall.c   |  5 +++++
 3 files changed, 24 insertions(+), 1 deletion(-)
configure +18 -0
index 044e0cd..7b9984b 100755
@@ -3913,6 +3913,21 @@ if compile_prog "" "" ; then
   clock_adjtime=yes
 fi
 
+# syncfs probe
+syncfs=no
+cat > $TMPC <<EOF
+#include <unistd.h>
+
+int main(void)
+{
+    return syncfs(0);
+}
+EOF
+syncfs=no
+if compile_prog "" "" ; then
+  syncfs=yes
+fi
+
 # Check if tools are available to build documentation.
 if test "$docs" != "no" ; then
   if has makeinfo && has pod2man; then
@@ -5201,6 +5216,9 @@ fi
 if test "$clock_adjtime" = "yes" ; then
   echo "CONFIG_CLOCK_ADJTIME=y" >> $config_host_mak
 fi
+if test "$syncfs" = "yes" ; then
+  echo "CONFIG_SYNCFS=y" >> $config_host_mak
+fi
 if test "$inotify" = "yes" ; then
   echo "CONFIG_INOTIFY=y" >> $config_host_mak
 fi
linux-user/strace.list +1 -1
index 9355075..c549f99 100644
@@ -1462,7 +1462,7 @@
 { TARGET_NR_sync_file_range, "sync_file_range" , NULL, NULL, NULL },
 #endif
 #ifdef TARGET_NR_syncfs
-{ TARGET_NR_syncfs, "syncfs" , NULL, NULL, NULL },
+{ TARGET_NR_syncfs, "syncfs" , "%s(%d)", NULL, NULL },
 #endif
 #ifdef TARGET_NR_syscall
 { TARGET_NR_syscall, "syscall" , NULL, NULL, NULL },
linux-user/syscall.c +5 -0
index c4e2641..8b24efb 100644
@@ -8071,6 +8071,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         sync();
         ret = 0;
         break;
+#if defined(TARGET_NR_syncfs) && defined(CONFIG_SYNCFS)
+    case TARGET_NR_syncfs:
+        ret = get_errno(syncfs(arg1));
+        break;
+#endif
     case TARGET_NR_kill:
         ret = get_errno(safe_kill(arg1, target_to_host_signal(arg2)));
         break;
Signature · 1 line
2.9.3