qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/19] linux-user changes for 2.1
@ 2014-06-23 13:26 riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 01/19] Add support for MAP_NORESERVE mmap flag riku.voipio
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Riku Voipio

From: Riku Voipio <riku.voipio@linaro.org>

The following changes since commit d9c1647d896d3192cba9dbf98fb7efab876edde5:

  Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2014-06-23 12:55:22 +0100)

are available in the git repository at:

  git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream

for you to fetch changes up to 1f1fb45ffe2a67bc1853b55b1d029fcee37d546a:

  linux-user: support the SIOCGIFINDEX ioctl (2014-06-23 16:00:23 +0300)

Christophe Lyon (1):
  Add support for MAP_NORESERVE mmap flag.

Hunter Laux (1):
  Add support for the arm breakpoint syscall

Paul Burton (16):
  linux-user: translate the result of getsockopt SO_TYPE
  linux-user: support SO_ACCEPTCONN getsockopt option
  linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options
  linux-user: support SO_PASSSEC setsockopt option
  linux-user: allow NULL arguments to mount
  linux-user: support strace of epoll_create1
  linux-user: fix struct target_epoll_event layout for MIPS
  linux-user: respect timezone for settimeofday
  linux-user: allow NULL tv argument for settimeofday
  linux-user: support timerfd_{create, gettime, settime} syscalls
  linux-user: support ioprio_{get, set} syscalls
  linux-user: support {name_to, open_by}_handle_at syscalls
  linux-user: support the setns syscall
  linux-user: support the unshare syscall
  linux-user: support the KDSIGACCEPT ioctl
  linux-user: support the SIOCGIFINDEX ioctl

Wim Vander Schelden (1):
  linux-user: added fake open() for /proc/self/cmdline

 linux-user/arm/syscall.h  |   1 +
 linux-user/ioctls.h       |   2 +
 linux-user/main.c         |   4 +
 linux-user/socket.h       |   5 +
 linux-user/strace.c       |  30 ++++
 linux-user/strace.list    |  21 +++
 linux-user/syscall.c      | 347 ++++++++++++++++++++++++++++++++++++++++++----
 linux-user/syscall_defs.h |   9 +-
 8 files changed, 392 insertions(+), 27 deletions(-)

-- 
2.0.0

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

* [Qemu-devel] [PULL 01/19] Add support for MAP_NORESERVE mmap flag.
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 02/19] Add support for the arm breakpoint syscall riku.voipio
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Christophe Lyon

From: Christophe Lyon <christophe.lyon@linaro.org>

mmap_flags_tbl contains a list of mmap flags, and how to map them to
the target. This patch adds MAP_NORESERVE, which was missing to the
list.

Signed-off-by: Christophe Lyon <christophe.lyon@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 7d74079..007d59d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3908,6 +3908,8 @@ static bitmask_transtbl mmap_flags_tbl[] = {
 	{ TARGET_MAP_DENYWRITE, TARGET_MAP_DENYWRITE, MAP_DENYWRITE, MAP_DENYWRITE },
 	{ TARGET_MAP_EXECUTABLE, TARGET_MAP_EXECUTABLE, MAP_EXECUTABLE, MAP_EXECUTABLE },
 	{ TARGET_MAP_LOCKED, TARGET_MAP_LOCKED, MAP_LOCKED, MAP_LOCKED },
+        { TARGET_MAP_NORESERVE, TARGET_MAP_NORESERVE, MAP_NORESERVE,
+          MAP_NORESERVE },
 	{ 0, 0, 0, 0 }
 };
 
-- 
2.0.0

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

* [Qemu-devel] [PULL 02/19] Add support for the arm breakpoint syscall
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 01/19] Add support for MAP_NORESERVE mmap flag riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 03/19] linux-user: added fake open() for /proc/self/cmdline riku.voipio
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Hunter Laux

From: Hunter Laux <hunterlaux@gmail.com>

OABI arm used a software interrupt(0xef9f0001) for breakpoints.
Since 2005 gdb has used the break instruction(0xe7f001f0) for EABI.
Apparently Steel Bank Common Lisp still uses the swi instruction.

This is the kernel implementation:
http://lxr.free-electrons.com/source/arch/arm/kernel/traps.c#L598

Signed-off-by: Hunter Laux <hunterlaux@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/arm/syscall.h | 1 +
 linux-user/main.c        | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/linux-user/arm/syscall.h b/linux-user/arm/syscall.h
index ce2c2a8..e0d2cc3 100644
--- a/linux-user/arm/syscall.h
+++ b/linux-user/arm/syscall.h
@@ -29,6 +29,7 @@ struct target_pt_regs {
 #define ARM_THUMB_SYSCALL	0
 
 #define ARM_NR_BASE	  0xf0000
+#define ARM_NR_breakpoint (ARM_NR_BASE + 1)
 #define ARM_NR_cacheflush (ARM_NR_BASE + 2)
 #define ARM_NR_set_tls	  (ARM_NR_BASE + 5)
 
diff --git a/linux-user/main.c b/linux-user/main.c
index a87c6f7..9c3eddc 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -807,6 +807,9 @@ void cpu_loop(CPUARMState *env)
                             cpu_set_tls(env, env->regs[0]);
                             env->regs[0] = 0;
                             break;
+                        case ARM_NR_breakpoint:
+                            env->regs[15] -= env->thumb ? 2 : 4;
+                            goto excp_debug;
                         default:
                             gemu_log("qemu: Unsupported ARM syscall: 0x%x\n",
                                      n);
@@ -850,6 +853,7 @@ void cpu_loop(CPUARMState *env)
             }
             break;
         case EXCP_DEBUG:
