* [Qemu-devel] [PULL 00/24] Linux-user updates
@ 2014-08-15 11:01 riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content riku.voipio
` (24 more replies)
0 siblings, 25 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
Hi,
A usual set of improvements and bugfixes. The binfmt flag addition is an
ABI break so endusers need to update their binfmt registering scripts.
The following changes since commit 2d591ce2aeebf9620ff527c7946844a3122afeec:
Merge remote-tracking branch 'remotes/mdroth/qga-pull-2014-08-08' into staging (2014-08-08 14:16:05 +0100)
are available in the git repository at:
git://git.linaro.org/people/riku.voipio/qemu.git linux-user-for-upstream
for you to fetch changes up to e93757cb483a945e88550e605fc59bb1a1e80ccc:
linux-user: check return value of malloc() (2014-08-14 16:00:15 +0300)
----------------------------------------------------------------
Jincheng Miao (1):
linux-user: Fix syscall instruction usermode emulation on X86_64
Joakim Tjernlund (1):
linux-user: make binfmt flag O require P
Mike Frysinger (1):
linux-user: fix readlink handling with magic exe symlink
Mikhail Ilyin (1):
linux-user: /proc/self/maps content
Paul Burton (1):
linux-user: support ioprio_{get, set} syscalls
Peter Maydell (1):
linux-user: Fix conversion of sigevent argument to timer_create
Riku Voipio (4):
linux-user: redirect openat calls
linux-user: support timerfd_{create, gettime, settime} syscalls
linux-user: support {name_to,open_by}_handle_at syscalls
linux-user: add setns and unshare
Tom Musta (13):
linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2
linux-user: Dereference Pointer Argument to ipc/semctl Sys Call
linux-user: Properly Handle semun Structure In Cross-Endian Situations
linux-user: Make ipc syscall's third argument an abi_long
linux-user: Conditionally Pass Attribute Pointer to mq_open()
linux-user: Detect Negative Message Sizes in msgsnd System Call
linux-user: Handle NULL sched_param argument to sched_*
linux-user: Detect fault in sched_rr_get_interval
linux-user: Move get_ppc64_abi
linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2
linux-user: clock_nanosleep errno Handling on PPC
linux-user: Support target-to-host translation of mlockall argument
linux-user: writev Partial Writes
zhanghailiang (1):
linux-user: check return value of malloc()
configure | 37 +++++
include/exec/cpu-all.h | 2 +
linux-user/aarch64/syscall.h | 3 +
linux-user/alpha/syscall.h | 3 +
linux-user/arm/syscall.h | 4 +
linux-user/cris/syscall.h | 3 +
linux-user/elfload.c | 9 --
linux-user/i386/syscall.h | 3 +
linux-user/m68k/syscall.h | 4 +
linux-user/main.c | 20 ++-
linux-user/microblaze/syscall.h | 3 +
linux-user/mips/syscall.h | 3 +
linux-user/mips64/syscall.h | 3 +
linux-user/openrisc/syscall.h | 4 +
linux-user/ppc/syscall.h | 4 +
linux-user/ppc/target_cpu.h | 10 ++
linux-user/s390x/syscall.h | 3 +
linux-user/sh4/syscall.h | 4 +
linux-user/signal.c | 12 +-
linux-user/sparc/syscall.h | 3 +
linux-user/sparc64/syscall.h | 3 +
linux-user/strace.c | 30 ++++
linux-user/strace.list | 18 +++
linux-user/syscall.c | 347 ++++++++++++++++++++++++++++++++++------
linux-user/unicore32/syscall.h | 4 +
linux-user/x86_64/syscall.h | 3 +
scripts/qemu-binfmt-conf.sh | 36 ++---
target-i386/seg_helper.c | 4 +-
28 files changed, 495 insertions(+), 87 deletions(-)
--
2.0.1
^ permalink raw reply [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 02/24] linux-user: redirect openat calls riku.voipio
` (23 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Mikhail Ilyin, Peter Maydell
From: Mikhail Ilyin <m.ilin@samsung.com>
Build /proc/self/maps doing a match against guest memory translation table.
Output only that map records which are valid for guest memory layout.
Signed-off-by: Mikhail Ilyin <m.ilin@samsung.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
include/exec/cpu-all.h | 2 ++
linux-user/syscall.c | 25 ++++++++++---------------
2 files changed, 12 insertions(+), 15 deletions(-)
diff --git a/include/exec/cpu-all.h b/include/exec/cpu-all.h
index f91581f..f9d132f 100644
--- a/include/exec/cpu-all.h
+++ b/include/exec/cpu-all.h
@@ -198,6 +198,8 @@ extern unsigned long reserved_va;
#define RESERVED_VA 0ul
#endif
+#define GUEST_ADDR_MAX (RESERVED_VA ? RESERVED_VA : \
+ (1ul << TARGET_VIRT_ADDR_SPACE_BITS) - 1)
#endif
/* page related stuff */
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a50229d..c8c2b4c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5092,10 +5092,8 @@ static int open_self_cmdline(void *cpu_env, int fd)
static int open_self_maps(void *cpu_env, int fd)
{
-#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
CPUState *cpu = ENV_GET_CPU((CPUArchState *)cpu_env);
TaskState *ts = cpu->opaque;
-#endif
FILE *fp;
char *line = NULL;
size_t len = 0;
@@ -5118,13 +5116,18 @@ static int open_self_maps(void *cpu_env, int fd)
if ((fields < 10) || (fields > 11)) {
continue;
}
- if (!strncmp(path, "[stack]", 7)) {
- continue;
- }
- if (h2g_valid(min) && h2g_valid(max)) {
+ if (h2g_valid(min)) {
+ int flags = page_get_flags(h2g(min));
+ max = h2g_valid(max - 1) ? max : (uintptr_t)g2h(GUEST_ADDR_MAX);
+ if (page_check_range(h2g(min), max - min, flags) == -1) {
+ continue;
+ }
+ if (h2g(min) == ts->info->stack_limit) {
+ pstrcpy(path, sizeof(path), " [stack]");
+ }
dprintf(fd, TARGET_ABI_FMT_lx "-" TARGET_ABI_FMT_lx
" %c%c%c%c %08" PRIx64 " %02x:%02x %d %s%s\n",
- h2g(min), h2g(max), flag_r, flag_w,
+ h2g(min), h2g(max - 1) + 1, flag_r, flag_w,
flag_x, flag_p, offset, dev_maj, dev_min, inode,
path[0] ? " " : "", path);
}
@@ -5133,14 +5136,6 @@ static int open_self_maps(void *cpu_env, int fd)
free(line);
fclose(fp);
-#if defined(TARGET_ARM) || defined(TARGET_M68K) || defined(TARGET_UNICORE32)
- dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0 [stack]\n",
- (unsigned long long)ts->info->stack_limit,
- (unsigned long long)(ts->info->start_stack +
- (TARGET_PAGE_SIZE - 1)) & TARGET_PAGE_MASK,
- (unsigned long long)0);
-#endif
-
return 0;
}
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 02/24] linux-user: redirect openat calls
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 03/24] linux-user: make binfmt flag O require P riku.voipio
` (22 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Mikhail Ilin, Peter Maydell, Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
While Mikhail fixed /proc/self/maps, it was noticed openat calls are
not redirected currently. Some archs don't have open at all, so
openat needs to be redirected.
Fix this by consolidating open/openat code to do_openat - open
is implemented using openat(AT_FDCWD, ... ), which according
to open(2) man page is identical.
Since all targets now have openat, remove the ifdef around sys_openat
and openat: case in do_syscall.
Cc: Mikhail Ilin <m.ilin@samsung.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 23 +++++++++--------------
1 file changed, 9 insertions(+), 14 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c8c2b4c..dd77673 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -294,7 +294,6 @@ static int sys_getcwd1(char *buf, size_t size)
return strlen(buf)+1;
}
-#ifdef TARGET_NR_openat
static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode)
{
/*
@@ -306,7 +305,6 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode)
}
return (openat(dirfd, pathname, flags));
}
-#endif
#ifdef TARGET_NR_utimensat
#ifdef CONFIG_UTIMENSAT
@@ -5274,7 +5272,7 @@ static int open_net_route(void *cpu_env, int fd)
}
#endif
-static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
+static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode)
{
struct fake_open {
const char *filename;
@@ -5295,7 +5293,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
if (is_proc_myself(pathname, "exe")) {
int execfd = qemu_getauxval(AT_EXECFD);
- return execfd ? execfd : get_errno(open(exec_path, flags, mode));
+ return execfd ? execfd : get_errno(sys_openat(dirfd, exec_path, flags, mode));
}
for (fake_open = fakes; fake_open->filename; fake_open++) {
@@ -5329,7 +5327,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode)
return fd;
}
- return get_errno(open(path(pathname), flags, mode));
+ return get_errno(sys_openat(dirfd, path(pathname), flags, mode));
}
/* do_syscall() should always have a single exit point at the end so
@@ -5404,22 +5402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
case TARGET_NR_open:
if (!(p = lock_user_string(arg1)))
goto efault;
- ret = get_errno(do_open(cpu_env, p,
- target_to_host_bitmask(arg2, fcntl_flags_tbl),
- arg3));
+ ret = get_errno(do_openat(cpu_env, AT_FDCWD, p,
+ target_to_host_bitmask(arg2, fcntl_flags_tbl),
+ arg3));
unlock_user(p, arg1, 0);
break;
-#if defined(TARGET_NR_openat) && defined(__NR_openat)
case TARGET_NR_openat:
if (!(p = lock_user_string(arg2)))
goto efault;
- ret = get_errno(sys_openat(arg1,
- path(p),
- target_to_host_bitmask(arg3, fcntl_flags_tbl),
- arg4));
+ ret = get_errno(do_openat(cpu_env, arg1, p,
+ target_to_host_bitmask(arg3, fcntl_flags_tbl),
+ arg4));
unlock_user(p, arg2, 0);
break;
-#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 03/24] linux-user: make binfmt flag O require P
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 02/24] linux-user: redirect openat calls riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 04/24] linux-user: Fix syscall instruction usermode emulation on X86_64 riku.voipio
` (21 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Joakim Tjernlund
From: Joakim Tjernlund <joakim.tjernlund@transmode.se>
QEMU can autodetect if it is started from Linux binfmt loader
when binfmt flag O is on.
Use that and require binfmt flag P as well which will enable QEMU
to pass in correct argv0 to the application.
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/main.c | 19 +++++++++++++++----
scripts/qemu-binfmt-conf.sh | 36 ++++++++++++++++++------------------
2 files changed, 33 insertions(+), 22 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index b453a39..c5878f9 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -3751,7 +3751,7 @@ static void usage(void)
exit(1);
}
-static int parse_args(int argc, char **argv)
+static int parse_args(int argc, char **argv, int assume_P_flag)
{
const char *r;
int optind;
@@ -3767,7 +3767,18 @@ static int parse_args(int argc, char **argv)
arginfo->handle_opt(r);
}
}
-
+ if (assume_P_flag) {
+ /* Assume started by binmisc and binfmt P flag is set */
+ if (argc < 3) {
+ fprintf(stderr, "%s: Please use me through binfmt with P flag\n",
+ argv[0]);
+ exit(1);
+ }
+ filename = argv[1];
+ exec_path = argv[1];
+ /* Next argv must be argv0 for the app */
+ return 2;
+ }
optind = 1;
for (;;) {
if (optind >= argc) {
@@ -3858,7 +3869,8 @@ int main(int argc, char **argv, char **envp)
cpudef_setup(); /* parse cpu definitions in target config file (TBD) */
#endif
- optind = parse_args(argc, argv);
+ execfd = qemu_getauxval(AT_EXECFD);
+ optind = parse_args(argc, argv, execfd > 0);
/* Zero out regs */
memset(regs, 0, sizeof(struct target_pt_regs));
@@ -4004,7 +4016,6 @@ int main(int argc, char **argv, char **envp)
cpu->opaque = ts;
task_settid(ts);
- execfd = qemu_getauxval(AT_EXECFD);
if (execfd == 0) {
execfd = open(filename, O_RDONLY);
if (execfd < 0) {
diff --git a/scripts/qemu-binfmt-conf.sh b/scripts/qemu-binfmt-conf.sh
index 289b1a3..36fcb8f 100644
--- a/scripts/qemu-binfmt-conf.sh
+++ b/scripts/qemu-binfmt-conf.sh
@@ -31,42 +31,42 @@ esac
# register the interpreter for each cpu except for the native one
if [ $cpu != "i386" ] ; then
- echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
- echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:' > /proc/sys/fs/binfmt_misc/register
+ echo ':i386:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x03\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':i486:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x06\x00:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-i386:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "alpha" ] ; then
- echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-alpha:' > /proc/sys/fs/binfmt_misc/register
+ echo ':alpha:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x26\x90:\xff\xff\xff\xff\xff\xfe\xfe\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-alpha:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "arm" ] ; then
- echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:' > /proc/sys/fs/binfmt_misc/register
- echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:' > /proc/sys/fs/binfmt_misc/register
+ echo ':arm:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-arm:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':armeb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-armeb:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "aarch64" ] ; then
- echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-aarch64:' > /proc/sys/fs/binfmt_misc/register
+ echo ':aarch64:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\xb7\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-aarch64:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sparc" ] ; then
- echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:' > /proc/sys/fs/binfmt_misc/register
+ echo ':sparc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x02:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sparc:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "ppc" ] ; then
- echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:' > /proc/sys/fs/binfmt_misc/register
+ echo ':ppc:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x14:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-ppc:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "m68k" ] ; then
echo 'Please check cpu value and header information for m68k!'
- echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-m68k:' > /proc/sys/fs/binfmt_misc/register
+ echo ':m68k:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x04:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-m68k:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "mips" ] ; then
# FIXME: We could use the other endianness on a MIPS host.
- echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:' > /proc/sys/fs/binfmt_misc/register
- echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:' > /proc/sys/fs/binfmt_misc/register
- echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mipsn32:' > /proc/sys/fs/binfmt_misc/register
- echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsn32el:' > /proc/sys/fs/binfmt_misc/register
- echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips64:' > /proc/sys/fs/binfmt_misc/register
- echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mips64el:' > /proc/sys/fs/binfmt_misc/register
+ echo ':mips:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':mipsel:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsel:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':mipsn32:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mipsn32:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':mipsn32el:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mipsn32el:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':mips64:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-mips64:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':mips64el:M::\x7fELF\x02\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x08\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-mips64el:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "sh" ] ; then
- echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-sh4:' > /proc/sys/fs/binfmt_misc/register
- echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sh4eb:' > /proc/sys/fs/binfmt_misc/register
+ echo ':sh4:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a\x00:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/local/bin/qemu-sh4:PO' > /proc/sys/fs/binfmt_misc/register
+ echo ':sh4eb:M::\x7fELF\x01\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x2a:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-sh4eb:PO' > /proc/sys/fs/binfmt_misc/register
fi
if [ $cpu != "s390x" ] ; then
- echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-s390x:' > /proc/sys/fs/binfmt_misc/register
+ echo ':s390x:M::\x7fELF\x02\x02\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x16:\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff:/usr/local/bin/qemu-s390x:PO' > /proc/sys/fs/binfmt_misc/register
fi
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 04/24] linux-user: Fix syscall instruction usermode emulation on X86_64
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (2 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 03/24] linux-user: make binfmt flag O require P riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 05/24] linux-user: Fix conversion of sigevent argument to timer_create riku.voipio
` (20 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Jincheng Miao
From: Jincheng Miao <jmiao@redhat.com>
Currently syscall instruction is buggy on user mode X86_64,
the EIP is updated after do_syscall(), that is too late for
clone(). Because clone() will create a thread at the env->EIP
(the address of syscall insn), and then child thread enters
do_syscall() again, that is not expected. Sometimes it is tragic.
User mode syscall insn emulation is not used MSR, so the
action should be same to INT 0x80. INT 0x80 will update EIP in
do_interrupt(), ditto for syscall() for consistency.
Signed-off-by: Jincheng Miao <jmiao@redhat.com>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/main.c | 1 -
target-i386/seg_helper.c | 4 ++--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/linux-user/main.c b/linux-user/main.c
index c5878f9..bc1ff46 100644
--- a/linux-user/main.c
+++ b/linux-user/main.c
@@ -309,7 +309,6 @@ void cpu_loop(CPUX86State *env)
env->regs[8],
env->regs[9],
0, 0);
- env->eip = env->exception_next_eip;
break;
#endif
case EXCP0B_NOSEG:
diff --git a/target-i386/seg_helper.c b/target-i386/seg_helper.c
index 2d970d0..13eefba 100644
--- a/target-i386/seg_helper.c
+++ b/target-i386/seg_helper.c
@@ -1127,8 +1127,8 @@ static void do_interrupt_user(CPUX86State *env, int intno, int is_int,
/* Since we emulate only user space, we cannot do more than
exiting the emulation with the suitable exception and error
- code */
- if (is_int) {
+ code. So update EIP for INT 0x80 and EXCP_SYSCALL. */
+ if (is_int || intno == EXCP_SYSCALL) {
env->eip = next_eip;
}
}
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 05/24] linux-user: Fix conversion of sigevent argument to timer_create
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (3 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 04/24] linux-user: Fix syscall instruction usermode emulation on X86_64 riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 06/24] linux-user: fix readlink handling with magic exe symlink riku.voipio
` (19 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell
From: Peter Maydell <peter.maydell@linaro.org>
There were a number of bugs in the conversion of the sigevent
argument to timer_create from target to host format:
* signal number not converted from target to host
* thread ID not copied across
* sigev_value not copied across
* we never unlocked the struct when we were done
Between them, these problems meant that SIGEV_THREAD_ID
timers (and the glibc-implemented SIGEV_THREAD timers which
depend on them) didn't work.
Fix these problems and clean up the code a little by pulling
the struct conversion out into its own function, in line with
how we convert various other structs. This allows the test
program in bug LP:1042388 to run.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 38 ++++++++++++++++++++++++++++++--------
1 file changed, 30 insertions(+), 8 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index dd77673..fccf9f0 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4912,6 +4912,32 @@ static inline abi_long host_to_target_itimerspec(abi_ulong target_addr,
return 0;
}
+static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
+ abi_ulong target_addr)
+{
+ struct target_sigevent *target_sevp;
+
+ if (!lock_user_struct(VERIFY_READ, target_sevp, target_addr, 1)) {
+ return -TARGET_EFAULT;
+ }
+
+ /* This union is awkward on 64 bit systems because it has a 32 bit
+ * integer and a pointer in it; we follow the conversion approach
+ * used for handling sigval types in signal.c so the guest should get
+ * the correct value back even if we did a 64 bit byteswap and it's
+ * using the 32 bit integer.
+ */
+ host_sevp->sigev_value.sival_ptr =
+ (void *)(uintptr_t)tswapal(target_sevp->sigev_value.sival_ptr);
+ host_sevp->sigev_signo =
+ target_to_host_signal(tswap32(target_sevp->sigev_signo));
+ host_sevp->sigev_notify = tswap32(target_sevp->sigev_notify);
+ host_sevp->_sigev_un._tid = tswap32(target_sevp->_sigev_un._tid);
+
+ unlock_user_struct(target_sevp, target_addr, 1);
+ return 0;
+}
+
#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
static inline abi_long host_to_target_stat64(void *cpu_env,
abi_ulong target_addr,
@@ -9403,7 +9429,6 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
/* args: clockid_t clockid, struct sigevent *sevp, timer_t *timerid */
struct sigevent host_sevp = { {0}, }, *phost_sevp = NULL;
- struct target_sigevent *ptarget_sevp;
struct target_timer_t *ptarget_timer;
int clkid = arg1;
@@ -9415,14 +9440,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
timer_t *phtimer = g_posix_timers + timer_index;
if (arg2) {
- if (!lock_user_struct(VERIFY_READ, ptarget_sevp, arg2, 1)) {
- goto efault;
- }
-
- host_sevp.sigev_signo = tswap32(ptarget_sevp->sigev_signo);
- host_sevp.sigev_notify = tswap32(ptarget_sevp->sigev_notify);
-
phost_sevp = &host_sevp;
+ ret = target_to_host_sigevent(phost_sevp, arg2);
+ if (ret != 0) {
+ break;
+ }
}
ret = get_errno(timer_create(clkid, phost_sevp, phtimer));
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 06/24] linux-user: fix readlink handling with magic exe symlink
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (4 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 05/24] linux-user: Fix conversion of sigevent argument to timer_create riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 07/24] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
` (18 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Mike Frysinger
From: Mike Frysinger <vapier@chromium.org>
The current code always returns the length of the path when it should
be returning the number of bytes it wrote to the output string.
Further, readlink is not supposed to append a NUL byte, but the current
snprintf logic will always do just that.
Even further, if you pass in a length of 0, you're suppoesd to get back
an error (EINVAL), but the current logic just returns 0.
Further still, if there was an error reading the symlink, we should not
go ahead and try to read the target buffer as it is garbage.
Simple test for the first two issues:
$ cat test.c
int main() {
char buf[50];
size_t len;
for (len = 0; len < 10; ++len) {
memset(buf, '!', sizeof(buf));
ssize_t ret = readlink("/proc/self/exe", buf, len);
buf[20] = '\0';
printf("readlink(/proc/self/exe, {%s}, %zu) = %zi\n", buf, len, ret);
}
return 0;
}
Now compare the output of the native:
$ gcc test.c -o /tmp/x
$ /tmp/x
$ strace /tmp/x
With what qemu does:
$ armv7a-cros-linux-gnueabi-gcc test.c -o /tmp/x -static
$ qemu-arm /tmp/x
$ qemu-arm -strace /tmp/x
Signed-off-by: Mike Frysinger <vapier@chromium.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index fccf9f0..7c108ab 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -6636,11 +6636,22 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
p2 = lock_user(VERIFY_WRITE, arg2, arg3, 0);
if (!p || !p2) {
ret = -TARGET_EFAULT;
+ } else if (!arg3) {
+ /* Short circuit this for the magic exe check. */
+ ret = -TARGET_EINVAL;
} else if (is_proc_myself((const char *)p, "exe")) {
char real[PATH_MAX], *temp;
temp = realpath(exec_path, real);
- ret = temp == NULL ? get_errno(-1) : strlen(real) ;
- snprintf((char *)p2, arg3, "%s", real);
+ /* Return value is # of bytes that we wrote to the buffer. */
+ if (temp == NULL) {
+ ret = get_errno(-1);
+ } else {
+ /* Don't worry about sign mismatch as earlier mapping
+ * logic would have thrown a bad address error. */
+ ret = MIN(strlen(real), arg3);
+ /* We cannot NUL terminate the string. */
+ memcpy(p2, real, ret);
+ }
} else {
ret = get_errno(readlink(path(p), p2, arg3));
}
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 07/24] linux-user: support timerfd_{create, gettime, settime} syscalls
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (5 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 06/24] linux-user: fix readlink handling with magic exe symlink riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 08/24] linux-user: support ioprio_{get, set} syscalls riku.voipio
` (17 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
Adds support for the timerfd_create, timerfd_gettime & timerfd_settime
syscalls, allowing use of timerfds by target programs.
v2: By Riku - added configure check for timerfd and ifdefs
for benefit of old distributions like RHEL5.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
configure | 17 +++++++++++++++++
linux-user/strace.list | 9 +++++++++
linux-user/syscall.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 71 insertions(+)
diff --git a/configure b/configure
index f7685b5..577e2b9 100755
--- a/configure
+++ b/configure
@@ -3420,6 +3420,20 @@ if compile_prog "" "" ; then
sendfile=yes
fi
+# check for timerfd support (glibc 2.8 and newer)
+timerfd=no
+cat > $TMPC << EOF
+#include <sys/timerfd.h>
+
+int main(void)
+{
+ return(timerfd_create(CLOCK_REALTIME, 0));
+}
+EOF
+if compile_prog "" "" ; then
+ timerfd=yes
+fi
+
# Check if tools are available to build documentation.
if test "$docs" != "no" ; then
if has makeinfo && has pod2man; then
@@ -4486,6 +4500,9 @@ fi
if test "$sendfile" = "yes" ; then
echo "CONFIG_SENDFILE=y" >> $config_host_mak
fi
+if test "$timerfd" = "yes" ; then
+ echo "CONFIG_TIMERFD=y" >> $config_host_mak
+fi
if test "$inotify" = "yes" ; then
echo "CONFIG_INOTIFY=y" >> $config_host_mak
fi
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 7c108ab..44853d0 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>
@@ -9547,6 +9548,50 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
}
#endif
+#if defined(TARGET_NR_timerfd_create) && defined(CONFIG_TIMERFD)
+ case TARGET_NR_timerfd_create:
+ ret = get_errno(timerfd_create(arg1,
+ target_to_host_bitmask(arg2, fcntl_flags_tbl)));
+ break;
+#endif
+
+#if defined(TARGET_NR_timerfd_gettime) && defined(CONFIG_TIMERFD)
+ 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
+
+#if defined(TARGET_NR_timerfd_settime) && defined(CONFIG_TIMERFD)
+ 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.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 08/24] linux-user: support ioprio_{get, set} syscalls
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (6 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 07/24] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 09/24] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
` (16 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Paul Burton
From: Paul Burton <paul@archlinuxmips.org>
Add support for the ioprio_get & ioprio_set syscalls, allowing their
use by target programs.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 44853d0..f1c182b 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -252,6 +252,12 @@ _syscall2(int, capget, struct __user_cap_header_struct *, header,
struct __user_cap_data_struct *, data);
_syscall2(int, capset, struct __user_cap_header_struct *, header,
struct __user_cap_data_struct *, data);
+#if defined(TARGET_NR_ioprio_get) && defined(__NR_ioprio_get)
+_syscall2(int, ioprio_get, int, which, int, who)
+#endif
+#if defined(TARGET_NR_ioprio_set) && defined(__NR_ioprio_set)
+_syscall3(int, ioprio_set, int, which, int, who, int, ioprio)
+#endif
static bitmask_transtbl fcntl_flags_tbl[] = {
{ TARGET_O_ACCMODE, TARGET_O_WRONLY, O_ACCMODE, O_WRONLY, },
@@ -9592,6 +9598,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.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 09/24] linux-user: support {name_to, open_by}_handle_at syscalls
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (7 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 08/24] linux-user: support ioprio_{get, set} syscalls riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 10/24] linux-user: add setns and unshare riku.voipio
` (15 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
Implement support for the name_to_handle_at and open_by_handle_at
syscalls, allowing their use by the target program.
Modified by Riku - move syscalls to functions and put behind
the already existing CONFIG_OPEN_BY_HANDLE to avoid build failure
with old glibc's.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/strace.c | 30 ++++++++++++++++++++++
linux-user/strace.list | 6 +++++
linux-user/syscall.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 106 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 f1c182b..74c5d49 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -5362,6 +5362,66 @@ static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags,
return get_errno(sys_openat(dirfd, path(pathname), flags, mode));
}
+#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+static abi_long do_name_to_handle_at(abi_long arg1, abi_long arg2,
+ abi_long arg3, abi_long arg4, abi_long arg5)
+{
+ struct file_handle *fh;
+ uint32_t sz;
+ int mount_id;
+ abi_long ret;
+ char *p;
+
+ if (get_user_u32(sz, arg3)) {
+ return -TARGET_EFAULT;
+ }
+
+ p = lock_user_string(arg2);
+ if (!p) {
+ return -TARGET_EFAULT;
+ }
+
+ fh = lock_user(VERIFY_WRITE, arg3, sizeof(*fh) + sz, 1);
+ if (!fh) {
+ unlock_user(p, arg2, 0);
+ return -TARGET_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)) {
+ return -TARGET_EFAULT;
+ }
+ return ret;
+
+}
+#endif
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+static abi_long do_open_by_handle_at(abi_long arg1, abi_long arg2, abi_long arg3)
+{
+ struct file_handle *fh;
+ uint32_t sz;
+ abi_long ret;
+ char *p;
+
+ if (get_user_u32(sz, arg2)) {
+ return -TARGET_EFAULT;
+ }
+
+ fh = lock_user(VERIFY_WRITE, arg2, sizeof(*fh) + sz, 1);
+ if (!fh) {
+ return -TARGET_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);
+ return ret;
+}
+#endif
/* do_syscall() should always have a single exit point at the end so
that actions, such as logging of syscall results, can be performed.
@@ -5448,6 +5508,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
arg4));
unlock_user(p, arg2, 0);
break;
+#if defined(TARGET_NR_name_to_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+ case TARGET_NR_name_to_handle_at:
+ ret = do_name_to_handle_at(arg1, arg2, arg3, arg4, arg5);
+ break;
+#endif
+#if defined(TARGET_NR_open_by_handle_at) && defined(CONFIG_OPEN_BY_HANDLE)
+ case TARGET_NR_open_by_handle_at:
+ ret = do_open_by_handle_at(arg1, arg2, arg3);
+ break;
+#endif
case TARGET_NR_close:
ret = get_errno(close(arg1));
break;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 10/24] linux-user: add setns and unshare
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (8 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 09/24] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 11/24] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2 riku.voipio
` (14 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Riku Voipio
From: Riku Voipio <riku.voipio@linaro.org>
Add support for the setns and unshare syscalls, trivially passed through to
the host. Based on patches by Paul Burton, added configure check.
Signed-off-by: Paul Burton <paul@archlinuxmips.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
configure | 20 ++++++++++++++++++++
linux-user/strace.list | 3 +++
linux-user/syscall.c | 11 +++++++++++
3 files changed, 34 insertions(+)
diff --git a/configure b/configure
index 577e2b9..f6de265 100755
--- a/configure
+++ b/configure
@@ -3434,6 +3434,23 @@ if compile_prog "" "" ; then
timerfd=yes
fi
+# check for setns and unshare support
+setns=no
+cat > $TMPC << EOF
+#include <sched.h>
+
+int main(void)
+{
+ int ret;
+ ret = setns(0, 0);
+ ret = unshare(0);
+ return ret;
+}
+EOF
+if compile_prog "" "" ; then
+ setns=yes
+fi
+
# Check if tools are available to build documentation.
if test "$docs" != "no" ; then
if has makeinfo && has pod2man; then
@@ -4503,6 +4520,9 @@ fi
if test "$timerfd" = "yes" ; then
echo "CONFIG_TIMERFD=y" >> $config_host_mak
fi
+if test "$setns" = "yes" ; then
+ echo "CONFIG_SETNS=y" >> $config_host_mak
+fi
if test "$inotify" = "yes" ; then
echo "CONFIG_INOTIFY=y" >> $config_host_mak
fi
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 74c5d49..e5c3ebb 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9680,6 +9680,17 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
break;
#endif
+#if defined(TARGET_NR_setns) && defined(CONFIG_SETNS)
+ case TARGET_NR_setns:
+ ret = get_errno(setns(arg1, arg2));
+ break;
+#endif
+#if defined(TARGET_NR_unshare) && defined(CONFIG_SETNS)
+ case TARGET_NR_unshare:
+ ret = get_errno(unshare(arg1));
+ break;
+#endif
+
default:
unimplemented:
gemu_log("qemu: Unsupported syscall: %d\n", num);
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 11/24] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (9 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 10/24] linux-user: add setns and unshare riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 12/24] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call riku.voipio
` (13 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The 64 bit PowerPC platforms eliminate the _unused1 and _unused2
elements of the semid_ds structure from <sys/sem.h>. So eliminate
these from the target_semid_ds structure.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e5c3ebb..239e682 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2424,9 +2424,13 @@ struct target_semid_ds
{
struct target_ipc_perm sem_perm;
abi_ulong sem_otime;
+#if !defined(TARGET_PPC64)
abi_ulong __unused1;
+#endif
abi_ulong sem_ctime;
+#if !defined(TARGET_PPC64)
abi_ulong __unused2;
+#endif
abi_ulong sem_nsems;
abi_ulong __unused3;
abi_ulong __unused4;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 12/24] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (10 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 11/24] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2 riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 13/24] linux-user: Properly Handle semun Structure In Cross-Endian Situations riku.voipio
` (12 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
When the ipc system call is used to wrap a semctl system call,
the ptr argument to ipc needs to be dereferenced prior to passing
it to the semctl handler. This is because the fourth argument to
semctl is a union and not a pointer to a union.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 239e682..0113250 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3140,9 +3140,15 @@ static abi_long do_ipc(unsigned int call, int first,
ret = get_errno(semget(first, second, third));
break;
- case IPCOP_semctl:
- ret = do_semctl(first, second, third, (union target_semun)(abi_ulong) ptr);
+ case IPCOP_semctl: {
+ /* The semun argument to semctl is passed by value, so dereference the
+ * ptr argument. */
+ abi_ulong atptr;
+ get_user_ual(atptr, (abi_ulong)ptr);
+ ret = do_semctl(first, second, third,
+ (union target_semun)(abi_ulong) atptr);
break;
+ }
case IPCOP_msgget:
ret = get_errno(msgget(first, second));
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 13/24] linux-user: Properly Handle semun Structure In Cross-Endian Situations
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (11 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 12/24] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 14/24] linux-user: Make ipc syscall's third argument an abi_long riku.voipio
` (11 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The semun union used in the semctl system call contains both an int (val) and
pointers. In cross-endian situations on 64 bit targets, the value passed to
semctl is an 8 byte (abi_long) value and thus does not have the 4-byte val
field in the correct location. In order to rectify this, the other half
of the union must be accessed. This is achieved in code by performing
a byte swap on the entire 8 byte union, followed by a 4-byte swap of the
first half.
Also, eliminate an extraneous (dead) line of code that sets target_su.val in
the IPC_SET/IPC_GET case.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 0113250..ba9dfc5 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2652,9 +2652,18 @@ static inline abi_long do_semctl(int semid, int semnum, int cmd,
switch( cmd ) {
case GETVAL:
case SETVAL:
- arg.val = tswap32(target_su.val);
+ /* In 64 bit cross-endian situations, we will erroneously pick up
+ * the wrong half of the union for the "val" element. To rectify
+ * this, the entire 8-byte structure is byteswapped, followed by
+ * a swap of the 4 byte val field. In other cases, the data is
+ * already in proper host byte order. */
+ if (sizeof(target_su.val) != (sizeof(target_su.buf))) {
+ target_su.buf = tswapal(target_su.buf);
+ arg.val = tswap32(target_su.val);
+ } else {
+ arg.val = target_su.val;
+ }
ret = get_errno(semctl(semid, semnum, cmd, arg));
- target_su.val = tswap32(arg.val);
break;
case GETALL:
case SETALL:
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 14/24] linux-user: Make ipc syscall's third argument an abi_long
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (12 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 13/24] linux-user: Properly Handle semun Structure In Cross-Endian Situations riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 15/24] linux-user: Conditionally Pass Attribute Pointer to mq_open() riku.voipio
` (10 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
For those target ABIs that use the ipc system call (e.g. POWER),
the third argument is used in the shmat path as a pointer. It
therefore must be declared as an abi_long (versus int) so that
the address bits are not lost in truncation. In fact, all arguments
to do_ipc should be declared as abit_long.
In fact, it makes more sense for all of the arguments to be declaried
as abi_long (except call).
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index ba9dfc5..db40829 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -3130,8 +3130,8 @@ static inline abi_long do_shmdt(abi_ulong shmaddr)
#ifdef TARGET_NR_ipc
/* ??? This only works with linear mappings. */
/* do_ipc() must return target values and target errnos. */
-static abi_long do_ipc(unsigned int call, int first,
- int second, int third,
+static abi_long do_ipc(unsigned int call, abi_long first,
+ abi_long second, abi_long third,
abi_long ptr, abi_long fifth)
{
int version;
@@ -3153,9 +3153,9 @@ static abi_long do_ipc(unsigned int call, int first,
/* The semun argument to semctl is passed by value, so dereference the
* ptr argument. */
abi_ulong atptr;
- get_user_ual(atptr, (abi_ulong)ptr);
+ get_user_ual(atptr, ptr);
ret = do_semctl(first, second, third,
- (union target_semun)(abi_ulong) atptr);
+ (union target_semun) atptr);
break;
}
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 15/24] linux-user: Conditionally Pass Attribute Pointer to mq_open()
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (13 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 14/24] linux-user: Make ipc syscall's third argument an abi_long riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 16/24] linux-user: Detect Negative Message Sizes in msgsnd System Call riku.voipio
` (9 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The mq_open system call takes an optional struct mq_attr pointer
argument in the fourth position. This pointer is used when O_CREAT
is specified in the flags (second) argument. It may be NULL, in
which case the queue is created with implementation defined attributes.
Change the code to properly handle the case when NULL is passed in the
arg4 position.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index db40829..c9a9d3d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9185,12 +9185,16 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#if defined(TARGET_NR_mq_open) && defined(__NR_mq_open)
case TARGET_NR_mq_open:
{
- struct mq_attr posix_mq_attr;
+ struct mq_attr posix_mq_attr, *attrp;
p = lock_user_string(arg1 - 1);
- if (arg4 != 0)
+ if (arg4 != 0) {
copy_from_user_mq_attr (&posix_mq_attr, arg4);
- ret = get_errno(mq_open(p, arg2, arg3, &posix_mq_attr));
+ attrp = &posix_mq_attr;
+ } else {
+ attrp = 0;
+ }
+ ret = get_errno(mq_open(p, arg2, arg3, attrp));
unlock_user (p, arg1, 0);
}
break;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 16/24] linux-user: Detect Negative Message Sizes in msgsnd System Call
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (14 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 15/24] linux-user: Conditionally Pass Attribute Pointer to mq_open() riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 17/24] linux-user: Handle NULL sched_param argument to sched_* riku.voipio
` (8 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The msgsnd system call takes an argument that describes the message
size (msgsz) and is of type size_t. The system call should set
errno to EINVAL in the event that a negative message size is passed.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c9a9d3d..d223cff 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2879,12 +2879,16 @@ struct target_msgbuf {
};
static inline abi_long do_msgsnd(int msqid, abi_long msgp,
- unsigned int msgsz, int msgflg)
+ ssize_t msgsz, int msgflg)
{
struct target_msgbuf *target_mb;
struct msgbuf *host_mb;
abi_long ret = 0;
+ if (msgsz < 0) {
+ return -TARGET_EINVAL;
+ }
+
if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
return -TARGET_EFAULT;
host_mb = malloc(msgsz+sizeof(long));
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 17/24] linux-user: Handle NULL sched_param argument to sched_*
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (15 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 16/24] linux-user: Detect Negative Message Sizes in msgsnd System Call riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 18/24] linux-user: Detect fault in sched_rr_get_interval riku.voipio
` (7 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The sched_getparam, sched_setparam and sched_setscheduler system
calls take a pointer argument to a sched_param structure. When
this pointer is null, errno should be set to EINVAL.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index d223cff..a0436da 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7806,6 +7806,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
struct sched_param *target_schp;
struct sched_param schp;
+ if (arg2 == 0) {
+ return -TARGET_EINVAL;
+ }
if (!lock_user_struct(VERIFY_READ, target_schp, arg2, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
@@ -7817,6 +7820,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct sched_param *target_schp;
struct sched_param schp;
+
+ if (arg2 == 0) {
+ return -TARGET_EINVAL;
+ }
ret = get_errno(sched_getparam(arg1, &schp));
if (!is_error(ret)) {
if (!lock_user_struct(VERIFY_WRITE, target_schp, arg2, 0))
@@ -7830,6 +7837,9 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
{
struct sched_param *target_schp;
struct sched_param schp;
+ if (arg3 == 0) {
+ return -TARGET_EINVAL;
+ }
if (!lock_user_struct(VERIFY_READ, target_schp, arg3, 1))
goto efault;
schp.sched_priority = tswap32(target_schp->sched_priority);
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 18/24] linux-user: Detect fault in sched_rr_get_interval
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (16 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 17/24] linux-user: Handle NULL sched_param argument to sched_* riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 19/24] linux-user: Move get_ppc64_abi riku.voipio
` (6 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
Properly detect a fault when attempting to store into an invalid
struct timespec pointer.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a0436da..a24356d 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -7864,7 +7864,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
struct timespec ts;
ret = get_errno(sched_rr_get_interval(arg1, &ts));
if (!is_error(ret)) {
- host_to_target_timespec(arg2, &ts);
+ ret = host_to_target_timespec(arg2, &ts);
}
}
break;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 19/24] linux-user: Move get_ppc64_abi
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (17 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 18/24] linux-user: Detect fault in sched_rr_get_interval riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 20/24] linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2 riku.voipio
` (5 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The get_ppc64_abi is used to determine the ELF ABI (i.e. V1 or V2). This
routine is currently implemented in the linux-user/elfload.c file but
is useful in other scenarios. Move the routine to a more generally
available location (linux-user/ppc/target_cpu.h).
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/elfload.c | 9 ---------
linux-user/ppc/target_cpu.h | 10 ++++++++++
2 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/linux-user/elfload.c b/linux-user/elfload.c
index 60777fe..bea803b 100644
--- a/linux-user/elfload.c
+++ b/linux-user/elfload.c
@@ -824,8 +824,6 @@ static uint32_t get_elf_hwcap2(void)
NEW_AUX_ENT(AT_IGNOREPPC, AT_IGNOREPPC); \
} while (0)
-static inline uint32_t get_ppc64_abi(struct image_info *infop);
-
static inline void init_thread(struct target_pt_regs *_regs, struct image_info *infop)
{
_regs->gpr[1] = infop->start_stack;
@@ -1205,13 +1203,6 @@ static inline void init_thread(struct target_pt_regs *regs, struct image_info *i
#include "elf.h"
-#ifdef TARGET_PPC
-static inline uint32_t get_ppc64_abi(struct image_info *infop)
-{
- return infop->elf_flags & EF_PPC64_ABI;
-}
-#endif
-
struct exec
{
unsigned int a_info; /* Use macros N_MAGIC, etc for access */
diff --git a/linux-user/ppc/target_cpu.h b/linux-user/ppc/target_cpu.h
index 9cc0c3b..26f4ba2 100644
--- a/linux-user/ppc/target_cpu.h
+++ b/linux-user/ppc/target_cpu.h
@@ -38,4 +38,14 @@ static inline void cpu_set_tls(CPUPPCState *env, target_ulong newtls)
#endif
}
+#ifndef EF_PPC64_ABI
+#define EF_PPC64_ABI 0x3
+#endif
+
+static inline uint32_t get_ppc64_abi(struct image_info *infop)
+{
+ return infop->elf_flags & EF_PPC64_ABI;
+}
+
+
#endif
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 20/24] linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (18 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 19/24] linux-user: Move get_ppc64_abi riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 21/24] linux-user: clock_nanosleep errno Handling on PPC riku.voipio
` (4 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The ELF V2 ABI for PPC64 defines MINSIGSTKSZ as 4096 bytes whereas it was
2048 previously.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/aarch64/syscall.h | 1 +
linux-user/alpha/syscall.h | 1 +
linux-user/arm/syscall.h | 2 ++
linux-user/cris/syscall.h | 1 +
linux-user/i386/syscall.h | 1 +
linux-user/m68k/syscall.h | 2 ++
linux-user/microblaze/syscall.h | 1 +
linux-user/mips/syscall.h | 1 +
linux-user/mips64/syscall.h | 1 +
linux-user/openrisc/syscall.h | 2 ++
linux-user/ppc/syscall.h | 2 ++
linux-user/s390x/syscall.h | 1 +
linux-user/sh4/syscall.h | 2 ++
linux-user/signal.c | 12 +++++++++++-
linux-user/sparc/syscall.h | 1 +
linux-user/sparc64/syscall.h | 1 +
linux-user/unicore32/syscall.h | 2 ++
linux-user/x86_64/syscall.h | 1 +
18 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/linux-user/aarch64/syscall.h b/linux-user/aarch64/syscall.h
index 18f44a8..d1f4823 100644
--- a/linux-user/aarch64/syscall.h
+++ b/linux-user/aarch64/syscall.h
@@ -8,3 +8,4 @@ struct target_pt_regs {
#define UNAME_MACHINE "aarch64"
#define UNAME_MINIMUM_RELEASE "3.8.0"
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/alpha/syscall.h b/linux-user/alpha/syscall.h
index ed13d9a..3adedeb 100644
--- a/linux-user/alpha/syscall.h
+++ b/linux-user/alpha/syscall.h
@@ -252,3 +252,4 @@ struct target_pt_regs {
#define TARGET_UAC_NOPRINT 1
#define TARGET_UAC_NOFIX 2
#define TARGET_UAC_SIGBUS 4
+#define TARGET_MINSIGSTKSZ 4096
diff --git a/linux-user/arm/syscall.h b/linux-user/arm/syscall.h
index e0d2cc3..cdadb0c 100644
--- a/linux-user/arm/syscall.h
+++ b/linux-user/arm/syscall.h
@@ -44,3 +44,5 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS
+
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h
index f5783c0..a75bcc4 100644
--- a/linux-user/cris/syscall.h
+++ b/linux-user/cris/syscall.h
@@ -39,5 +39,6 @@ struct target_pt_regs {
};
#define TARGET_CLONE_BACKWARDS2
+#define TARGET_MINSIGSTKSZ 2048
#endif
diff --git a/linux-user/i386/syscall.h b/linux-user/i386/syscall.h
index 9bfc1ad..acf6856 100644
--- a/linux-user/i386/syscall.h
+++ b/linux-user/i386/syscall.h
@@ -147,3 +147,4 @@ struct target_vm86plus_struct {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/syscall.h
index 889eaf7..f8553f8 100644
--- a/linux-user/m68k/syscall.h
+++ b/linux-user/m68k/syscall.h
@@ -18,4 +18,6 @@ struct target_pt_regs {
#define UNAME_MACHINE "m68k"
#define UNAME_MINIMUM_RELEASE "2.6.32"
+#define TARGET_MINSIGSTKSZ 2048
+
void do_m68k_simcall(CPUM68KState *, int);
diff --git a/linux-user/microblaze/syscall.h b/linux-user/microblaze/syscall.h
index 5b5f6b4..2a5e160 100644
--- a/linux-user/microblaze/syscall.h
+++ b/linux-user/microblaze/syscall.h
@@ -49,5 +49,6 @@ struct target_pt_regs {
};
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 2048
#endif
diff --git a/linux-user/mips/syscall.h b/linux-user/mips/syscall.h
index 5bc5696..0b4662c 100644
--- a/linux-user/mips/syscall.h
+++ b/linux-user/mips/syscall.h
@@ -228,3 +228,4 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/mips64/syscall.h b/linux-user/mips64/syscall.h
index a7f5a58..39b8bed 100644
--- a/linux-user/mips64/syscall.h
+++ b/linux-user/mips64/syscall.h
@@ -225,3 +225,4 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/openrisc/syscall.h b/linux-user/openrisc/syscall.h
index c3b36da..e5e6180 100644
--- a/linux-user/openrisc/syscall.h
+++ b/linux-user/openrisc/syscall.h
@@ -23,3 +23,5 @@ struct target_pt_regs {
#define UNAME_MACHINE "openrisc"
#define UNAME_MINIMUM_RELEASE "2.6.32"
+
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/ppc/syscall.h b/linux-user/ppc/syscall.h
index db92bbe..5311cc6 100644
--- a/linux-user/ppc/syscall.h
+++ b/linux-user/ppc/syscall.h
@@ -69,3 +69,5 @@ struct target_revectored_struct {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS
+
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/s390x/syscall.h b/linux-user/s390x/syscall.h
index aaad512..b11a3b2 100644
--- a/linux-user/s390x/syscall.h
+++ b/linux-user/s390x/syscall.h
@@ -24,3 +24,4 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_CLONE_BACKWARDS2
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/sh4/syscall.h b/linux-user/sh4/syscall.h
index ccd2216..285ecf3 100644
--- a/linux-user/sh4/syscall.h
+++ b/linux-user/sh4/syscall.h
@@ -11,3 +11,5 @@ struct target_pt_regs {
#define UNAME_MACHINE "sh4"
#define UNAME_MINIMUM_RELEASE "2.6.32"
+
+#define TARGET_MINSIGSTKSZ 2048
diff --git a/linux-user/signal.c b/linux-user/signal.c
index 1141054..26929c5 100644
--- a/linux-user/signal.c
+++ b/linux-user/signal.c
@@ -617,6 +617,15 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp)
{
struct target_sigaltstack *uss;
struct target_sigaltstack ss;
+ size_t minstacksize = TARGET_MINSIGSTKSZ;
+
+#if defined(TARGET_PPC64)
+ /* ELF V2 for PPC64 has a 4K minimum stack size for signal handlers */
+ struct image_info *image = ((TaskState *)thread_cpu->opaque)->info;
+ if (get_ppc64_abi(image) > 1) {
+ minstacksize = 4096;
+ }
+#endif
ret = -TARGET_EFAULT;
if (!lock_user_struct(VERIFY_READ, uss, uss_addr, 1)) {
@@ -642,8 +651,9 @@ abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp)
ss.ss_sp = 0;
} else {
ret = -TARGET_ENOMEM;
- if (ss.ss_size < MINSIGSTKSZ)
+ if (ss.ss_size < minstacksize) {
goto out;
+ }
}
target_sigaltstack_used.ss_sp = ss.ss_sp;
diff --git a/linux-user/sparc/syscall.h b/linux-user/sparc/syscall.h
index 9549ea0..ae40744 100644
--- a/linux-user/sparc/syscall.h
+++ b/linux-user/sparc/syscall.h
@@ -15,3 +15,4 @@ struct target_pt_regs {
* and copy_thread().
*/
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 4096
diff --git a/linux-user/sparc64/syscall.h b/linux-user/sparc64/syscall.h
index 82b1680..816a00f 100644
--- a/linux-user/sparc64/syscall.h
+++ b/linux-user/sparc64/syscall.h
@@ -16,3 +16,4 @@ struct target_pt_regs {
* and copy_thread().
*/
#define TARGET_CLONE_BACKWARDS
+#define TARGET_MINSIGSTKSZ 4096
diff --git a/linux-user/unicore32/syscall.h b/linux-user/unicore32/syscall.h
index f7e5525..3ed6237 100644
--- a/linux-user/unicore32/syscall.h
+++ b/linux-user/unicore32/syscall.h
@@ -53,4 +53,6 @@ struct target_pt_regs {
#define UNAME_MACHINE "UniCore-II"
#define UNAME_MINIMUM_RELEASE "2.6.32"
+#define TARGET_MINSIGSTKSZ 2048
+
#endif /* __UC32_SYSCALL_H__ */
diff --git a/linux-user/x86_64/syscall.h b/linux-user/x86_64/syscall.h
index e03b5a0..5828b91 100644
--- a/linux-user/x86_64/syscall.h
+++ b/linux-user/x86_64/syscall.h
@@ -97,3 +97,4 @@ struct target_msqid64_ds {
#define TARGET_ARCH_SET_FS 0x1002
#define TARGET_ARCH_GET_FS 0x1003
#define TARGET_ARCH_GET_GS 0x1004
+#define TARGET_MINSIGSTKSZ 2048
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 21/24] linux-user: clock_nanosleep errno Handling on PPC
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (19 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 20/24] linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2 riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 22/24] linux-user: Support target-to-host translation of mlockall argument riku.voipio
` (3 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The clock_nanosleep syscall is unusual in that it returns positive
numbers in error handling situations, versus returning -1 and setting
errno, or returning a negative errno value. On POWER, the kernel will
set the SO bit of CR0 to indicate failure in a syscall. QEMU has
generic handling to do this for syscalls with standard return values.
Add special case code for clock_nanosleep to handle CR0 properly.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index a24356d..e4be32c 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -9103,6 +9103,14 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
ret = get_errno(clock_nanosleep(arg1, arg2, &ts, arg4 ? &ts : NULL));
if (arg4)
host_to_target_timespec(arg4, &ts);
+
+#if defined(TARGET_PPC)
+ /* clock_nanosleep is odd in that it returns positive errno values.
+ * On PPC, CR0 bit 3 should be set in such a situation. */
+ if (ret) {
+ ((CPUPPCState *)cpu_env)->crf[0] |= 1;
+ }
+#endif
break;
}
#endif
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 22/24] linux-user: Support target-to-host translation of mlockall argument
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (20 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 21/24] linux-user: clock_nanosleep errno Handling on PPC riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 23/24] linux-user: writev Partial Writes riku.voipio
` (2 subsequent siblings)
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
The argument to the mlockall system call is not necessarily the same on
all platforms and thus may require translation prior to passing to the
host.
For example, PowerPC 64 bit platforms define values for MCL_CURRENT
(0x2000) and MCL_FUTURE (0x4000) which are different from Intel platforms
(0x1 and 0x2, respectively)
Signed-off-by: Tom Musta <tommusta@gmail.com>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/aarch64/syscall.h | 2 ++
linux-user/alpha/syscall.h | 2 ++
linux-user/arm/syscall.h | 2 ++
linux-user/cris/syscall.h | 2 ++
linux-user/i386/syscall.h | 2 ++
linux-user/m68k/syscall.h | 2 ++
linux-user/microblaze/syscall.h | 2 ++
linux-user/mips/syscall.h | 2 ++
linux-user/mips64/syscall.h | 2 ++
linux-user/openrisc/syscall.h | 2 ++
linux-user/ppc/syscall.h | 2 ++
linux-user/s390x/syscall.h | 2 ++
linux-user/sh4/syscall.h | 2 ++
linux-user/sparc/syscall.h | 2 ++
linux-user/sparc64/syscall.h | 2 ++
linux-user/syscall.c | 17 ++++++++++++++++-
linux-user/unicore32/syscall.h | 2 ++
linux-user/x86_64/syscall.h | 2 ++
18 files changed, 50 insertions(+), 1 deletion(-)
diff --git a/linux-user/aarch64/syscall.h b/linux-user/aarch64/syscall.h
index d1f4823..dc72a15 100644
--- a/linux-user/aarch64/syscall.h
+++ b/linux-user/aarch64/syscall.h
@@ -9,3 +9,5 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "3.8.0"
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/alpha/syscall.h b/linux-user/alpha/syscall.h
index 3adedeb..245cff2 100644
--- a/linux-user/alpha/syscall.h
+++ b/linux-user/alpha/syscall.h
@@ -253,3 +253,5 @@ struct target_pt_regs {
#define TARGET_UAC_NOFIX 2
#define TARGET_UAC_SIGBUS 4
#define TARGET_MINSIGSTKSZ 4096
+#define TARGET_MLOCKALL_MCL_CURRENT 0x2000
+#define TARGET_MLOCKALL_MCL_FUTURE 0x4000
diff --git a/linux-user/arm/syscall.h b/linux-user/arm/syscall.h
index cdadb0c..3844a96 100644
--- a/linux-user/arm/syscall.h
+++ b/linux-user/arm/syscall.h
@@ -46,3 +46,5 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/cris/syscall.h b/linux-user/cris/syscall.h
index a75bcc4..2957b0d 100644
--- a/linux-user/cris/syscall.h
+++ b/linux-user/cris/syscall.h
@@ -40,5 +40,7 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS2
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
#endif
diff --git a/linux-user/i386/syscall.h b/linux-user/i386/syscall.h
index acf6856..906aaac 100644
--- a/linux-user/i386/syscall.h
+++ b/linux-user/i386/syscall.h
@@ -148,3 +148,5 @@ struct target_vm86plus_struct {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/m68k/syscall.h b/linux-user/m68k/syscall.h
index f8553f8..9218493 100644
--- a/linux-user/m68k/syscall.h
+++ b/linux-user/m68k/syscall.h
@@ -19,5 +19,7 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
void do_m68k_simcall(CPUM68KState *, int);
diff --git a/linux-user/microblaze/syscall.h b/linux-user/microblaze/syscall.h
index 2a5e160..3c1ed27 100644
--- a/linux-user/microblaze/syscall.h
+++ b/linux-user/microblaze/syscall.h
@@ -50,5 +50,7 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
#endif
diff --git a/linux-user/mips/syscall.h b/linux-user/mips/syscall.h
index 0b4662c..35ca23b 100644
--- a/linux-user/mips/syscall.h
+++ b/linux-user/mips/syscall.h
@@ -229,3 +229,5 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/mips64/syscall.h b/linux-user/mips64/syscall.h
index 39b8bed..6733107 100644
--- a/linux-user/mips64/syscall.h
+++ b/linux-user/mips64/syscall.h
@@ -226,3 +226,5 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/openrisc/syscall.h b/linux-user/openrisc/syscall.h
index e5e6180..8ac0365 100644
--- a/linux-user/openrisc/syscall.h
+++ b/linux-user/openrisc/syscall.h
@@ -25,3 +25,5 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/ppc/syscall.h b/linux-user/ppc/syscall.h
index 5311cc6..0daf5cd 100644
--- a/linux-user/ppc/syscall.h
+++ b/linux-user/ppc/syscall.h
@@ -71,3 +71,5 @@ struct target_revectored_struct {
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 0x2000
+#define TARGET_MLOCKALL_MCL_FUTURE 0x4000
diff --git a/linux-user/s390x/syscall.h b/linux-user/s390x/syscall.h
index b11a3b2..35f170a 100644
--- a/linux-user/s390x/syscall.h
+++ b/linux-user/s390x/syscall.h
@@ -25,3 +25,5 @@ struct target_pt_regs {
#define TARGET_CLONE_BACKWARDS2
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/sh4/syscall.h b/linux-user/sh4/syscall.h
index 285ecf3..7aa4f23 100644
--- a/linux-user/sh4/syscall.h
+++ b/linux-user/sh4/syscall.h
@@ -13,3 +13,5 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
diff --git a/linux-user/sparc/syscall.h b/linux-user/sparc/syscall.h
index ae40744..58573b9 100644
--- a/linux-user/sparc/syscall.h
+++ b/linux-user/sparc/syscall.h
@@ -16,3 +16,5 @@ struct target_pt_regs {
*/
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 4096
+#define TARGET_MLOCKALL_MCL_CURRENT 0x2000
+#define TARGET_MLOCKALL_MCL_FUTURE 0x4000
diff --git a/linux-user/sparc64/syscall.h b/linux-user/sparc64/syscall.h
index 816a00f..8398d3f 100644
--- a/linux-user/sparc64/syscall.h
+++ b/linux-user/sparc64/syscall.h
@@ -17,3 +17,5 @@ struct target_pt_regs {
*/
#define TARGET_CLONE_BACKWARDS
#define TARGET_MINSIGSTKSZ 4096
+#define TARGET_MLOCKALL_MCL_CURRENT 0x2000
+#define TARGET_MLOCKALL_MCL_FUTURE 0x4000
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index e4be32c..c4f6454 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -4968,6 +4968,21 @@ static inline abi_long target_to_host_sigevent(struct sigevent *host_sevp,
return 0;
}
+#if defined(TARGET_NR_mlockall)
+static inline int target_to_host_mlockall_arg(int arg)
+{
+ int result = 0;
+
+ if (arg & TARGET_MLOCKALL_MCL_CURRENT) {
+ result |= MCL_CURRENT;
+ }
+ if (arg & TARGET_MLOCKALL_MCL_FUTURE) {
+ result |= MCL_FUTURE;
+ }
+ return result;
+}
+#endif
+
#if defined(TARGET_NR_stat64) || defined(TARGET_NR_newfstatat)
static inline abi_long host_to_target_stat64(void *cpu_env,
abi_ulong target_addr,
@@ -6890,7 +6905,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
#endif
#ifdef TARGET_NR_mlockall
case TARGET_NR_mlockall:
- ret = get_errno(mlockall(arg1));
+ ret = get_errno(mlockall(target_to_host_mlockall_arg(arg1)));
break;
#endif
#ifdef TARGET_NR_munlockall
diff --git a/linux-user/unicore32/syscall.h b/linux-user/unicore32/syscall.h
index 3ed6237..385a975 100644
--- a/linux-user/unicore32/syscall.h
+++ b/linux-user/unicore32/syscall.h
@@ -54,5 +54,7 @@ struct target_pt_regs {
#define UNAME_MINIMUM_RELEASE "2.6.32"
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
#endif /* __UC32_SYSCALL_H__ */
diff --git a/linux-user/x86_64/syscall.h b/linux-user/x86_64/syscall.h
index 5828b91..88b3c3f 100644
--- a/linux-user/x86_64/syscall.h
+++ b/linux-user/x86_64/syscall.h
@@ -98,3 +98,5 @@ struct target_msqid64_ds {
#define TARGET_ARCH_GET_FS 0x1003
#define TARGET_ARCH_GET_GS 0x1004
#define TARGET_MINSIGSTKSZ 2048
+#define TARGET_MLOCKALL_MCL_CURRENT 1
+#define TARGET_MLOCKALL_MCL_FUTURE 2
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 23/24] linux-user: writev Partial Writes
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (21 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 22/24] linux-user: Support target-to-host translation of mlockall argument riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 24/24] linux-user: check return value of malloc() riku.voipio
2014-08-15 17:49 ` [Qemu-devel] [PULL 00/24] Linux-user updates Peter Maydell
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, Tom Musta
From: Tom Musta <tommusta@gmail.com>
Although not technically not required by POSIX, the writev system call will
typically write out its buffers individually. That is, if the first buffer
is written successfully, but the second buffer pointer is invalid, then
the first chuck will be written and its size is returned.
Signed-off-by: Tom Musta <tommusta@gmail.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index c4f6454..3b1beff 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -1803,6 +1803,7 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
abi_ulong total_len, max_len;
int i;
int err = 0;
+ bool bad_address = false;
if (count == 0) {
errno = 0;
@@ -1843,9 +1844,20 @@ static struct iovec *lock_iovec(int type, abi_ulong target_addr,
vec[i].iov_base = 0;
} else {
vec[i].iov_base = lock_user(type, base, len, copy);
+ /* If the first buffer pointer is bad, this is a fault. But
+ * subsequent bad buffers will result in a partial write; this
+ * is realized by filling the vector with null pointers and
+ * zero lengths. */
if (!vec[i].iov_base) {
- err = EFAULT;
- goto fail;
+ if (i == 0) {
+ err = EFAULT;
+ goto fail;
+ } else {
+ bad_address = true;
+ }
+ }
+ if (bad_address) {
+ len = 0;
}
if (len > max_len - total_len) {
len = max_len - total_len;
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* [Qemu-devel] [PULL 24/24] linux-user: check return value of malloc()
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (22 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 23/24] linux-user: writev Partial Writes riku.voipio
@ 2014-08-15 11:01 ` riku.voipio
2014-08-15 17:49 ` [Qemu-devel] [PULL 00/24] Linux-user updates Peter Maydell
24 siblings, 0 replies; 37+ messages in thread
From: riku.voipio @ 2014-08-15 11:01 UTC (permalink / raw)
To: qemu-devel; +Cc: Peter Maydell, zhanghailiang
From: zhanghailiang <zhang.zhanghailiang@huawei.com>
Signed-off-by: zhanghailiang <zhang.zhanghailiang@huawei.com>
Acked-by: Riku Voipio <riku.voipio@linaro.org>
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
---
linux-user/syscall.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/linux-user/syscall.c b/linux-user/syscall.c
index 3b1beff..3aaed81 100644
--- a/linux-user/syscall.c
+++ b/linux-user/syscall.c
@@ -2904,6 +2904,10 @@ static inline abi_long do_msgsnd(int msqid, abi_long msgp,
if (!lock_user_struct(VERIFY_READ, target_mb, msgp, 0))
return -TARGET_EFAULT;
host_mb = malloc(msgsz+sizeof(long));
+ if (!host_mb) {
+ unlock_user_struct(target_mb, msgp, 0);
+ return -TARGET_ENOMEM;
+ }
host_mb->mtype = (abi_long) tswapal(target_mb->mtype);
memcpy(host_mb->mtext, target_mb->mtext, msgsz);
ret = get_errno(msgsnd(msqid, host_mb, msgsz, msgflg));
--
2.0.1
^ permalink raw reply related [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
` (23 preceding siblings ...)
2014-08-15 11:01 ` [Qemu-devel] [PULL 24/24] linux-user: check return value of malloc() riku.voipio
@ 2014-08-15 17:49 ` Peter Maydell
2014-08-18 8:46 ` Riku Voipio
24 siblings, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2014-08-15 17:49 UTC (permalink / raw)
To: Riku Voipio; +Cc: QEMU Developers
On 15 August 2014 12:01, <riku.voipio@linaro.org> wrote:
> A usual set of improvements and bugfixes. The binfmt flag addition is an
> ABI break so endusers need to update their binfmt registering scripts.
Ugh, really? I didn't realize that when I saw that patch
go past; I'd like to look at it in more detail before I
apply this, since "break everybody's working setup"
doesn't seem like a great idea...
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-15 17:49 ` [Qemu-devel] [PULL 00/24] Linux-user updates Peter Maydell
@ 2014-08-18 8:46 ` Riku Voipio
2014-08-18 10:49 ` Joakim Tjernlund
0 siblings, 1 reply; 37+ messages in thread
From: Riku Voipio @ 2014-08-18 8:46 UTC (permalink / raw)
To: Peter Maydell, joakim.tjernlund; +Cc: QEMU Developers
On 15 August 2014 20:49, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 15 August 2014 12:01, <riku.voipio@linaro.org> wrote:
>> A usual set of improvements and bugfixes. The binfmt flag addition is an
>> ABI break so endusers need to update their binfmt registering scripts.
> Ugh, really? I didn't realize that when I saw that patch
> go past; I'd like to look at it in more detail before I
> apply this, since "break everybody's working setup"
> doesn't seem like a great idea...
Ok, I think Joakim's patch can be adjusted so that it continues to
work as-is with
current binfmt registrations that don't have "P" set. Meanwhile, I'll
drop the patch from this round and re-submit the current linux-user
que without it.
Riku
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 8:46 ` Riku Voipio
@ 2014-08-18 10:49 ` Joakim Tjernlund
2014-08-18 10:58 ` Peter Maydell
0 siblings, 1 reply; 37+ messages in thread
From: Joakim Tjernlund @ 2014-08-18 10:49 UTC (permalink / raw)
To: Riku Voipio; +Cc: Peter Maydell, QEMU Developers
Riku Voipio <riku.voipio@linaro.org> wrote on 2014/08/18 10:46:36:
>
> On 15 August 2014 20:49, Peter Maydell <peter.maydell@linaro.org> wrote:
> > On 15 August 2014 12:01, <riku.voipio@linaro.org> wrote:
> >> A usual set of improvements and bugfixes. The binfmt flag addition is
an
> >> ABI break so endusers need to update their binfmt registering
scripts.
>
> > Ugh, really? I didn't realize that when I saw that patch
> > go past; I'd like to look at it in more detail before I
> > apply this, since "break everybody's working setup"
> > doesn't seem like a great idea...
>
> Ok, I think Joakim's patch can be adjusted so that it continues to
> work as-is with
> current binfmt registrations that don't have "P" set. Meanwhile, I'll
> drop the patch from this round and re-submit the current linux-user
> que without it.
>
ouch, this was a surprise this late in the game. I don't see how you are
going to modify my patch to not need P flag, can you elaborate?
The current binfmt is semibroken as is, for some it works when adding O
flag but
not all apps is happy with that. I think my patch is the best way solve
this problem,
all one have to do is to update the binfmt registering(mostly a dist.
problem) then it
will work for all uses.
Jocke
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 10:49 ` Joakim Tjernlund
@ 2014-08-18 10:58 ` Peter Maydell
2014-08-18 12:38 ` Joakim Tjernlund
0 siblings, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2014-08-18 10:58 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers
On 18 August 2014 11:49, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
> The current binfmt is semibroken as is, for some it works when adding O
> flag but not all apps is happy with that. I think my patch is the best
> way solve this problem, all one have to do is to update the binfmt
> registering(mostly a dist. problem) then it will work for all uses.
Well, binfmt-misc works fine for me as it is and presumably
for most people or we'd have had more complaints. So
breaking all those existing working setups is really something
we should avoid as much as possible.
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 10:58 ` Peter Maydell
@ 2014-08-18 12:38 ` Joakim Tjernlund
2014-08-18 12:45 ` Peter Maydell
0 siblings, 1 reply; 37+ messages in thread
From: Joakim Tjernlund @ 2014-08-18 12:38 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, QEMU Developers
Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 12:58:48:
>
> On 18 August 2014 11:49, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> > The current binfmt is semibroken as is, for some it works when adding
O
> > flag but not all apps is happy with that. I think my patch is the best
> > way solve this problem, all one have to do is to update the binfmt
> > registering(mostly a dist. problem) then it will work for all uses.
>
> Well, binfmt-misc works fine for me as it is and presumably
> for most people or we'd have had more complaints. So
> breaking all those existing working setups is really something
> we should avoid as much as possible.
How do you use it? With LXC booting a VM with traditional init?
There are complaints which dists had to solve because QEMU didn't. Usually
this is a separate static QEMU package/hack with a binfmt wrapper.
Gentoo used to have one but this got removed.
Jocke
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 12:38 ` Joakim Tjernlund
@ 2014-08-18 12:45 ` Peter Maydell
2014-08-18 12:59 ` Joakim Tjernlund
2014-08-18 13:02 ` Laurent Vivier
0 siblings, 2 replies; 37+ messages in thread
From: Peter Maydell @ 2014-08-18 12:45 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers
On 18 August 2014 13:38, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
> Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 12:58:48:
>> Well, binfmt-misc works fine for me as it is and presumably
>> for most people or we'd have had more complaints. So
>> breaking all those existing working setups is really something
>> we should avoid as much as possible.
>
> How do you use it? With LXC booting a VM with traditional init?
No. Just a straightforward chroot environment with a
statically linked qemu in it, and a binfmt_misc config like:
e104462:trusty:qemu$ cat /proc/sys/fs/binfmt_misc/qemu-arm
enabled
interpreter /usr/bin/qemu-arm-static
flags: OC
offset 0
magic 7f454c4601010100000000000000000002002800
mask ffffffffffffff00fffffffffffffffffeffffff
This works fine for the things I try to run in the chroot
(mostly test programs, also bash and basic command
line utilities).
> There are complaints which dists had to solve because QEMU didn't. Usually
> this is a separate static QEMU package/hack with a binfmt wrapper.
> Gentoo used to have one but this got removed.
I'm sure there are cases which don't work; but we should try
to find a way which allows us to make those work (with a
recommended change to binfmt misc registration) which
doesn't break the old configs in the process.
thanks
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 12:45 ` Peter Maydell
@ 2014-08-18 12:59 ` Joakim Tjernlund
2014-08-18 13:04 ` Peter Maydell
2014-08-18 13:17 ` Riku Voipio
2014-08-18 13:02 ` Laurent Vivier
1 sibling, 2 replies; 37+ messages in thread
From: Joakim Tjernlund @ 2014-08-18 12:59 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, QEMU Developers
Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 14:45:49:
>
> On 18 August 2014 13:38, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 12:58:48:
> >> Well, binfmt-misc works fine for me as it is and presumably
> >> for most people or we'd have had more complaints. So
> >> breaking all those existing working setups is really something
> >> we should avoid as much as possible.
> >
> > How do you use it? With LXC booting a VM with traditional init?
>
> No. Just a straightforward chroot environment with a
> statically linked qemu in it, and a binfmt_misc config like:
>
> e104462:trusty:qemu$ cat /proc/sys/fs/binfmt_misc/qemu-arm
> enabled
> interpreter /usr/bin/qemu-arm-static
Where does -static come from? Is that the standard name a static qemu-user
build gets?
> flags: OC
> offset 0
> magic 7f454c4601010100000000000000000002002800
> mask ffffffffffffff00fffffffffffffffffeffffff
>
> This works fine for the things I try to run in the chroot
> (mostly test programs, also bash and basic command
> line utilities).
Using bash as a login shell one need one of(from bash man page):
A login shell is one whose first character of argument zero is a -, or
one started with the --login option.
>
> > There are complaints which dists had to solve because QEMU didn't.
Usually
> > this is a separate static QEMU package/hack with a binfmt wrapper.
> > Gentoo used to have one but this got removed.
>
> I'm sure there are cases which don't work; but we should try
> to find a way which allows us to make those work (with a
> recommended change to binfmt misc registration) which
> doesn't break the old configs in the process.
This was considered/discussed to some point and no-one could come up
with a better approach.
Jocke
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 12:45 ` Peter Maydell
2014-08-18 12:59 ` Joakim Tjernlund
@ 2014-08-18 13:02 ` Laurent Vivier
1 sibling, 0 replies; 37+ messages in thread
From: Laurent Vivier @ 2014-08-18 13:02 UTC (permalink / raw)
To: Peter Maydell, Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers
[-- Attachment #1: Type: text/plain, Size: 2042 bytes --]
> Le 18 août 2014 à 14:45, Peter Maydell <peter.maydell@linaro.org> a écrit :
>
>
> On 18 August 2014 13:38, Joakim Tjernlund <joakim.tjernlund@transmode.se>
> wrote:
> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 12:58:48:
> >> Well, binfmt-misc works fine for me as it is and presumably
> >> for most people or we'd have had more complaints. So
> >> breaking all those existing working setups is really something
> >> we should avoid as much as possible.
> >
> > How do you use it? With LXC booting a VM with traditional init?
>
> No. Just a straightforward chroot environment with a
> statically linked qemu in it, and a binfmt_misc config like:
>
> e104462:trusty:qemu$ cat /proc/sys/fs/binfmt_misc/qemu-arm
> enabled
> interpreter /usr/bin/qemu-arm-static
> flags: OC
> offset 0
> magic 7f454c4601010100000000000000000002002800
> mask ffffffffffffff00fffffffffffffffffeffffff
>
> This works fine for the things I try to run in the chroot
> (mostly test programs, also bash and basic command
> line utilities).
>
> > There are complaints which dists had to solve because QEMU didn't. Usually
> > this is a separate static QEMU package/hack with a binfmt wrapper.
> > Gentoo used to have one but this got removed.
>
> I'm sure there are cases which don't work; but we should try
> to find a way which allows us to make those work (with a
> recommended change to binfmt misc registration) which
> doesn't break the old configs in the process.
If it can help:
I'm using qemu-linux-user in LXC containers for more than a year now without any
problem and with nor wrapper neither modifications in the distro I install (to
be honest, only debian etch-m68k and previous).
I like this approach because it avoids to have to maintain gcc cross-compiler
(and tools). It's 10 times slower than the cross compiler but works fine.
I've a script in my qemu-m68k repo that can create containers for several archs
(search in QEMU mailing list archives... or ask)
Regards,
Laurent
[-- Attachment #2: Type: text/html, Size: 3466 bytes --]
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 12:59 ` Joakim Tjernlund
@ 2014-08-18 13:04 ` Peter Maydell
2014-08-18 15:15 ` Joakim Tjernlund
2014-08-18 13:17 ` Riku Voipio
1 sibling, 1 reply; 37+ messages in thread
From: Peter Maydell @ 2014-08-18 13:04 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: Riku Voipio, QEMU Developers
On 18 August 2014 13:59, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
> Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 14:45:49:
>>
>> On 18 August 2014 13:38, Joakim Tjernlund
> <joakim.tjernlund@transmode.se> wrote:
>> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 12:58:48:
>> >> Well, binfmt-misc works fine for me as it is and presumably
>> >> for most people or we'd have had more complaints. So
>> >> breaking all those existing working setups is really something
>> >> we should avoid as much as possible.
>> >
>> > How do you use it? With LXC booting a VM with traditional init?
>>
>> No. Just a straightforward chroot environment with a
>> statically linked qemu in it, and a binfmt_misc config like:
>>
>> e104462:trusty:qemu$ cat /proc/sys/fs/binfmt_misc/qemu-arm
>> enabled
>> interpreter /usr/bin/qemu-arm-static
>
> Where does -static come from? Is that the standard name a static qemu-user
> build gets?
No. It's just what Debian and Ubuntu call their statically
linked binaries.
>> flags: OC
>> offset 0
>> magic 7f454c4601010100000000000000000002002800
>> mask ffffffffffffff00fffffffffffffffffeffffff
>>
>> This works fine for the things I try to run in the chroot
>> (mostly test programs, also bash and basic command
>> line utilities).
>
> Using bash as a login shell one need one of(from bash man page):
> A login shell is one whose first character of argument zero is a -, or
> one started with the --login option.
Who said anything about login shells? I just chroot into the
thing and run a shell.
-- PMM
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 12:59 ` Joakim Tjernlund
2014-08-18 13:04 ` Peter Maydell
@ 2014-08-18 13:17 ` Riku Voipio
2014-08-18 15:35 ` Joakim Tjernlund
1 sibling, 1 reply; 37+ messages in thread
From: Riku Voipio @ 2014-08-18 13:17 UTC (permalink / raw)
To: Joakim Tjernlund; +Cc: Peter Maydell, QEMU Developers
On 18 August 2014 15:59, Joakim Tjernlund <joakim.tjernlund@transmode.se> wrote:
> Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 14:45:49:
>> I'm sure there are cases which don't work; but we should try
>> to find a way which allows us to make those work (with a
>> recommended change to binfmt misc registration) which
>> doesn't break the old configs in the process.
> This was considered/discussed to some point and no-one could come up
> with a better approach.
A lot of people are OK with the current approach. Really few
applications become unhappy if say,called "/bin/ls" instead of "ls".
So saying things are "broken" without switching to P flag is a bit
myopic view. In my experience, only some testsuites suffer failures.
The problem with updating the binfmt registration is that people may
have a mix of old and new qemu binaries. When we change the
registration, it means no old qemu anymore works. The "argc > 3" is
also a bit weak - it means that calling "ls -la ." would pass the test
even if "P" flag is not set, but qemu would pass wrong parameters to
the binary being run.
No doubt starting to use the P flag would be a improvement. But it
would be good to find a less breaky way manage the transition.
Riku
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 13:04 ` Peter Maydell
@ 2014-08-18 15:15 ` Joakim Tjernlund
0 siblings, 0 replies; 37+ messages in thread
From: Joakim Tjernlund @ 2014-08-18 15:15 UTC (permalink / raw)
To: Peter Maydell; +Cc: Riku Voipio, QEMU Developers
Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 15:04:50:
>
> On 18 August 2014 13:59, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 14:45:49:
> >>
> >> On 18 August 2014 13:38, Joakim Tjernlund
> > <joakim.tjernlund@transmode.se> wrote:
> >> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18
12:58:48:
> >> >> Well, binfmt-misc works fine for me as it is and presumably
> >> >> for most people or we'd have had more complaints. So
> >> >> breaking all those existing working setups is really something
> >> >> we should avoid as much as possible.
> >> >
> >> > How do you use it? With LXC booting a VM with traditional init?
> >>
> >> No. Just a straightforward chroot environment with a
> >> statically linked qemu in it, and a binfmt_misc config like:
> >>
> >> e104462:trusty:qemu$ cat /proc/sys/fs/binfmt_misc/qemu-arm
> >> enabled
> >> interpreter /usr/bin/qemu-arm-static
> >
> > Where does -static come from? Is that the standard name a static
qemu-user
> > build gets?
>
> No. It's just what Debian and Ubuntu call their statically
> linked binaries.
>
> >> flags: OC
> >> offset 0
> >> magic 7f454c4601010100000000000000000002002800
> >> mask ffffffffffffff00fffffffffffffffffeffffff
> >>
> >> This works fine for the things I try to run in the chroot
> >> (mostly test programs, also bash and basic command
> >> line utilities).
> >
> > Using bash as a login shell one need one of(from bash man page):
> > A login shell is one whose first character of argument zero is a -,
or
> > one started with the --login option.
>
> Who said anything about login shells? I just chroot into the
> thing and run a shell.
Yes, that was a bit short. It was only meant as an example of what could
break not using
P flag as bash behaves differently if invoked as login shell which could
lead to breakage
further down the line.
Jocke
^ permalink raw reply [flat|nested] 37+ messages in thread
* Re: [Qemu-devel] [PULL 00/24] Linux-user updates
2014-08-18 13:17 ` Riku Voipio
@ 2014-08-18 15:35 ` Joakim Tjernlund
0 siblings, 0 replies; 37+ messages in thread
From: Joakim Tjernlund @ 2014-08-18 15:35 UTC (permalink / raw)
To: Riku Voipio; +Cc: Peter Maydell, QEMU Developers
Riku Voipio <riku.voipio@linaro.org> wrote on 2014/08/18 15:17:06:
>
> On 18 August 2014 15:59, Joakim Tjernlund
<joakim.tjernlund@transmode.se> wrote:
> > Peter Maydell <peter.maydell@linaro.org> wrote on 2014/08/18 14:45:49:
> >> I'm sure there are cases which don't work; but we should try
> >> to find a way which allows us to make those work (with a
> >> recommended change to binfmt misc registration) which
> >> doesn't break the old configs in the process.
>
> > This was considered/discussed to some point and no-one could come up
> > with a better approach.
>
> A lot of people are OK with the current approach. Really few
> applications become unhappy if say,called "/bin/ls" instead of "ls".
> So saying things are "broken" without switching to P flag is a bit
> myopic view. In my experience, only some testsuites suffer failures.
semibroken but OK, that was a bit much too.
>
> The problem with updating the binfmt registration is that people may
> have a mix of old and new qemu binaries. When we change the
> registration, it means no old qemu anymore works. The "argc > 3" is
> also a bit weak - it means that calling "ls -la ." would pass the test
> even if "P" flag is not set, but qemu would pass wrong parameters to
> the binary being run.
Yes, it does not catch all error cases but I figured it was better than no
error check at all.
>
> No doubt starting to use the P flag would be a improvement. But it
> would be good to find a less breaky way manage the transition.
Yes it would but none of us came up with a better way at the time and you
were OK
with my patch in the end. Now I don't have time to dwell on this, sorry.
Jocke
PS.
Crazy idea, you could read /proc/sys/fs/binfmt_misc/$ARCH and parse the
flags
field if you can live with the performance hit.
^ permalink raw reply [flat|nested] 37+ messages in thread
end of thread, other threads:[~2014-08-18 15:35 UTC | newest]
Thread overview: 37+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-08-15 11:01 [Qemu-devel] [PULL 00/24] Linux-user updates riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 01/24] linux-user: /proc/self/maps content riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 02/24] linux-user: redirect openat calls riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 03/24] linux-user: make binfmt flag O require P riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 04/24] linux-user: Fix syscall instruction usermode emulation on X86_64 riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 05/24] linux-user: Fix conversion of sigevent argument to timer_create riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 06/24] linux-user: fix readlink handling with magic exe symlink riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 07/24] linux-user: support timerfd_{create, gettime, settime} syscalls riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 08/24] linux-user: support ioprio_{get, set} syscalls riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 09/24] linux-user: support {name_to, open_by}_handle_at syscalls riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 10/24] linux-user: add setns and unshare riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 11/24] linux-user: PPC64 semid_ds Doesnt Include _unused1 and _unused2 riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 12/24] linux-user: Dereference Pointer Argument to ipc/semctl Sys Call riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 13/24] linux-user: Properly Handle semun Structure In Cross-Endian Situations riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 14/24] linux-user: Make ipc syscall's third argument an abi_long riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 15/24] linux-user: Conditionally Pass Attribute Pointer to mq_open() riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 16/24] linux-user: Detect Negative Message Sizes in msgsnd System Call riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 17/24] linux-user: Handle NULL sched_param argument to sched_* riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 18/24] linux-user: Detect fault in sched_rr_get_interval riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 19/24] linux-user: Move get_ppc64_abi riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 20/24] linux-user: Minimum Sig Handler Stack Size for PPC64 ELF V2 riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 21/24] linux-user: clock_nanosleep errno Handling on PPC riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 22/24] linux-user: Support target-to-host translation of mlockall argument riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 23/24] linux-user: writev Partial Writes riku.voipio
2014-08-15 11:01 ` [Qemu-devel] [PULL 24/24] linux-user: check return value of malloc() riku.voipio
2014-08-15 17:49 ` [Qemu-devel] [PULL 00/24] Linux-user updates Peter Maydell
2014-08-18 8:46 ` Riku Voipio
2014-08-18 10:49 ` Joakim Tjernlund
2014-08-18 10:58 ` Peter Maydell
2014-08-18 12:38 ` Joakim Tjernlund
2014-08-18 12:45 ` Peter Maydell
2014-08-18 12:59 ` Joakim Tjernlund
2014-08-18 13:04 ` Peter Maydell
2014-08-18 15:15 ` Joakim Tjernlund
2014-08-18 13:17 ` Riku Voipio
2014-08-18 15:35 ` Joakim Tjernlund
2014-08-18 13:02 ` Laurent Vivier
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).