* [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements
@ 2014-06-15 16:18 Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE Paul Burton
` (17 more replies)
0 siblings, 18 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
This series fixes a number of bugs in QEMUs linux-user support, some
specific to targetting the MIPS architecture but mostly generic. It also
adds support for some previously unsupported syscalls & {g,s}etsockopt
options.
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
linux-user/ioctls.h | 2 +
linux-user/socket.h | 2 +
linux-user/strace.c | 30 +++++
linux-user/strace.list | 21 ++++
linux-user/syscall.c | 273 +++++++++++++++++++++++++++++++++++++++++-----
linux-user/syscall_defs.h | 9 +-
6 files changed, 310 insertions(+), 27 deletions(-)
--
2.0.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-21 9:39 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 02/16] linux-user: support SO_ACCEPTCONN getsockopt option Paul Burton
` (16 subsequent siblings)
17 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/syscall.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6efeeff..3921cff 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -592,6 +592,35 @@ 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;
@@ -1526,6 +1555,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
abi_long ret;
int len, val;
socklen_t lv;
+ int (*translate_result)(int val) = NULL;
switch(level) {
case TARGET_SOL_SOCKET:
@@ -1578,6 +1608,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
optname = SO_REUSEADDR;
goto int_case;
case TARGET_SO_TYPE:
+ translate_result = host_to_target_sock_type;
optname = SO_TYPE;
goto int_case;
case TARGET_SO_ERROR:
@@ -1636,6 +1667,8 @@ 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 (translate_result)
+ val = translate_result(val);
if (len > lv)
len = lv;
if (len == 4) {
--
2.0.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 02/16] linux-user: support SO_ACCEPTCONN getsockopt option
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 03/16] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options Paul Burton
` (15 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Translate the SO_ACCEPTCONN option to the host value & execute the
syscall as expected.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
---
linux-user/syscall.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3921cff..e6afd30 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] 29+ messages in thread
* [Qemu-devel] [PATCH 03/16] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 02/16] linux-user: support SO_ACCEPTCONN getsockopt option Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option Paul Burton
` (14 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/syscall.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e6afd30..679d165 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1500,9 +1500,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] 29+ messages in thread
* [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (2 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 03/16] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-21 10:59 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 05/16] linux-user: allow NULL arguments to mount Paul Burton
` (13 subsequent siblings)
17 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/socket.h | 2 ++
linux-user/syscall.c | 3 +++
2 files changed, 5 insertions(+)
diff --git a/linux-user/socket.h b/linux-user/socket.h
index ae17959..289c6ac 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
*
@@ -298,6 +299,7 @@
#define TARGET_SO_ACCEPTCONN 30
#define TARGET_SO_PEERSEC 31
+ #define TARGET_SO_PASSSEC 34
#endif
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 679d165..b507f81 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1529,6 +1529,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] 29+ messages in thread
* [Qemu-devel] [PATCH 05/16] linux-user: allow NULL arguments to mount
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (3 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 06/16] linux-user: support strace of epoll_create1 Paul Burton
` (12 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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 for good measure.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
---
linux-user/syscall.c | 68 +++++++++++++++++++++++++++++++++++-----------------
1 file changed, 46 insertions(+), 22 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index b507f81..2dc7ca3 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5565,29 +5565,53 @@ 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 = get_errno(mount(p, p2, p3, (unsigned long)arg4, NULL));
+ else
+ ret = get_errno(mount(p, p2, p3, (unsigned long)arg4, g2h(arg5)));
+
+ 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] 29+ messages in thread
* [Qemu-devel] [PATCH 06/16] linux-user: support strace of epoll_create1
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (4 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 05/16] linux-user: allow NULL arguments to mount Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS Paul Burton
` (11 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
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] 29+ messages in thread
* [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (5 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 06/16] linux-user: support strace of epoll_create1 Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-21 11:02 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 08/16] linux-user: respect timezone for settimeofday Paul Burton
` (10 subsequent siblings)
17 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
MIPS requires the pad field to 64b-align the data field just as ARM
does.
Signed-off-by: Paul Burton <paul@archlinuxmips.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..9fcb723 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)
uint32_t __pad;
#endif
target_epoll_data_t data;
--
2.0.0
^ permalink raw reply related [flat|nested] 29+ messages in thread
* [Qemu-devel] [PATCH 08/16] linux-user: respect timezone for settimeofday
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (6 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 09/16] linux-user: allow NULL tv argument " Paul Burton
` (9 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/syscall.c | 27 ++++++++++++++++++++++++++-
linux-user/syscall_defs.h | 5 +++++
2 files changed, 31 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 2dc7ca3..d30dff8 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -933,6 +933,22 @@ 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>
@@ -6329,9 +6345,18 @@ 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 9fcb723..380e865 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] 29+ messages in thread
* [Qemu-devel] [PATCH 09/16] linux-user: allow NULL tv argument for settimeofday
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (7 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 08/16] linux-user: respect timezone for settimeofday Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 10/16] linux-user: support timerfd_{create, gettime, settime} syscalls Paul Burton
` (8 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/syscall.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d30dff8..8ebb9e7 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6344,11 +6344,14 @@ 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))
@@ -6356,7 +6359,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] 29+ messages in thread
* [Qemu-devel] [PATCH 10/16] linux-user: support timerfd_{create, gettime, settime} syscalls
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (8 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 09/16] linux-user: allow NULL tv argument " Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls Paul Burton
` (7 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/strace.list | 9 +++++++++
linux-user/syscall.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 53 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 8ebb9e7..0830205 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>
@@ -9416,6 +9417,49 @@ 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] 29+ messages in thread
* [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (9 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 10/16] linux-user: support timerfd_{create, gettime, settime} syscalls Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-20 12:54 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 12/16] linux-user: support {name_to, open_by}_handle_at syscalls Paul Burton
` (6 subsequent siblings)
17 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Add support for the ioprio_get & ioprio_set syscalls, allowing their
use by target programs.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
---
linux-user/syscall.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0830205..c7f176a 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);
+#ifdef __NR_ioprio_get
+_syscall2(int, ioprio_get, int, which, int, who)
+#endif
+#ifdef __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, },
@@ -9460,6 +9466,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] 29+ messages in thread
* [Qemu-devel] [PATCH 12/16] linux-user: support {name_to, open_by}_handle_at syscalls
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (10 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-08-26 12:30 ` [Qemu-devel] [12/16] " Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 13/16] linux-user: support the setns syscall Paul Burton
` (5 subsequent siblings)
17 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
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>
---
linux-user/strace.c | 30 ++++++++++++++++++++++++++++++
linux-user/strace.list | 6 ++++++
linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 86 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 c7f176a..192ad3a 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5349,6 +5349,56 @@ 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;
+
+ if (!(p = lock_user_string(arg2)))
+ goto efault;
+
+ if (get_user_u32(sz, arg3)) {
+ unlock_user(p, arg2, 0);
+ goto efault;
+ }
+
+ if (!(fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1))) {
+ 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;
+
+ if (!(fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1)))
+ 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] 29+ messages in thread
* [Qemu-devel] [PATCH 13/16] linux-user: support the setns syscall
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (11 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 12/16] linux-user: support {name_to, open_by}_handle_at syscalls Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 14/16] linux-user: support the unshare syscall Paul Burton
` (4 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Add support for the setns syscall, trivially passed through to the host.
Signed-off-by: Paul Burton <paul@archlinuxmips.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 192ad3a..208c6c4 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9528,6 +9528,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] 29+ messages in thread
* [Qemu-devel] [PATCH 14/16] linux-user: support the unshare syscall
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (12 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 13/16] linux-user: support the setns syscall Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 15/16] linux-user: support the KDSIGACCEPT ioctl Paul Burton
` (3 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Add support for the unshare syscall, trivially passed through to the
host.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
---
linux-user/syscall.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 208c6c4..5412b1e 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9534,6 +9534,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] 29+ messages in thread
* [Qemu-devel] [PATCH 15/16] linux-user: support the KDSIGACCEPT ioctl
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (13 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 14/16] linux-user: support the unshare syscall Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 16/16] linux-user: support the SIOCGIFINDEX ioctl Paul Burton
` (2 subsequent siblings)
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Add a definition of the KDSIGACCEPT ioctl & allow its use by target
programs.
Signed-off-by: Paul Burton <paul@archlinuxmips.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 309fb21..cd21e64 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(KDSIGACCEPT, 0, TYPE_INT)
IOCTL(BLKROSET, IOC_W, MK_PTR(TYPE_INT))
IOCTL(BLKROGET, IOC_R, MK_PTR(TYPE_INT))
diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h
index 380e865..4d35d54 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] 29+ messages in thread
* [Qemu-devel] [PATCH 16/16] linux-user: support the SIOCGIFINDEX ioctl
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (14 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 15/16] linux-user: support the KDSIGACCEPT ioctl Paul Burton
@ 2014-06-15 16:18 ` Paul Burton
2014-06-17 13:39 ` [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Riku Voipio
2014-06-21 11:11 ` Riku Voipio
17 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-15 16:18 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio, Paul Burton
Add a definition of the SIOCGIFINDEX ioctl, allowing its use by target
programs.
Signed-off-by: Paul Burton <paul@archlinuxmips.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 cd21e64..20551a8 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 4d35d54..9c7499c 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] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (15 preceding siblings ...)
2014-06-15 16:18 ` [Qemu-devel] [PATCH 16/16] linux-user: support the SIOCGIFINDEX ioctl Paul Burton
@ 2014-06-17 13:39 ` Riku Voipio
2014-06-21 11:11 ` Riku Voipio
17 siblings, 0 replies; 29+ messages in thread
From: Riku Voipio @ 2014-06-17 13:39 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
Hi,
On Sun, Jun 15, 2014 at 05:18:17PM +0100, Paul Burton wrote:
> This series fixes a number of bugs in QEMUs linux-user support, some
> specific to targetting the MIPS architecture but mostly generic. It also
> adds support for some previously unsupported syscalls & {g,s}etsockopt
> options.
This series looks great - I'll review throught patches soon,
first I need to get the current linux-user que upstream.
Riku
> 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
>
> linux-user/ioctls.h | 2 +
> linux-user/socket.h | 2 +
> linux-user/strace.c | 30 +++++
> linux-user/strace.list | 21 ++++
> linux-user/syscall.c | 273 +++++++++++++++++++++++++++++++++++++++++-----
> linux-user/syscall_defs.h | 9 +-
> 6 files changed, 310 insertions(+), 27 deletions(-)
>
> --
> 2.0.0
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls
2014-06-15 16:18 ` [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls Paul Burton
@ 2014-06-20 12:54 ` Riku Voipio
0 siblings, 0 replies; 29+ messages in thread
From: Riku Voipio @ 2014-06-20 12:54 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
On Sun, Jun 15, 2014 at 05:18:28PM +0100, Paul Burton wrote:
> Add support for the ioprio_get & ioprio_set syscalls, allowing their
> use by target programs.
>
> Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> ---
> linux-user/syscall.c | 18 ++++++++++++++++++
> 1 file changed, 18 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 0830205..c7f176a 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);
> +#ifdef __NR_ioprio_get
> +_syscall2(int, ioprio_get, int, which, int, who)
> +#endif
> +#ifdef __NR_ioprio_set
> +_syscall3(int, ioprio_set, int, which, int, who, int, ioprio)
> +#endif
Since this is only used if both host and guest, thes needs to be
protected by both TARGET_NR_ioprio_get and __NR_ioprio_get. Else we get
compile error on some targets:
qemu/linux-user/syscall.c:256:16: error: ‘ioprio_get’ defined but not used [-Werror=unused-function]
_syscall2(int, ioprio_get, int, which, int, who)
^
qemu/linux-user/syscall.c:147:13: note: in definition of macro ‘_syscall2’
static type name (type1 arg1,type2 arg2) \
^
> static bitmask_transtbl fcntl_flags_tbl[] = {
> { TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
> @@ -9460,6 +9466,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 [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE
2014-06-15 16:18 ` [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE Paul Burton
@ 2014-06-21 9:39 ` Riku Voipio
2014-06-21 17:39 ` Paul Burton
0 siblings, 1 reply; 29+ messages in thread
From: Riku Voipio @ 2014-06-21 9:39 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
On Sun, Jun 15, 2014 at 05:18:18PM +0100, Paul Burton wrote:
> 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>
> ---
> linux-user/syscall.c | 33 +++++++++++++++++++++++++++++++++
> 1 file changed, 33 insertions(+)
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 6efeeff..3921cff 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -592,6 +592,35 @@ 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;
> @@ -1526,6 +1555,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
> abi_long ret;
> int len, val;
> socklen_t lv;
> + int (*translate_result)(int val) = NULL;
>
> switch(level) {
> case TARGET_SOL_SOCKET:
> @@ -1578,6 +1608,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
> optname = SO_REUSEADDR;
> goto int_case;
> case TARGET_SO_TYPE:
> + translate_result = host_to_target_sock_type;
> optname = SO_TYPE;
> goto int_case;
> case TARGET_SO_ERROR:
> @@ -1636,6 +1667,8 @@ 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 (translate_result)
> + val = translate_result(val);
perhaps instead:
if (optname == SO_TYPE)
val = host_to_target_sock_type(val);
Then we avoid the need of function pointer.
> if (len > lv)
> len = lv;
> if (len == 4) {
> --
> 2.0.0
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option
2014-06-15 16:18 ` [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option Paul Burton
@ 2014-06-21 10:59 ` Riku Voipio
2014-06-21 17:46 ` Paul Burton
0 siblings, 1 reply; 29+ messages in thread
From: Riku Voipio @ 2014-06-21 10:59 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
On Sun, Jun 15, 2014 at 05:18:21PM +0100, Paul Burton wrote:
> Translate the SO_PASSSEC option to setsockopt to the host value &
> perform the syscall as expected, allowing use of the option by target
> programs.
Another file that is a total mess in linux-user tree.. This should be
split out to arch specific header files - but that's for another patch.
For this patch - the value for sparc SO_PASSEC should be set, since
it's different from others:
http://lxr.free-electrons.com/source/arch/sparc/include/uapi/asm/socket.h#L51
> Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> ---
> linux-user/socket.h | 2 ++
> linux-user/syscall.c | 3 +++
> 2 files changed, 5 insertions(+)
>
> diff --git a/linux-user/socket.h b/linux-user/socket.h
> index ae17959..289c6ac 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
> *
> @@ -298,6 +299,7 @@
> #define TARGET_SO_ACCEPTCONN 30
>
> #define TARGET_SO_PEERSEC 31
> + #define TARGET_SO_PASSSEC 34
>
> #endif
>
> diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> index 679d165..b507f81 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -1529,6 +1529,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 [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS
2014-06-15 16:18 ` [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS Paul Burton
@ 2014-06-21 11:02 ` Riku Voipio
2014-06-21 18:04 ` Paul Burton
0 siblings, 1 reply; 29+ messages in thread
From: Riku Voipio @ 2014-06-21 11:02 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
On Sun, Jun 15, 2014 at 05:18:24PM +0100, Paul Burton wrote:
> MIPS requires the pad field to 64b-align the data field just as ARM
> does.
Is this true for the 64bit mips also?
> Signed-off-by: Paul Burton <paul@archlinuxmips.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..9fcb723 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)
> uint32_t __pad;
> #endif
> target_epoll_data_t data;
> --
> 2.0.0
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
` (16 preceding siblings ...)
2014-06-17 13:39 ` [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Riku Voipio
@ 2014-06-21 11:11 ` Riku Voipio
17 siblings, 0 replies; 29+ messages in thread
From: Riku Voipio @ 2014-06-21 11:11 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
On Sun, Jun 15, 2014 at 05:18:17PM +0100, Paul Burton wrote:
> This series fixes a number of bugs in QEMUs linux-user support, some
> specific to targetting the MIPS architecture but mostly generic. It also
> adds support for some previously unsupported syscalls & {g,s}etsockopt
> options.
Apart from the patches I commented to, I think the rest are good to go.
Thanks for helping with linux-user,
Riku
> 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
>
> linux-user/ioctls.h | 2 +
> linux-user/socket.h | 2 +
> linux-user/strace.c | 30 +++++
> linux-user/strace.list | 21 ++++
> linux-user/syscall.c | 273 +++++++++++++++++++++++++++++++++++++++++-----
> linux-user/syscall_defs.h | 9 +-
> 6 files changed, 310 insertions(+), 27 deletions(-)
>
> --
> 2.0.0
>
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE
2014-06-21 9:39 ` Riku Voipio
@ 2014-06-21 17:39 ` Paul Burton
0 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-21 17:39 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Paul Burton
[-- Attachment #1: Type: text/plain, Size: 1286 bytes --]
On Sat, Jun 21, 2014 at 12:39:12PM +0300, Riku Voipio wrote:
> > @@ -1526,6 +1555,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
> > abi_long ret;
> > int len, val;
> > socklen_t lv;
> > + int (*translate_result)(int val) = NULL;
> >
> > switch(level) {
> > case TARGET_SOL_SOCKET:
> > @@ -1578,6 +1608,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname,
> > optname = SO_REUSEADDR;
> > goto int_case;
> > case TARGET_SO_TYPE:
> > + translate_result = host_to_target_sock_type;
> > optname = SO_TYPE;
> > goto int_case;
> > case TARGET_SO_ERROR:
> > @@ -1636,6 +1667,8 @@ 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 (translate_result)
> > + val = translate_result(val);
>
> perhaps instead:
>
> if (optname == SO_TYPE)
> val = host_to_target_sock_type(val);
>
> Then we avoid the need of function pointer.
Fair enough, perhaps I was making it too generic for my own good :)
Thanks,
Paul
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option
2014-06-21 10:59 ` Riku Voipio
@ 2014-06-21 17:46 ` Paul Burton
0 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-21 17:46 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Paul Burton
[-- Attachment #1: Type: text/plain, Size: 2118 bytes --]
On Sat, Jun 21, 2014 at 01:59:33PM +0300, Riku Voipio wrote:
> On Sun, Jun 15, 2014 at 05:18:21PM +0100, Paul Burton wrote:
> > Translate the SO_PASSSEC option to setsockopt to the host value &
> > perform the syscall as expected, allowing use of the option by target
> > programs.
>
> Another file that is a total mess in linux-user tree.. This should be
> split out to arch specific header files - but that's for another patch.
> For this patch - the value for sparc SO_PASSEC should be set, since
> it's different from others:
>
> http://lxr.free-electrons.com/source/arch/sparc/include/uapi/asm/socket.h#L51
Good catch, and it looks like the same is true of some other already
incorrect options for sparc (SO_PEERSEC, SO_BINDTODEVICE at least at a
glance).
Paul
>
> > Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> > ---
> > linux-user/socket.h | 2 ++
> > linux-user/syscall.c | 3 +++
> > 2 files changed, 5 insertions(+)
> >
> > diff --git a/linux-user/socket.h b/linux-user/socket.h
> > index ae17959..289c6ac 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
> > *
> > @@ -298,6 +299,7 @@
> > #define TARGET_SO_ACCEPTCONN 30
> >
> > #define TARGET_SO_PEERSEC 31
> > + #define TARGET_SO_PASSSEC 34
> >
> > #endif
> >
> > diff --git a/linux-user/syscall.c b/linux-user/syscall.c
> > index 679d165..b507f81 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -1529,6 +1529,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
> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS
2014-06-21 11:02 ` Riku Voipio
@ 2014-06-21 18:04 ` Paul Burton
0 siblings, 0 replies; 29+ messages in thread
From: Paul Burton @ 2014-06-21 18:04 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel, Paul Burton
[-- Attachment #1: Type: text/plain, Size: 949 bytes --]
On Sat, Jun 21, 2014 at 02:02:55PM +0300, Riku Voipio wrote:
> On Sun, Jun 15, 2014 at 05:18:24PM +0100, Paul Burton wrote:
> > MIPS requires the pad field to 64b-align the data field just as ARM
> > does.
>
> Is this true for the 64bit mips also?
It appears so, good catch :)
Paul
> > Signed-off-by: Paul Burton <paul@archlinuxmips.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..9fcb723 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)
> > uint32_t __pad;
> > #endif
> > target_epoll_data_t data;
> > --
> > 2.0.0
> >
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [12/16] linux-user: support {name_to, open_by}_handle_at syscalls
2014-06-15 16:18 ` [Qemu-devel] [PATCH 12/16] linux-user: support {name_to, open_by}_handle_at syscalls Paul Burton
@ 2014-08-26 12:30 ` Riku Voipio
2014-08-26 14:21 ` Paul Burton
0 siblings, 1 reply; 29+ messages in thread
From: Riku Voipio @ 2014-08-26 12:30 UTC (permalink / raw)
To: Paul Burton; +Cc: qemu-devel
Hi Paul,
On Sun, Jun 15, 2014 at 05:18:29PM +0100, Paul Burton wrote:
> Implement support for the name_to_handle_at and open_by_handle_at
> syscalls, allowing their use by the target program.
What was your testcase for these syscalls? I usually use LTP for testing
syscalls, but there is no testcase for name_to_handle_at and
open_by_handle_at.
Riku
> Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> ---
> linux-user/strace.c | 30 ++++++++++++++++++++++++++++++
> linux-user/strace.list | 6 ++++++
> linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 86 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 c7f176a..192ad3a 100644
> --- a/linux-user/syscall.c
> +++ b/linux-user/syscall.c
> @@ -5349,6 +5349,56 @@ 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;
> +
> + if (!(p = lock_user_string(arg2)))
> + goto efault;
> +
> + if (get_user_u32(sz, arg3)) {
> + unlock_user(p, arg2, 0);
> + goto efault;
> + }
> +
> + if (!(fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1))) {
> + 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;
> +
> + if (!(fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1)))
> + 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;
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [12/16] linux-user: support {name_to, open_by}_handle_at syscalls
2014-08-26 12:30 ` [Qemu-devel] [12/16] " Riku Voipio
@ 2014-08-26 14:21 ` Paul Burton
2014-08-28 7:10 ` Riku Voipio
0 siblings, 1 reply; 29+ messages in thread
From: Paul Burton @ 2014-08-26 14:21 UTC (permalink / raw)
To: Riku Voipio; +Cc: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 5789 bytes --]
On Tue, Aug 26, 2014 at 03:30:41PM +0300, Riku Voipio wrote:
> Hi Paul,
>
> On Sun, Jun 15, 2014 at 05:18:29PM +0100, Paul Burton wrote:
> > Implement support for the name_to_handle_at and open_by_handle_at
> > syscalls, allowing their use by the target program.
>
> What was your testcase for these syscalls? I usually use LTP for testing
> syscalls, but there is no testcase for name_to_handle_at and
> open_by_handle_at.
Hi Riku,
First thanks for taking care of a whole bunch of these patches, and my
apologies for not being around or responsive! Meatspace has been keeping
me busy, but has calmed down for now so I should be able to find more
time to contribute :)
Actually my test for these was that a mipsel systemd could boot from
init through to a login prompt inside a container on my x86-64 host
using QEMU via binfmt_misc. That does however also require a few more
patches which I need to clean up before submitting. But you can find
them here in the short term if you're interested:
https://github.com/Arch-Linux-MIPS/qemu
Paul
> Riku
>
> > Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> > ---
> > linux-user/strace.c | 30 ++++++++++++++++++++++++++++++
> > linux-user/strace.list | 6 ++++++
> > linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > 3 files changed, 86 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 c7f176a..192ad3a 100644
> > --- a/linux-user/syscall.c
> > +++ b/linux-user/syscall.c
> > @@ -5349,6 +5349,56 @@ 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;
> > +
> > + if (!(p = lock_user_string(arg2)))
> > + goto efault;
> > +
> > + if (get_user_u32(sz, arg3)) {
> > + unlock_user(p, arg2, 0);
> > + goto efault;
> > + }
> > +
> > + if (!(fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1))) {
> > + 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;
> > +
> > + if (!(fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1)))
> > + 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;
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
^ permalink raw reply [flat|nested] 29+ messages in thread
* Re: [Qemu-devel] [12/16] linux-user: support {name_to, open_by}_handle_at syscalls
2014-08-26 14:21 ` Paul Burton
@ 2014-08-28 7:10 ` Riku Voipio
0 siblings, 0 replies; 29+ messages in thread
From: Riku Voipio @ 2014-08-28 7:10 UTC (permalink / raw)
To: Paul Burton; +Cc: Riku Voipio, qemu-devel
Hi,
On Tue, Aug 26, 2014 at 03:21:30PM +0100, Paul Burton wrote:
> On Tue, Aug 26, 2014 at 03:30:41PM +0300, Riku Voipio wrote:
> > On Sun, Jun 15, 2014 at 05:18:29PM +0100, Paul Burton wrote:
> > > Implement support for the name_to_handle_at and open_by_handle_at
> > > syscalls, allowing their use by the target program.
> >
> > What was your testcase for these syscalls? I usually use LTP for testing
> > syscalls, but there is no testcase for name_to_handle_at and
> > open_by_handle_at.
> First thanks for taking care of a whole bunch of these patches, and my
> apologies for not being around or responsive! Meatspace has been keeping
> me busy, but has calmed down for now so I should be able to find more
> time to contribute :)
> Actually my test for these was that a mipsel systemd could boot from
> init through to a login prompt inside a container on my x86-64 host
> using QEMU via binfmt_misc. That does however also require a few more
> patches which I need to clean up before submitting. But you can find
> them here in the short term if you're interested:
> https://github.com/Arch-Linux-MIPS/qemu
Ok, a good start would probably be just to rebase your changes against
current qemu head, and then send them for review - they don't need be
polished patches for first round.
Systemd booting in binfmt_misc container would be a nice additional
feature to target for the next Qemu release (2.2).
Riku
> Paul
>
> > Riku
> >
> > > Signed-off-by: Paul Burton <paul@archlinuxmips.org>
> > > ---
> > > linux-user/strace.c | 30 ++++++++++++++++++++++++++++++
> > > linux-user/strace.list | 6 ++++++
> > > linux-user/syscall.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
> > > 3 files changed, 86 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 c7f176a..192ad3a 100644
> > > --- a/linux-user/syscall.c
> > > +++ b/linux-user/syscall.c
> > > @@ -5349,6 +5349,56 @@ 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;
> > > +
> > > + if (!(p = lock_user_string(arg2)))
> > > + goto efault;
> > > +
> > > + if (get_user_u32(sz, arg3)) {
> > > + unlock_user(p, arg2, 0);
> > > + goto efault;
> > > + }
> > > +
> > > + if (!(fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1))) {
> > > + 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;
> > > +
> > > + if (!(fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1)))
> > > + 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;
^ permalink raw reply [flat|nested] 29+ messages in thread
end of thread, other threads:[~2014-08-28 7:10 UTC | newest]
Thread overview: 29+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-15 16:18 [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 01/16] linux-user: translate the result of getsockopt SO_TYPE Paul Burton
2014-06-21 9:39 ` Riku Voipio
2014-06-21 17:39 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 02/16] linux-user: support SO_ACCEPTCONN getsockopt option Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 03/16] linux-user: support SO_{SND, RCV}BUFFORCE setsockopt options Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 04/16] linux-user: support SO_PASSSEC setsockopt option Paul Burton
2014-06-21 10:59 ` Riku Voipio
2014-06-21 17:46 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 05/16] linux-user: allow NULL arguments to mount Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 06/16] linux-user: support strace of epoll_create1 Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 07/16] linux-user: fix struct target_epoll_event layout for MIPS Paul Burton
2014-06-21 11:02 ` Riku Voipio
2014-06-21 18:04 ` Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 08/16] linux-user: respect timezone for settimeofday Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 09/16] linux-user: allow NULL tv argument " Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 10/16] linux-user: support timerfd_{create, gettime, settime} syscalls Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 11/16] linux-user: support ioprio_{get, set} syscalls Paul Burton
2014-06-20 12:54 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 12/16] linux-user: support {name_to, open_by}_handle_at syscalls Paul Burton
2014-08-26 12:30 ` [Qemu-devel] [12/16] " Riku Voipio
2014-08-26 14:21 ` Paul Burton
2014-08-28 7:10 ` Riku Voipio
2014-06-15 16:18 ` [Qemu-devel] [PATCH 13/16] linux-user: support the setns syscall Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 14/16] linux-user: support the unshare syscall Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 15/16] linux-user: support the KDSIGACCEPT ioctl Paul Burton
2014-06-15 16:18 ` [Qemu-devel] [PATCH 16/16] linux-user: support the SIOCGIFINDEX ioctl Paul Burton
2014-06-17 13:39 ` [Qemu-devel] [PATCH 00/16] linux-user fixes & improvements Riku Voipio
2014-06-21 11:11 ` Riku Voipio
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.