+        excp_debug:
             {
                 int sig;
 
-- 
2.0.0

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

* [Qemu-devel] [PULL 03/19] linux-user: added fake open() for /proc/self/cmdline
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 01/19] Add support for MAP_NORESERVE mmap flag riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 02/19] Add support for the arm breakpoint syscall riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 04/19] linux-user: translate the result of getsockopt SO_TYPE riku.voipio
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Wim Vander Schelden

From: Wim Vander Schelden <wim@fixnum.org>

Signed-off-by: Wim Vander Schelden <wim@fixnum.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 007d59d..5c175ba 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4949,6 +4949,51 @@ int host_to_target_waitstatus(int status)
     return status;
 }
 
+static int open_self_cmdline(void *cpu_env, int fd)
+{
+    int fd_orig = -1;
+    bool word_skipped = false;
+
+    fd_orig = open("/proc/self/cmdline", O_RDONLY);
+    if (fd_orig < 0) {
+        return fd_orig;
+    }
+
+    while (true) {
+        ssize_t nb_read;
+        char buf[128];
+        char *cp_buf = buf;
+
+        nb_read = read(fd_orig, buf, sizeof(buf));
+        if (nb_read < 0) {
+            fd_orig = close(fd_orig);
+            return -1;
+        } else if (nb_read == 0) {
+            break;
+        }
+
+        if (!word_skipped) {
+            /* Skip the first string, which is the path to qemu-*-static
+               instead of the actual command. */
+            cp_buf = memchr(buf, 0, sizeof(buf));
+            if (cp_buf) {
+                /* Null byte found, skip one string */
+                cp_buf++;
+                nb_read -= cp_buf - buf;
+                word_skipped = true;
+            }
+        }
+
+        if (word_skipped) {
+            if (write(fd, cp_buf, nb_read) != nb_read) {
+                return -1;
+            }
+        }
+    }
+
+    return close(fd_orig);
+}
+
 static int open_self_maps(void *cpu_env, int fd)
 {
 #if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
@@ -5150,6 +5195,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
         { "maps", open_self_maps, is_proc_myself },
         { "stat", open_self_stat, is_proc_myself },
         { "auxv", open_self_auxv, is_proc_myself },
+        { "cmdline", open_self_cmdline, is_proc_myself },
 #if defined(HOST_WORDS_BIGENDIAN) != defined(TARGET_WORDS_BIGENDIAN)
         { "/proc/net/route", open_net_route, is_proc },
 #endif
-- 
2.0.0

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

* [Qemu-devel] [PULL 04/19] linux-user: translate the result of getsockopt SO_TYPE
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (2 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 03/19] linux-user: added fake open() for /proc/self/cmdline riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 05/19] linux-user: support SO_ACCEPTCONN getsockopt option riku.voipio
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

QEMU previously passed the result of the host syscall directly to the
target program. This is a problem if the host & target have different
representations of socket types, as is the case when running a MIPS
target program on an x86 host. Introduce a host_to_target_sock_type
helper function mirroring the existing target_to_host_sock_type, and
call it to translate the value provided by getsockopt when called for
the SO_TYPE option.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 5c175ba..8d13781 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -592,6 +592,37 @@ char *target_strerror(int err)
     return strerror(target_to_host_errno(err));
 }
 
+static inline int host_to_target_sock_type(int host_type)
+{
+    int target_type;
+
+    switch (host_type & 0xf /* SOCK_TYPE_MASK */) {
+    case SOCK_DGRAM:
+        target_type = TARGET_SOCK_DGRAM;
+        break;
+    case SOCK_STREAM:
+        target_type = TARGET_SOCK_STREAM;
+        break;
+    default:
+        target_type = host_type & 0xf /* SOCK_TYPE_MASK */;
+        break;
+    }
+
+#if defined(SOCK_CLOEXEC)
+    if (host_type & SOCK_CLOEXEC) {
+        target_type |= TARGET_SOCK_CLOEXEC;
+    }
+#endif
+
+#if defined(SOCK_NONBLOCK)
+    if (host_type & SOCK_NONBLOCK) {
+        target_type |= TARGET_SOCK_NONBLOCK;
+    }
+#endif
+
+    return target_type;
+}
+
 static abi_ulong target_brk;
 static abi_ulong target_original_brk;
 static abi_ulong brk_page;
@@ -1636,6 +1667,9 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         ret = get_errno(getsockopt(sockfd, level, optname, &val, &lv));
         if (ret < 0)
             return ret;
