* [Qemu-devel] [PULL] linux-user updates
@ 2013-03-11 19:27 riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 01/11] linux-user: Add Alpha socket constants riku.voipio
` (12 more replies)
0 siblings, 13 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
Hi,
This is my patch queue for linux-user. Please pull.
The following changes since commit fa3889162ff724d09eb6b6bd06ba54769100a77f:
Merge remote-tracking branch 'origin/master' into staging (2013-03-10 20:39:17 -0500)
are available in the git repository at:
git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream
Dillon Amburgey (3):
linux-user: Add Alpha socket constants
linux-user: Support setgroups syscall with no groups
linux-user: Add more sparc syscall numbers
John Rigby (2):
linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
linux-user: fix futex strace of FUTEX_CLOCK_REALTIME
Laurent Vivier (1):
linux-user: improve print_fcntl()
Peter Maydell (5):
linux-user: Fix layout of usage table to account for option text
linux-user: make bogus negative iovec lengths fail EINVAL
linux-user: Implement sendfile and sendfile64
linux-user: Implement accept4
linux-user/syscall.c: Don't warn about unimplemented get_robust_list
configure | 17 ++++++
linux-user/main.c | 24 +++++---
linux-user/socket.h | 69 +++++++++++++++++++++
linux-user/sparc/syscall_nr.h | 2 +
linux-user/strace.c | 103 +++++++++++++++++++++++++------
linux-user/syscall.c | 134 ++++++++++++++++++++++++++++++++++-------
6 files changed, 302 insertions(+), 47 deletions(-)
--
1.7.10.4
^ permalink raw reply [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 01/11] linux-user: Add Alpha socket constants
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 02/11] linux-user: improve print_fcntl() riku.voipio
` (11 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Dillon Amburgey
From: Dillon Amburgey <dillona@dillona.com>
Without these, some networking programs will not work
Signed-off-by: Dillon Amburgey <dillona@dillona.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/socket.h | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 69 insertions(+)
diff --git a/linux-user/socket.h b/linux-user/socket.h
index 93d4782..339cae5 100644
--- a/linux-user/socket.h
+++ b/linux-user/socket.h
@@ -87,6 +87,75 @@
#define TARGET_SOCK_MAX (SOCK_PACKET + 1)
+#elif defined(TARGET_ALPHA)
+
+ /* For setsockopt(2) */
+ #define TARGET_SOL_SOCKET 0xffff
+
+ #define TARGET_SO_DEBUG 0x0001
+ #define TARGET_SO_REUSEADDR 0x0004
+ #define TARGET_SO_KEEPALIVE 0x0008
+ #define TARGET_SO_DONTROUTE 0x0010
+ #define TARGET_SO_BROADCAST 0x0020
+ #define TARGET_SO_LINGER 0x0080
+ #define TARGET_SO_OOBINLINE 0x0100
+ /* To add :#define TARGET_SO_REUSEPORT 0x0200 */
+
+ #define TARGET_SO_TYPE 0x1008
+ #define TARGET_SO_ERROR 0x1007
+ #define TARGET_SO_SNDBUF 0x1001
+ #define TARGET_SO_RCVBUF 0x1002
+ #define TARGET_SO_SNDBUFFORCE 0x100a
+ #define TARGET_SO_RCVBUFFORCE 0x100b
+ #define TARGET_SO_RCVLOWAT 0x1010
+ #define TARGET_SO_SNDLOWAT 0x1011
+ #define TARGET_SO_RCVTIMEO 0x1012
+ #define TARGET_SO_SNDTIMEO 0x1013
+ #define TARGET_SO_ACCEPTCONN 0x1014
+ #define TARGET_SO_PROTOCOL 0x1028
+ #define TARGET_SO_DOMAIN 0x1029
+
+ /* linux-specific, might as well be the same as on i386 */
+ #define TARGET_SO_NO_CHECK 11
+ #define TARGET_SO_PRIORITY 12
+ #define TARGET_SO_BSDCOMPAT 14
+
+ #define TARGET_SO_PASSCRED 17
+ #define TARGET_SO_PEERCRED 18
+ #define TARGET_SO_BINDTODEVICE 25
+
+ /* Socket filtering */
+ #define TARGET_SO_ATTACH_FILTER 26
+ #define TARGET_SO_DETACH_FILTER 27
+
+ #define TARGET_SO_PEERNAME 28
+ #define TARGET_SO_TIMESTAMP 29
+ #define TARGET_SCM_TIMESTAMP TARGET_SO_TIMESTAMP
+
+ #define TARGET_SO_PEERSEC 30
+ #define TARGET_SO_PASSSEC 34
+ #define TARGET_SO_TIMESTAMPNS 35
+ #define TARGET_SCM_TIMESTAMPNS TARGET_SO_TIMESTAMPNS
+
+ /* Security levels - as per NRL IPv6 - don't actually do anything */
+ #define TARGET_SO_SECURITY_AUTHENTICATION 19
+ #define TARGET_SO_SECURITY_ENCRYPTION_TRANSPORT 20
+ #define TARGET_SO_SECURITY_ENCRYPTION_NETWORK 21
+
+ #define TARGET_SO_MARK 36
+
+ #define TARGET_SO_TIMESTAMPING 37
+ #define TARGET_SCM_TIMESTAMPING TARGET_SO_TIMESTAMPING
+
+ #define TARGET_SO_RXQ_OVFL 40
+
+ #define TARGET_SO_WIFI_STATUS 41
+ #define TARGET_SCM_WIFI_STATUS TARGET_SO_WIFI_STATUS
+ #define TARGET_SO_PEEK_OFF 42
+
+ /* Instruct lower device to use last 4-bytes of skb data as FCS */
+ #define TARGET_SO_NOFCS 43
+
#else
/* For setsockopt(2) */
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 02/11] linux-user: improve print_fcntl()
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 01/11] linux-user: Add Alpha socket constants riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 03/11] linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex riku.voipio
` (10 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Laurent Vivier
From: Laurent Vivier <Laurent@Vivier.EU>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/strace.c | 97 +++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 79 insertions(+), 18 deletions(-)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 4e91a6e..9a18146 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -462,18 +462,6 @@ UNUSED static struct flags mmap_flags[] = {
FLAG_END,
};
-UNUSED static struct flags fcntl_flags[] = {
- FLAG_TARGET(F_DUPFD),
- FLAG_TARGET(F_GETFD),
- FLAG_TARGET(F_SETFD),
- FLAG_TARGET(F_GETFL),
- FLAG_TARGET(F_SETFL),
- FLAG_TARGET(F_GETLK),
- FLAG_TARGET(F_SETLK),
- FLAG_TARGET(F_SETLKW),
- FLAG_END,
-};
-
UNUSED static struct flags clone_flags[] = {
FLAG_GENERIC(CLONE_VM),
FLAG_GENERIC(CLONE_FS),
@@ -867,12 +855,85 @@ print_fcntl(const struct syscallname *name,
{
print_syscall_prologue(name);
print_raw_param("%d", arg0, 0);
- print_flags(fcntl_flags, arg1, 0);
- /*
- * TODO: check flags and print following argument only
- * when needed.
- */
- print_pointer(arg2, 1);
+ switch(arg1) {
+ case TARGET_F_DUPFD:
+ gemu_log("F_DUPFD,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+ break;
+ case TARGET_F_GETFD:
+ gemu_log("F_GETFD");
+ break;
+ case TARGET_F_SETFD:
+ gemu_log("F_SETFD,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+ break;
+ case TARGET_F_GETFL:
+ gemu_log("F_GETFL");
+ break;
+ case TARGET_F_SETFL:
+ gemu_log("F_SETFL,");
+ print_open_flags(arg2, 1);
+ break;
+ case TARGET_F_GETLK:
+ gemu_log("F_GETLK,");
+ print_pointer(arg2, 1);
+ break;
+ case TARGET_F_SETLK:
+ gemu_log("F_SETLK,");
+ print_pointer(arg2, 1);
+ break;
+ case TARGET_F_SETLKW:
+ gemu_log("F_SETLKW,");
+ print_pointer(arg2, 1);
+ break;
+ case TARGET_F_GETOWN:
+ gemu_log("F_GETOWN");
+ break;
+ case TARGET_F_SETOWN:
+ gemu_log("F_SETOWN,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+ break;
+ case TARGET_F_GETSIG:
+ gemu_log("F_GETSIG");
+ break;
+ case TARGET_F_SETSIG:
+ gemu_log("F_SETSIG,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+ break;
+#if TARGET_ABI_BITS == 32
+ case TARGET_F_GETLK64:
+ gemu_log("F_GETLK64,");
+ print_pointer(arg2, 1);
+ break;
+ case TARGET_F_SETLK64:
+ gemu_log("F_SETLK64,");
+ print_pointer(arg2, 1);
+ break;
+ case TARGET_F_SETLKW64:
+ gemu_log("F_SETLKW64,");
+ print_pointer(arg2, 1);
+ break;
+#endif
+ case TARGET_F_SETLEASE:
+ gemu_log("F_SETLEASE,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+ break;
+ case TARGET_F_GETLEASE:
+ gemu_log("F_GETLEASE");
+ break;
+ case TARGET_F_DUPFD_CLOEXEC:
+ gemu_log("F_DUPFD_CLOEXEC,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 1);
+ break;
+ case TARGET_F_NOTIFY:
+ gemu_log("F_NOTIFY,");
+ print_raw_param(TARGET_ABI_FMT_ld, arg2, 0);
+ break;
+ default:
+ print_raw_param(TARGET_ABI_FMT_ld, arg1, 0);
+ print_pointer(arg2, 1);
+ break;
+ }
print_syscall_epilogue(name);
}
#define print_fcntl64 print_fcntl
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 03/11] linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 01/11] linux-user: Add Alpha socket constants riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 02/11] linux-user: improve print_fcntl() riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 04/11] linux-user: fix futex strace of FUTEX_CLOCK_REALTIME riku.voipio
` (9 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: John Rigby
From: John Rigby <john.rigby@linaro.org>
Upstream libc has recently changed to start using
FUTEX_WAIT_BITSET instead of FUTEX_WAIT and this
is causing do_futex to return -TARGET_ENOSYS.
Pass bitset in val3 to sys_futex which will be
ignored by kernel for the FUTEX_WAIT case.
Signed-off-by: John Rigby <john.rigby@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 19630ea..c7fcfc0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4922,6 +4922,7 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
#endif
switch (base_op) {
case FUTEX_WAIT:
+ case FUTEX_WAIT_BITSET:
if (timeout) {
pts = &ts;
target_to_host_timespec(pts, timeout);
@@ -4929,7 +4930,7 @@ static int do_futex(target_ulong uaddr, int op, int val, target_ulong timeout,
pts = NULL;
}
return get_errno(sys_futex(g2h(uaddr), op, tswap32(val),
- pts, NULL, 0));
+ pts, NULL, val3));
case FUTEX_WAKE:
return get_errno(sys_futex(g2h(uaddr), op, val, NULL, NULL, 0));
case FUTEX_FD:
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 04/11] linux-user: fix futex strace of FUTEX_CLOCK_REALTIME
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (2 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 03/11] linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 05/11] linux-user: Support setgroups syscall with no groups riku.voipio
` (8 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: John Rigby
From: John Rigby <john.rigby@linaro.org>
Handle same as existing FUTEX_PRIVATE_FLAG.
Signed-off-by: John Rigby <john.rigby@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/strace.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/linux-user/strace.c b/linux-user/strace.c
index 9a18146..0fbae3c 100644
--- a/linux-user/strace.c
+++ b/linux-user/strace.c
@@ -1498,6 +1498,12 @@ if( cmd == val ) { \
cmd &= ~FUTEX_PRIVATE_FLAG;
}
#endif
+#ifdef FUTEX_CLOCK_REALTIME
+ if (cmd & FUTEX_CLOCK_REALTIME) {
+ gemu_log("FUTEX_CLOCK_REALTIME|");
+ cmd &= ~FUTEX_CLOCK_REALTIME;
+ }
+#endif
print_op(FUTEX_WAIT)
print_op(FUTEX_WAKE)
print_op(FUTEX_FD)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 05/11] linux-user: Support setgroups syscall with no groups
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (3 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 04/11] linux-user: fix futex strace of FUTEX_CLOCK_REALTIME riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 06/11] linux-user: Add more sparc syscall numbers riku.voipio
` (7 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Dillon Amburgey
From: Dillon Amburgey <dillona@dillona.com>
Signed-off-by: Dillon Amburgey <dillona@dillona.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 22 ++++++++++++----------
1 file changed, 12 insertions(+), 10 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c7fcfc0..1729446 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7680,18 +7680,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
int gidsetsize = arg1;
target_id *target_grouplist;
- gid_t *grouplist;
+ gid_t *grouplist = NULL;
int i;
-
- grouplist = alloca(gidsetsize * sizeof(gid_t));
- target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
- if (!target_grouplist) {
- ret = -TARGET_EFAULT;
- goto fail;
+ if (gidsetsize) {
+ grouplist = alloca(gidsetsize * sizeof(gid_t));
+ target_grouplist = lock_user(VERIFY_READ, arg2, gidsetsize * 2, 1);
+ if (!target_grouplist) {
+ ret = -TARGET_EFAULT;
+ goto fail;
+ }
+ for (i = 0; i < gidsetsize; i++) {
+ grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
+ }
+ unlock_user(target_grouplist, arg2, 0);
}
- for(i = 0;i < gidsetsize; i++)
- grouplist[i] = low2highgid(tswapid(target_grouplist[i]));
- unlock_user(target_grouplist, arg2, 0);
ret = get_errno(setgroups(gidsetsize, grouplist));
}
break;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 06/11] linux-user: Add more sparc syscall numbers
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (4 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 05/11] linux-user: Support setgroups syscall with no groups riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 07/11] linux-user: Fix layout of usage table to account for option text riku.voipio
` (6 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Dillon Amburgey
From: Dillon Amburgey <dillona@dillona.com>
Signed-off-by: Dillon Amburgey <dillona@dillona.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/sparc/syscall_nr.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/linux-user/sparc/syscall_nr.h b/linux-user/sparc/syscall_nr.h
index 061711c..534e6e9 100644
--- a/linux-user/sparc/syscall_nr.h
+++ b/linux-user/sparc/syscall_nr.h
@@ -200,6 +200,8 @@
#define TARGET_NR__newselect 230 /* Linux Specific */
#define TARGET_NR_time 231 /* Linux Specific */
#define TARGET_NR_stime 233 /* Linux Specific */
+#define TARGET_NR_statfs64 234 /* Linux Specific */
+#define TARGET_NR_fstatfs64 235 /* Linux Specific */
#define TARGET_NR__llseek 236 /* Linux Specific */
#define TARGET_NR_mlock 237
#define TARGET_NR_munlock 238
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 07/11] linux-user: Fix layout of usage table to account for option text
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (5 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 06/11] linux-user: Add more sparc syscall numbers riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 08/11] linux-user: make bogus negative iovec lengths fail EINVAL riku.voipio
` (5 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
The linux-user usage message attempts to line up the columns in
its table by calculating the maximum width of any item in them.
However for the 'Argument' column it was only accounting for the
length of the option switch (eg "-d"), not the additional example
text (eg "item[,...]"). This currently has no adverse effects
because the widest item in the column happens to be the argumentless
"-singlestep" option, but improving the "-d" option help to read
"-d item[,...]" exceeds that limit.
Fix this by correctly calculating maxarglen as the width of the
first column text including a possible option argument, and
adjusting its uses to match.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/main.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index d8b0cd6..4e92a0b 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3406,27 +3406,35 @@ static void usage(void)
"Options and associated environment variables:\n"
"\n");
- maxarglen = maxenvlen = 0;
+ /* Calculate column widths. We must always have at least enough space
+ * for the column header.
+ */
+ maxarglen = strlen("Argument");
+ maxenvlen = strlen("Env-variable");
for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
+ int arglen = strlen(arginfo->argv);
+ if (arginfo->has_arg) {
+ arglen += strlen(arginfo->example) + 1;
+ }
if (strlen(arginfo->env) > maxenvlen) {
maxenvlen = strlen(arginfo->env);
}
- if (strlen(arginfo->argv) > maxarglen) {
- maxarglen = strlen(arginfo->argv);
+ if (arglen > maxarglen) {
+ maxarglen = arglen;
}
}
- printf("%-*s%-*sDescription\n", maxarglen+3, "Argument",
- maxenvlen+1, "Env-variable");
+ printf("%-*s %-*s Description\n", maxarglen+1, "Argument",
+ maxenvlen, "Env-variable");
for (arginfo = arg_table; arginfo->handle_opt != NULL; arginfo++) {
if (arginfo->has_arg) {
printf("-%s %-*s %-*s %s\n", arginfo->argv,
- (int)(maxarglen-strlen(arginfo->argv)), arginfo->example,
- maxenvlen, arginfo->env, arginfo->help);
+ (int)(maxarglen - strlen(arginfo->argv) - 1),
+ arginfo->example, maxenvlen, arginfo->env, arginfo->help);
} else {
- printf("-%-*s %-*s %s\n", maxarglen+1, arginfo->argv,
+ printf("-%-*s %-*s %s\n", maxarglen, arginfo->argv,
maxenvlen, arginfo->env,
arginfo->help);
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 08/11] linux-user: make bogus negative iovec lengths fail EINVAL
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (6 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 07/11] linux-user: Fix layout of usage table to account for option text riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 09/11] linux-user: Implement sendfile and sendfile64 riku.voipio
` (4 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
If the guest passes us a bogus negative length for an iovec, fail
EINVAL rather than proceeding blindly forward. This fixes some of
the error cases tests for readv and writev in the LTP.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 1729446..bab9ab5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1776,7 +1776,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
errno = 0;
return NULL;
}
- if (count > IOV_MAX) {
+ if (count < 0 || count > IOV_MAX) {
errno = EINVAL;
return NULL;
}
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 09/11] linux-user: Implement sendfile and sendfile64
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (7 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 08/11] linux-user: make bogus negative iovec lengths fail EINVAL riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 10/11] linux-user: Implement accept4 riku.voipio
` (3 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
Implement the sendfile and sendfile64 syscalls. This implementation
passes all the LTP test cases for these syscalls.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
configure | 17 ++++++++++++++++
linux-user/syscall.c | 53 ++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 70 insertions(+)
diff --git a/configure b/configure
index 84317c6..a416e23 100755
--- a/configure
+++ b/configure
@@ -2760,6 +2760,20 @@ if compile_prog "" "" ; then
epoll_pwait=yes
fi
+# check for sendfile support
+sendfile=no
+cat > $TMPC << EOF
+#include <sys/sendfile.h>
+
+int main(void)
+{
+ return sendfile(0, 0, 0, 0);
+}
+EOF
+if compile_prog "" "" ; then
+ sendfile=yes
+fi
+
# Check if tools are available to build documentation.
if test "$docs" != "no" ; then
if has makeinfo && has pod2man; then
@@ -3628,6 +3642,9 @@ fi
if test "$epoll_pwait" = "yes" ; then
echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
fi
+if test "$sendfile" = "yes" ; then
+ echo "CONFIG_SENDFILE=y" >> $config_host_mak
+fi
if test "$inotify" = "yes" ; then
echo "CONFIG_INOTIFY=y" >> $config_host_mak
fi
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index bab9ab5..77281f1 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -78,6 +78,9 @@ int __clone2(int (*fn)(void *), void *child_stack_base,
#ifdef CONFIG_ATTR
#include "qemu/xattr.h"
#endif
+#ifdef CONFIG_SENDFILE
+#include <sys/sendfile.h>
+#endif
#define termios host_termios
#define winsize host_winsize
@@ -7531,8 +7534,58 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#else
goto unimplemented;
#endif
+
+#ifdef CONFIG_SENDFILE
+ case TARGET_NR_sendfile:
+ {
+ off_t *offp = NULL;
+ off_t off;
+ if (arg3) {
+ ret = get_user_sal(off, arg3);
+ if (is_error(ret)) {
+ break;
+ }
+ offp = &off;
+ }
+ ret = get_errno(sendfile(arg1, arg2, offp, arg4));
+ if (!is_error(ret) && arg3) {
+ abi_long ret2 = put_user_sal(off, arg3);
+ if (is_error(ret2)) {
+ ret = ret2;
+ }
+ }
+ break;
+ }
+#ifdef TARGET_NR_sendfile64
+ case TARGET_NR_sendfile64:
+ {
+ off_t *offp = NULL;
+ off_t off;
+ if (arg3) {
+ ret = get_user_s64(off, arg3);
+ if (is_error(ret)) {
+ break;
+ }
+ offp = &off;
+ }
+ ret = get_errno(sendfile(arg1, arg2, offp, arg4));
+ if (!is_error(ret) && arg3) {
+ abi_long ret2 = put_user_s64(off, arg3);
+ if (is_error(ret2)) {
+ ret = ret2;
+ }
+ }
+ break;
+ }
+#endif
+#else
case TARGET_NR_sendfile:
+#ifdef TARGET_NR_sendfile64:
+ case TARGET_NR_sendfile64:
+#endif
goto unimplemented;
+#endif
+
#ifdef TARGET_NR_getpmsg
case TARGET_NR_getpmsg:
goto unimplemented;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 10/11] linux-user: Implement accept4
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (8 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 09/11] linux-user: Implement sendfile and sendfile64 riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 11/11] linux-user/syscall.c: Don't warn about unimplemented get_robust_list riku.voipio
` (2 subsequent siblings)
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
Implement the accept4 syscall (which is identical to accept
but has an additional flags argument).
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 39 +++++++++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 77281f1..6182a27 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2004,16 +2004,30 @@ out2:
return ret;
}
-/* do_accept() Must return target values and target errnos. */
-static abi_long do_accept(int fd, abi_ulong target_addr,
- abi_ulong target_addrlen_addr)
+/* If we don't have a system accept4() then just call accept.
+ * The callsites to do_accept4() will ensure that they don't
+ * pass a non-zero flags argument in this config.
+ */
+#ifndef CONFIG_ACCEPT4
+static inline int accept4(int sockfd, struct sockaddr *addr,
+ socklen_t *addrlen, int flags)
+{
+ assert(flags == 0);
+ return accept(sockfd, addr, addrlen);
+}
+#endif
+
+/* do_accept4() Must return target values and target errnos. */
+static abi_long do_accept4(int fd, abi_ulong target_addr,
+ abi_ulong target_addrlen_addr, int flags)
{
socklen_t addrlen;
void *addr;
abi_long ret;
- if (target_addr == 0)
- return get_errno(accept(fd, NULL, NULL));
+ if (target_addr == 0) {
+ return get_errno(accept4(fd, NULL, NULL, flags));
+ }
/* linux returns EINVAL if addrlen pointer is invalid */
if (get_user_u32(addrlen, target_addrlen_addr))
@@ -2028,7 +2042,7 @@ static abi_long do_accept(int fd, abi_ulong target_addr,
addr = alloca(addrlen);
- ret = get_errno(accept(fd, addr, &addrlen));
+ ret = get_errno(accept4(fd, addr, &addrlen, flags));
if (!is_error(ret)) {
host_to_target_sockaddr(target_addr, addr, addrlen);
if (put_user_u32(addrlen, target_addrlen_addr))
@@ -2254,7 +2268,7 @@ static abi_long do_socketcall(int num, abi_ulong vptr)
|| get_user_ual(target_addrlen, vptr + 2 * n))
return -TARGET_EFAULT;
- ret = do_accept(sockfd, target_addr, target_addrlen);
+ ret = do_accept4(sockfd, target_addr, target_addrlen, 0);
}
break;
case SOCKOP_getsockname:
@@ -6677,7 +6691,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_accept
case TARGET_NR_accept:
- ret = do_accept(arg1, arg2, arg3);
+ ret = do_accept4(arg1, arg2, arg3, 0);
+ break;
+#endif
+#ifdef TARGET_NR_accept4
+ case TARGET_NR_accept4:
+#ifdef CONFIG_ACCEPT4
+ ret = do_accept4(arg1, arg2, arg3, arg4);
+#else
+ goto unimplemented;
+#endif
break;
#endif
#ifdef TARGET_NR_bind
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* [Qemu-devel] [PATCH 11/11] linux-user/syscall.c: Don't warn about unimplemented get_robust_list
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (9 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 10/11] linux-user: Implement accept4 riku.voipio
@ 2013-03-11 19:27 ` riku.voipio
2013-03-11 21:21 ` [Qemu-devel] [PULL] linux-user updates Peter Maydell
2013-03-15 14:55 ` Anthony Liguori
12 siblings, 0 replies; 15+ messages in thread
From: riku.voipio @ 2013-03-11 19:27 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
The nature of the kernel ABI for the get_robust_list and set_robust_list
syscalls means we cannot implement them in QEMU. Make get_robust_list
silently return ENOSYS rather than using the default "print message and
then fail ENOSYS" code path, in the same way we already do for
set_robust_list, and add a comment documenting why we do this.
This silences warnings which were being produced for emulating
even trivial programs like 'ls' in x86-64-on-x86-64.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 15 ++++++++++++++-
1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 6182a27..ee82a2d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -8631,7 +8631,20 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#ifdef TARGET_NR_set_robust_list
case TARGET_NR_set_robust_list:
- goto unimplemented_nowarn;
+ case TARGET_NR_get_robust_list:
+ /* The ABI for supporting robust futexes has userspace pass
+ * the kernel a pointer to a linked list which is updated by
+ * userspace after the syscall; the list is walked by the kernel
+ * when the thread exits. Since the linked list in QEMU guest
+ * memory isn't a valid linked list for the host and we have
+ * no way to reliably intercept the thread-death event, we can't
+ * support these. Silently return ENOSYS so that guest userspace
+ * falls back to a non-robust futex implementation (which should
+ * be OK except in the corner case of the guest crashing while
+ * holding a mutex that is shared with another process via
+ * shared memory).
+ */
+ goto unimplemented_nowarn;
#endif
#if defined(TARGET_NR_utimensat) && defined(__NR_utimensat)
--
1.7.10.4
^ permalink raw reply related [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL] linux-user updates
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (10 preceding siblings ...)
2013-03-11 19:27 ` [Qemu-devel] [PATCH 11/11] linux-user/syscall.c: Don't warn about unimplemented get_robust_list riku.voipio
@ 2013-03-11 21:21 ` Peter Maydell
2013-03-11 22:58 ` Anthony Liguori
2013-03-15 14:55 ` Anthony Liguori
12 siblings, 1 reply; 15+ messages in thread
From: Peter Maydell @ 2013-03-11 21:21 UTC (permalink / raw)
To: riku.voipio; +Cc: Anthony Liguori, qemu-devel
On 11 March 2013 19:27, <riku.voipio@linaro.org> wrote:
> From: Riku Voipio <riku.voipio@linaro.org>
>
> Hi,
>
> This is my patch queue for linux-user. Please pull.
>
> The following changes since commit fa3889162ff724d09eb6b6bd06ba54769100a77f:
>
> Merge remote-tracking branch 'origin/master' into staging (2013-03-10 20:39:17 -0500)
>
> are available in the git repository at:
>
> git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream
Probably best to cc Anthony on pullreqs, I'm not sure his system
flags them up otherwise.
-- PMM
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL] linux-user updates
2013-03-11 21:21 ` [Qemu-devel] [PULL] linux-user updates Peter Maydell
@ 2013-03-11 22:58 ` Anthony Liguori
0 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2013-03-11 22:58 UTC (permalink / raw)
To: Peter Maydell, riku.voipio; +Cc: qemu-devel
Peter Maydell <peter.maydell@linaro.org> writes:
> On 11 March 2013 19:27, <riku.voipio@linaro.org> wrote:
>> From: Riku Voipio <riku.voipio@linaro.org>
>>
>> Hi,
>>
>> This is my patch queue for linux-user. Please pull.
>>
>> The following changes since commit fa3889162ff724d09eb6b6bd06ba54769100a77f:
>>
>> Merge remote-tracking branch 'origin/master' into staging (2013-03-10 20:39:17 -0500)
>>
>> are available in the git repository at:
>>
>> git://git.linaro.org/people/rikuvoipio/qemu.git linux-user-for-upstream
>
> Probably best to cc Anthony on pullreqs, I'm not sure his system
> flags them up otherwise.
Never hurts, but for pull requests it's not strictly necessary. It
matters for patches just due to sheer volume. We don't (yet) have that
problem with pull requests.
Regards,
Anthony Liguori
>
> -- PMM
^ permalink raw reply [flat|nested] 15+ messages in thread
* Re: [Qemu-devel] [PULL] linux-user updates
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
` (11 preceding siblings ...)
2013-03-11 21:21 ` [Qemu-devel] [PULL] linux-user updates Peter Maydell
@ 2013-03-15 14:55 ` Anthony Liguori
12 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2013-03-15 14:55 UTC (permalink / raw)
To: riku.voipio, qemu-devel
Pulled. Thanks.
Regards,
Anthony Liguori
^ permalink raw reply [flat|nested] 15+ messages in thread
end of thread, other threads:[~2013-03-15 14:55 UTC | newest]
Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-11 19:27 [Qemu-devel] [PULL] linux-user updates riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 01/11] linux-user: Add Alpha socket constants riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 02/11] linux-user: improve print_fcntl() riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 03/11] linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 04/11] linux-user: fix futex strace of FUTEX_CLOCK_REALTIME riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 05/11] linux-user: Support setgroups syscall with no groups riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 06/11] linux-user: Add more sparc syscall numbers riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 07/11] linux-user: Fix layout of usage table to account for option text riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 08/11] linux-user: make bogus negative iovec lengths fail EINVAL riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 09/11] linux-user: Implement sendfile and sendfile64 riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 10/11] linux-user: Implement accept4 riku.voipio
2013-03-11 19:27 ` [Qemu-devel] [PATCH 11/11] linux-user/syscall.c: Don't warn about unimplemented get_robust_list riku.voipio
2013-03-11 21:21 ` [Qemu-devel] [PULL] linux-user updates Peter Maydell
2013-03-11 22:58 ` Anthony Liguori
2013-03-15 14:55 ` Anthony Liguori
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.