+        if (optname == SO_TYPE) {
+            val = host_to_target_sock_type(val);
+        }
         if (len > lv)
             len = lv;
         if (len == 4) {
-- 
2.0.0

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

* [Qemu-devel] [PULL 05/19] linux-user: support SO_ACCEPTCONN getsockopt option
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (3 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 04/19] linux-user: translate the result of getsockopt SO_TYPE riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 06/19] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options riku.voipio
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Translate the SO_ACCEPTCONN option to the host value & execute the
syscall as expected.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8d13781..b1e57df 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1652,6 +1652,9 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
         case TARGET_SO_RCVLOWAT:
             optname = SO_RCVLOWAT;
             goto int_case;
+        case TARGET_SO_ACCEPTCONN:
+            optname = SO_ACCEPTCONN;
+            goto int_case;
         default:
             goto int_case;
         }
-- 
2.0.0

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

* [Qemu-devel] [PULL 06/19] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (4 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 05/19] linux-user: support SO_ACCEPTCONN getsockopt option riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 07/19] linux-user: support SO_PASSSEC setsockopt option riku.voipio
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Translate the SO_SNDBUFFORCE & SO_RCVBUFFORCE options to setsockopt to
the host values & perform the syscall as expected, allowing use of those
options by target programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b1e57df..bdc60fe 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1502,9 +1502,15 @@ set_timeout:
         case TARGET_SO_SNDBUF:
 		optname = SO_SNDBUF;
 		break;
+        case TARGET_SO_SNDBUFFORCE:
+                optname = SO_SNDBUFFORCE;
+                break;
         case TARGET_SO_RCVBUF:
 		optname = SO_RCVBUF;
 		break;
+        case TARGET_SO_RCVBUFFORCE:
+                optname = SO_RCVBUFFORCE;
+                break;
         case TARGET_SO_KEEPALIVE:
 		optname = SO_KEEPALIVE;
 		break;
-- 
2.0.0

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

* [Qemu-devel] [PULL 07/19] linux-user: support SO_PASSSEC setsockopt option
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (5 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 06/19] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 08/19] linux-user: allow NULL arguments to mount riku.voipio
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Translate the SO_PASSSEC option to setsockopt to the host value &
perform the syscall as expected, allowing use of the option by target
programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/socket.h  | 5 +++++
 linux-user/syscall.c | 3 +++
 2 files changed, 8 insertions(+)

diff --git a/linux-user/socket.h b/linux-user/socket.h
index ae17959..4dacae6 100644
--- a/linux-user/socket.h
+++ b/linux-user/socket.h
@@ -63,6 +63,7 @@
     #define TARGET_SO_PEERSEC              30
     #define TARGET_SO_SNDBUFFORCE          31
     #define TARGET_SO_RCVBUFFORCE          33
+    #define TARGET_SO_PASSSEC              34
 
     /** sock_type - Socket types
      *
@@ -242,6 +243,10 @@
 
     #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1)
     #define TARGET_SOCK_TYPE_MASK    0xf  /* Covers up to TARGET_SOCK_MAX-1. */
+
+    #define TARGET_SO_PASSSEC        31
+#else
+    #define TARGET_SO_PASSSEC        34
 #endif
 
     /* For setsockopt(2) */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bdc60fe..3971cb5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1531,6 +1531,9 @@ set_timeout:
         case TARGET_SO_PASSCRED:
 		optname = SO_PASSCRED;
 		break;
+        case TARGET_SO_PASSSEC:
+                optname = SO_PASSSEC;
+                break;
         case TARGET_SO_TIMESTAMP:
 		optname = SO_TIMESTAMP;
 		break;
-- 
2.0.0

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

* [Qemu-devel] [PULL 08/19] linux-user: allow NULL arguments to mount
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (6 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 07/19] linux-user: support SO_PASSSEC setsockopt option riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 09/19] linux-user: support strace of epoll_create1 riku.voipio
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Calls to the mount syscall can legitimately provide NULL as the value
for the source of filesystemtype arguments, which QEMU would previously
reject & return -EFAULT to the target program. An example of this is
remounting an already mounted filesystem with different properties.

Instead of rejecting such syscalls with -EFAULT, pass NULL along to the
kernel as the target program expects.

Additionally this patch fixes a potential memory leak when DEBUG_REMAP
is enabled and lock_user_string fails on the target or filesystemtype
arguments but a prior argument was non-NULL and already locked.

Since the patch already touched most lines of the TARGET_NR_mount case,
it fixes the indentation & coding style for good measure.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 75 +++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 53 insertions(+), 22 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3971cb5..4e48af6 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5614,29 +5614,60 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
     case TARGET_NR_mount:
-		{
-			/* need to look at the data field */
-			void *p2, *p3;
-			p = lock_user_string(arg1);
-			p2 = lock_user_string(arg2);
-			p3 = lock_user_string(arg3);
-                        if (!p || !p2 || !p3)
-                            ret = -TARGET_EFAULT;
-                        else {
-                            /* FIXME - arg5 should be locked, but it isn't clear how to
-                             * do that since it's not guaranteed to be a NULL-terminated
-                             * string.
-                             */
-                            if ( ! arg5 )
-                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL));
-                            else
-                                ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
-                        }
+        {
+            /* need to look at the data field */
+            void *p2, *p3;
+
+            if (arg1) {
+                p = lock_user_string(arg1);
+                if (!p) {
+                    goto efault;
+                }
+            } else {
+                p = NULL;
+            }
+
+            p2 = lock_user_string(arg2);
+            if (!p2) {
+                if (arg1) {
+                    unlock_user(p, arg1, 0);
+                }
+                goto efault;
+            }
+
+            if (arg3) {
+                p3 = lock_user_string(arg3);
+                if (!p3) {
+                    if (arg1) {
                         unlock_user(p, arg1, 0);
-                        unlock_user(p2, arg2, 0);
-                        unlock_user(p3, arg3, 0);
-			break;
-		}
+                    }
+                    unlock_user(p2, arg2, 0);
+                    goto efault;
+                }
+            } else {
+                p3 = NULL;
+            }
+
+            /* FIXME - arg5 should be locked, but it isn't clear how to
+             * do that since it's not guaranteed to be a NULL-terminated
+             * string.
+             */
+            if (!arg5) {
+                ret = mount(p, p2, p3, (unsigned long)arg4, NULL);
+            } else {
+                ret = mount(p, p2, p3, (unsigned long)arg4, g2h(arg5));
+            }
+            ret = get_errno(ret);
+
+            if (arg1) {
+                unlock_user(p, arg1, 0);
+            }
+            unlock_user(p2, arg2, 0);
+            if (arg3) {
+                unlock_user(p3, arg3, 0);
+            }
+        }
+        break;
 #ifdef TARGET_NR_umount
     case TARGET_NR_umount:
         if (!(p = lock_user_string(arg1)))
-- 
2.0.0

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

* [Qemu-devel] [PULL 09/19] linux-user: support strace of epoll_create1
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (7 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 08/19] linux-user: allow NULL arguments to mount riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 10/19] linux-user: fix struct target_epoll_event layout for MIPS riku.voipio
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add the epoll_create1 syscall to strace.list in order to display that
syscall when it occurs, rather than a message about the syscall being
unknown despite QEMU already implementing support for it.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/strace.list | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index cf5841a..fcb258d 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -114,6 +114,9 @@
 #ifdef TARGET_NR_epoll_create
 { TARGET_NR_epoll_create, "epoll_create" , NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_epoll_create1
+{ TARGET_NR_epoll_create1, "epoll_create1" , NULL, NULL, NULL },
+#endif
 #ifdef TARGET_NR_epoll_ctl
 { TARGET_NR_epoll_ctl, "epoll_ctl" , NULL, NULL, NULL },
 #endif
-- 
2.0.0

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

* [Qemu-devel] [PULL 10/19] linux-user: fix struct target_epoll_event layout for MIPS
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (8 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 09/19] linux-user: support strace of epoll_create1 riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 11/19] linux-user: respect timezone for settimeofday riku.voipio
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

MIPS requires the pad field to 64b-align the data field just as ARM
does.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall_defs.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 69c3982..e379b45 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -2528,7 +2528,7 @@ typedef union target_epoll_data {
 
 struct target_epoll_event {
     uint32_t events;
-#ifdef TARGET_ARM
+#if defined(TARGET_ARM) || defined(TARGET_MIPS) || defined(TARGET_MIPS64)
     uint32_t __pad;
 #endif
     target_epoll_data_t data;
-- 
2.0.0

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

* [Qemu-devel] [PULL 11/19] linux-user: respect timezone for settimeofday
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (9 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 10/19] linux-user: fix struct target_epoll_event layout for MIPS riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 12/19] linux-user: allow NULL tv argument " riku.voipio
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

The settimeofday syscall accepts a tz argument indicating the desired
timezone to the kernel. QEMU previously ignored any argument provided
by the target program & always passed NULL to the kernel. Instead,
translate the argument & pass along the data userland provided.

Although this argument is described by the settimeofday man page as
obsolete, it is used by systemd as of version 213.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c      | 29 ++++++++++++++++++++++++++++-
 linux-user/syscall_defs.h |  5 +++++
 2 files changed, 33 insertions(+), 1 deletion(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 4e48af6..0ce1a4e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -935,6 +935,23 @@ static inline abi_long copy_to_user_timeval(abi_ulong target_tv_addr,
     return 0;
 }
 
+static inline abi_long copy_from_user_timezone(struct timezone *tz,
+                                               abi_ulong target_tz_addr)
+{
+    struct target_timezone *target_tz;
+
+    if (!lock_user_struct(VERIFY_READ, target_tz, target_tz_addr, 1)) {
+        return -TARGET_EFAULT;
+    }
+
+    __get_user(tz->tz_minuteswest, &target_tz->tz_minuteswest);
+    __get_user(tz->tz_dsttime, &target_tz->tz_dsttime);
+
+    unlock_user_struct(target_tz, target_tz_addr, 0);
+
+    return 0;
+}
+
 #if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
 #include <mqueue.h>
 
@@ -6385,9 +6402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     case TARGET_NR_settimeofday:
         {
             struct timeval tv;
+            struct timezone tz, *ptz = NULL;
+
             if (copy_from_user_timeval(&tv, arg1))
                 goto efault;
-            ret = get_errno(settimeofday(&tv, NULL));
+
+            if (arg2) {
+                if (copy_from_user_timezone(&tz, arg2)) {
+                    goto efault;
+                }
+                ptz = &tz;
+            }
+
+            ret = get_errno(settimeofday(&tv, ptz));
         }
         break;
 #if defined(TARGET_NR_select)
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index e379b45..a1f1fce 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -165,6 +165,11 @@ struct target_timespec {
     abi_long tv_nsec;
 };
 
+struct target_timezone {
+    abi_int tz_minuteswest;
+    abi_int tz_dsttime;
+};
+
 struct target_itimerval {
     struct target_timeval it_interval;
     struct target_timeval it_value;
-- 
2.0.0

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

* [Qemu-devel] [PULL 12/19] linux-user: allow NULL tv argument for settimeofday
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (10 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 11/19] linux-user: respect timezone for settimeofday riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 13/19] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

The tv argument to the settimeofday syscall is allowed to be NULL, if
the program only wishes to provide the timezone. QEMU previously
returned -EFAULT when tv was NULL. Instead, execute the syscall &
provide NULL to the kernel as the target program expected.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0ce1a4e..8e2762b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6401,11 +6401,15 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     case TARGET_NR_settimeofday:
         {
-            struct timeval tv;
+            struct timeval tv, *ptv = NULL;
             struct timezone tz, *ptz = NULL;
 
-            if (copy_from_user_timeval(&tv, arg1))
-                goto efault;
+            if (arg1) {
+                if (copy_from_user_timeval(&tv, arg1)) {
+                    goto efault;
+                }
+                ptv = &tv;
+            }
 
             if (arg2) {
                 if (copy_from_user_timezone(&tz, arg2)) {
@@ -6414,7 +6418,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                 ptz = &tz;
             }
 
-            ret = get_errno(settimeofday(&tv, ptz));
+            ret = get_errno(settimeofday(ptv, ptz));
         }
         break;
 #if defined(TARGET_NR_select)
-- 
2.0.0

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

* [Qemu-devel] [PULL 13/19] linux-user: support timerfd_{create, gettime, settime} syscalls
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (11 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 12/19] linux-user: allow NULL tv argument " riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 14/19] linux-user: support ioprio_{get, set} syscalls riku.voipio
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Adds support for the timerfd_create, timerfd_gettime & timerfd_settime
syscalls, allowing use of timerfds by target programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/strace.list |  9 +++++++++
 linux-user/syscall.c   | 45 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index fcb258d..8de972a 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1404,6 +1404,15 @@
 #ifdef TARGET_NR_timer_settime
 { TARGET_NR_timer_settime, "timer_settime" , NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_timerfd_create
+{ TARGET_NR_timerfd_create, "timerfd_create" , NULL, NULL, NULL },
+#endif
+#ifdef TARGET_NR_timerfd_gettime
+{ TARGET_NR_timerfd_gettime, "timerfd_gettime" , NULL, NULL, NULL },
+#endif
+#ifdef TARGET_NR_timerfd_settime
+{ TARGET_NR_timerfd_settime, "timerfd_settime" , NULL, NULL, NULL },
+#endif
 #ifdef TARGET_NR_times
 { TARGET_NR_times, "times" , NULL, NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 8e2762b..ca38147 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -58,6 +58,7 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
 #include <sys/shm.h>
 #include <sys/sem.h>
 #include <sys/statfs.h>
+#include <sys/timerfd.h>
 #include <utime.h>
 #include <sys/sysinfo.h>
 //#include <sys/user.h>
@@ -9491,6 +9492,50 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
     }
 #endif
 
+#ifdef TARGET_NR_timerfd_create
+    case TARGET_NR_timerfd_create:
+        ret = get_errno(timerfd_create(arg1,
+                target_to_host_bitmask(arg2, fcntl_flags_tbl)));
+        break;
+#endif
+
+#ifdef TARGET_NR_timerfd_gettime
+    case TARGET_NR_timerfd_gettime:
+        {
+            struct itimerspec its_curr;
+
+            ret = get_errno(timerfd_gettime(arg1, &its_curr));
+
+            if (arg2 && host_to_target_itimerspec(arg2, &its_curr)) {
+                goto efault;
+            }
+        }
+        break;
+#endif
+
+#ifdef TARGET_NR_timerfd_settime
+    case TARGET_NR_timerfd_settime:
+        {
+            struct itimerspec its_new, its_old, *p_new;
+
+            if (arg3) {
+                if (target_to_host_itimerspec(&its_new, arg3)) {
+                    goto efault;
+                }
+                p_new = &its_new;
+            } else {
+                p_new = NULL;
+            }
+
+            ret = get_errno(timerfd_settime(arg1, arg2, p_new, &its_old));
+
+            if (arg4 && host_to_target_itimerspec(arg4, &its_old)) {
+                goto efault;
+            }
+        }
+        break;
+#endif
+
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
-- 
2.0.0

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

* [Qemu-devel] [PULL 14/19] linux-user: support ioprio_{get, set} syscalls
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (12 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 13/19] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 15/19] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add support for the ioprio_get & ioprio_set syscalls, allowing their
use by target programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ca38147..c70b3b0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -252,6 +252,12 @@ _syscall2(int, capget, struct __user_cap_header_struct *, header,
           struct __user_cap_data_struct *, data);
 _syscall2(int, capset, struct __user_cap_header_struct *, header,
           struct __user_cap_data_struct *, data);
+#if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)
+_syscall2(int, ioprio_get, int, which, int, who)
+#endif
+#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
+_syscall3(int, ioprio_set, int, which, int, who, int, ioprio)
+#endif
 
 static bitmask_transtbl fcntl_flags_tbl[] = {
   { TARGET_O_ACCMODE,   TARGET_O_WRONLY,    O_ACCMODE,   O_WRONLY,    },
@@ -9536,6 +9542,18 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
 
+#if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)
+    case TARGET_NR_ioprio_get:
+        ret = get_errno(ioprio_get(arg1, arg2));
+        break;
+#endif
+
+#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
+    case TARGET_NR_ioprio_set:
+        ret = get_errno(ioprio_set(arg1, arg2, arg3));
+        break;
+#endif
+
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
-- 
2.0.0

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

* [Qemu-devel] [PULL 15/19] linux-user: support {name_to, open_by}_handle_at syscalls
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (13 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 14/19] linux-user: support ioprio_{get, set} syscalls riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 16/19] linux-user: support the setns syscall riku.voipio
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Implement support for the name_to_handle_at and open_by_handle_at
syscalls, allowing their use by the target program.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/strace.c    | 30 ++++++++++++++++++++++++++
 linux-user/strace.list |  6 ++++++
 linux-user/syscall.c   | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 93 insertions(+)

diff --git a/linux-user/strace.c b/linux-user/strace.c
index ea6c1d2..c20ddf1 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1552,6 +1552,36 @@ print_kill(const struct syscallname *name,
 }
 #endif
 
+#ifdef TARGET_NR_name_to_handle_at
+static void
+print_name_to_handle_at(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_at_dirfd(arg0, 0);
+    print_string(arg1, 0);
+    print_pointer(arg2, 0);
+    print_pointer(arg3, 0);
+    print_raw_param("0x%x", arg4, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
+#ifdef TARGET_NR_open_by_handle_at
+static void
+print_open_by_handle_at(const struct syscallname *name,
+    abi_long arg0, abi_long arg1, abi_long arg2,
+    abi_long arg3, abi_long arg4, abi_long arg5)
+{
+    print_syscall_prologue(name);
+    print_raw_param("%d", arg0, 0);
+    print_pointer(arg2, 0);
+    print_open_flags(arg3, 1);
+    print_syscall_epilogue(name);
+}
+#endif
+
 /*
  * An array of all of the syscalls we know about
  */
diff --git a/linux-user/strace.list b/linux-user/strace.list
index 8de972a..147f579 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -582,6 +582,9 @@
 #ifdef TARGET_NR_munmap
 { TARGET_NR_munmap, "munmap" , NULL, print_munmap, NULL },
 #endif
+#ifdef TARGET_NR_name_to_handle_at
+{ TARGET_NR_name_to_handle_at, "name_to_handle_at" , NULL, print_name_to_handle_at, NULL },
+#endif
 #ifdef TARGET_NR_nanosleep
 { TARGET_NR_nanosleep, "nanosleep" , NULL, NULL, NULL },
 #endif
@@ -624,6 +627,9 @@
 #ifdef TARGET_NR_openat
 { TARGET_NR_openat, "openat" , NULL, print_openat, NULL },
 #endif
+#ifdef TARGET_NR_open_by_handle_at
+{ TARGET_NR_open_by_handle_at, "open_by_handle_at" , NULL, print_open_by_handle_at, NULL },
+#endif
 #ifdef TARGET_NR_osf_adjtime
 { TARGET_NR_osf_adjtime, "osf_adjtime" , NULL, NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c70b3b0..3fd0974 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5399,6 +5399,63 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         unlock_user(p, arg2, 0);
         break;
 #endif
+#ifdef TARGET_NR_name_to_handle_at
+    case TARGET_NR_name_to_handle_at:
+        {
+            struct file_handle *fh;
+            uint32_t sz;
+            int mount_id;
+
+            p = lock_user_string(arg2);
+            if (!p) {
+                goto efault;
+            }
+
+            if (get_user_u32(sz, arg3)) {
+                unlock_user(p, arg2, 0);
+                goto efault;
+            }
+
+            fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1);
+            if (!fh) {
+                unlock_user(p, arg2, 0);
+                goto efault;
+            }
+
+            ret = get_errno(name_to_handle_at(arg1, path(p), fh,
+                                              &mount_id, arg5));
+
+            unlock_user(p, arg2, 0);
+            unlock_user(p, arg3, sizeof(*fh) + sz);
+
+            if (put_user_s32(mount_id, arg4)) {
+                goto efault;
+            }
+        }
+        break;
+#endif
+#ifdef TARGET_NR_open_by_handle_at
+    case TARGET_NR_open_by_handle_at:
+        {
+            struct file_handle *fh;
+            uint32_t sz;
+
+            if (get_user_u32(sz, arg2)) {
+                goto efault;
+            }
+
+            fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1);
+            if (!fh) {
+                goto efault;
+            }
+
+            ret = get_errno(open_by_handle_at(arg1, fh,
+                    target_to_host_bitmask(arg3, fcntl_flags_tbl)));
+
+            unlock_user(p, arg2, sizeof(*fh) + sz);
+        }
+        break;
+#endif
     case TARGET_NR_close:
         ret = get_errno(close(arg1));
         break;
-- 
2.0.0

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

* [Qemu-devel] [PULL 16/19] linux-user: support the setns syscall
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (14 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 15/19] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 17/19] linux-user: support the unshare syscall riku.voipio
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add support for the setns syscall, trivially passed through to the host.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/strace.list | 3 +++
 linux-user/syscall.c   | 6 ++++++
 2 files changed, 9 insertions(+)

diff --git a/linux-user/strace.list b/linux-user/strace.list
index 147f579..d5b8033 100644
--- a/linux-user/strace.list
+++ b/linux-user/strace.list
@@ -1191,6 +1191,9 @@
 #ifdef TARGET_NR_set_mempolicy
 { TARGET_NR_set_mempolicy, "set_mempolicy" , NULL, NULL, NULL },
 #endif
+#ifdef TARGET_NR_setns
+{ TARGET_NR_setns, "setns" , NULL, NULL, NULL },
+#endif
 #ifdef TARGET_NR_setpgid
 { TARGET_NR_setpgid, "setpgid" , NULL, NULL, NULL },
 #endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3fd0974..ecd5be9 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9611,6 +9611,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
 
+#ifdef TARGET_NR_setns
+    case TARGET_NR_setns:
+        ret = get_errno(setns(arg1, arg2));
+        break;
+#endif
+
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
-- 
2.0.0

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

* [Qemu-devel] [PULL 17/19] linux-user: support the unshare syscall
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (15 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 16/19] linux-user: support the setns syscall riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 18/19] linux-user: support the KDSIGACCEPT ioctl riku.voipio
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add support for the unshare syscall, trivially passed through to the
host.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/syscall.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ecd5be9..769c661 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9617,6 +9617,12 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
 #endif
 
+#ifdef TARGET_NR_unshare
+    case TARGET_NR_unshare:
+        ret = get_errno(unshare(arg1));
+        break;
+#endif
+
     default:
     unimplemented:
         gemu_log("qemu: Unsupported syscall: %d\n", num);
-- 
2.0.0

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

* [Qemu-devel] [PULL 18/19] linux-user: support the KDSIGACCEPT ioctl
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (16 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 17/19] linux-user: support the unshare syscall riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 13:26 ` [Qemu-devel] [PULL 19/19] linux-user: support the SIOCGIFINDEX ioctl riku.voipio
  2014-06-23 17:26 ` [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add a definition of the KDSIGACCEPT ioctl & allow its use by target
programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/ioctls.h       | 1 +
 linux-user/syscall.c      | 7 +++++++
 linux-user/syscall_defs.h | 1 +
 3 files changed, 9 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index 309fb21..f278d3e 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -64,6 +64,7 @@
      IOCTL(KDSKBLED, 0, TYPE_INT)
      IOCTL(KDGETLED, 0, TYPE_INT)
      IOCTL(KDSETLED, 0, TYPE_INT)
+     IOCTL_SPECIAL(KDSIGACCEPT, 0, do_ioctl_kdsigaccept, TYPE_INT)
 
      IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
      IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 769c661..c4dbe4f 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3696,6 +3696,13 @@ static abi_long do_ioctl_rt(const IOCTLEntry *ie, uint8_t *buf_temp,
     return ret;
 }
 
+static abi_long do_ioctl_kdsigaccept(const IOCTLEntry *ie, uint8_t *buf_temp,
+                                     int fd, abi_long cmd, abi_long arg)
+{
+    int sig = target_to_host_signal(arg);
+    return get_errno(ioctl(fd, ie->host_cmd, sig));
+}
+
 static IOCTLEntry ioctl_entries[] = {
 #define IOCTL(cmd, access, ...) \
     { TARGET_ ## cmd, cmd, #cmd, access, 0, {  __VA_ARGS__ } },
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index a1f1fce..4adfd3a 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -831,6 +831,7 @@ struct target_pollfd {
 #define TARGET_KDSKBLED        0x4B65	/* set led flags (not lights) */
 #define TARGET_KDGETLED        0x4B31	/* return current led state */
 #define TARGET_KDSETLED        0x4B32	/* set led state [lights, not flags] */
+#define TARGET_KDSIGACCEPT     0x4B4E
 
 #define TARGET_SIOCATMARK      0x8905
 
-- 
2.0.0

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

* [Qemu-devel] [PULL 19/19] linux-user: support the SIOCGIFINDEX ioctl
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (17 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 18/19] linux-user: support the KDSIGACCEPT ioctl riku.voipio
@ 2014-06-23 13:26 ` riku.voipio
  2014-06-23 17:26 ` [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: riku.voipio @ 2014-06-23 13:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: Paul Burton

From: Paul Burton <paul@archlinuxmips.org>

Add a definition of the SIOCGIFINDEX ioctl, allowing its use by target
programs.

Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
 linux-user/ioctls.h       | 1 +
 linux-user/syscall_defs.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/linux-user/ioctls.h b/linux-user/ioctls.h
index f278d3e..07a00da 100644
--- a/linux-user/ioctls.h
+++ b/linux-user/ioctls.h
@@ -118,6 +118,7 @@
   IOCTL(SIOCSIFMEM, IOC_W, MK_PTR(MK_STRUCT(STRUCT_ptr_ifreq)))
   IOCTL(SIOCADDMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
   IOCTL(SIOCDELMULTI, IOC_W, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
+  IOCTL(SIOCGIFINDEX, IOC_W | IOC_R, MK_PTR(MK_STRUCT(STRUCT_sockaddr_ifreq)))
   IOCTL(SIOCSIFLINK, 0, TYPE_NULL)
   IOCTL_SPECIAL(SIOCGIFCONF, IOC_W | IOC_R, do_ioctl_ifconf,
                 MK_PTR(MK_STRUCT(STRUCT_ifconf)))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 4adfd3a..8563027 100644
--- a/linux-user/syscall_defs.h
+++ b/linux-user/syscall_defs.h
@@ -865,6 +865,7 @@ struct target_pollfd {
 #define TARGET_SIOCSIFSLAVE    0x8930
 #define TARGET_SIOCADDMULTI    0x8931          /* Multicast address lists      */
 #define TARGET_SIOCDELMULTI    0x8932
+#define TARGET_SIOCGIFINDEX    0x8933
 
 /* Bridging control calls */
 #define TARGET_SIOCGIFBR       0x8940          /* Bridging support             */
-- 
2.0.0

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

* Re: [Qemu-devel] [PULL 00/19] linux-user changes for 2.1
  2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
                   ` (18 preceding siblings ...)
  2014-06-23 13:26 ` [Qemu-devel] [PULL 19/19] linux-user: support the SIOCGIFINDEX ioctl riku.voipio
@ 2014-06-23 17:26 ` Peter Maydell
  19 siblings, 0 replies; 21+ messages in thread
From: Peter Maydell @ 2014-06-23 17:26 UTC (permalink / raw)
  To: Riku Voipio; +Cc: QEMU Developers

On 23 June 2014 14:26,  <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> The following changes since commit d9c1647d896d3192cba9dbf98fb7efab876edde5:
>
>   Merge remote-tracking branch 'remotes/stefanha/tags/block-pull-request' into staging (2014-06-23 12:55:22 +0100)
>
> are available in the git repository at:
>
>   git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream
>
> for you to fetch changes up to 1f1fb45ffe2a67bc1853b55b1d029fcee37d546a:
>
>   linux-user: support the SIOCGIFINDEX ioctl (2014-06-23 16:00:23 +0300)

Hi; I'm afraid this fails to build on my 32-bit
ARM host:

  CC    aarch64-linux-user/linux-user/syscall.o
/root/qemu/linux-user/syscall.c: In function ‘do_syscall’:
/root/qemu/linux-user/syscall.c:5462:24: error: ‘p’ may be used
uninitialized in this function [-Werror=uninitialized]
cc1: all warnings being treated as errors

Looks like we call fh = lock_user(...) but then use
the wrong variable in the unlock_user() call.

(No idea why this only fails on this machine and
not on x86-64...)

thanks
-- PMM

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

end of thread, other threads:[~2014-06-23 17:26 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-06-23 13:26 [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 01/19] Add support for MAP_NORESERVE mmap flag riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 02/19] Add support for the arm breakpoint syscall riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 03/19] linux-user: added fake open() for /proc/self/cmdline riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 04/19] linux-user: translate the result of getsockopt SO_TYPE riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 05/19] linux-user: support SO_ACCEPTCONN getsockopt option riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 06/19] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 07/19] linux-user: support SO_PASSSEC setsockopt option riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 08/19] linux-user: allow NULL arguments to mount riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 09/19] linux-user: support strace of epoll_create1 riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 10/19] linux-user: fix struct target_epoll_event layout for MIPS riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 11/19] linux-user: respect timezone for settimeofday riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 12/19] linux-user: allow NULL tv argument " riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 13/19] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 14/19] linux-user: support ioprio_{get, set} syscalls riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 15/19] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 16/19] linux-user: support the setns syscall riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 17/19] linux-user: support the unshare syscall riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 18/19] linux-user: support the KDSIGACCEPT ioctl riku.voipio
2014-06-23 13:26 ` [Qemu-devel] [PULL 19/19] linux-user: support the SIOCGIFINDEX ioctl riku.voipio
2014-06-23 17:26 ` [Qemu-devel] [PULL 00/19] linux-user changes for 2.1 Peter Maydell

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).