History | View | Annotate | Download (259.3 kB)
linux-user: fail execve() if env/args too big
If the host's page size is equal to or smaller than the target's, nativeexecve() will fail appropriately with E2BIG if called with too big anenvironment for the target to handle. It may falsely succeed, however, if...
linux-user: fake /proc/self/maps
glibc's pthread_attr_getstack tries to find the stack range from/proc/self/maps. Unfortunately, /proc is usually the host's /procwhich means linux-user guests see qemu's stack there.
Fake the file with a constructed maps entry that exposes the guest's...
linux-user: fake /proc/self/stat
The boehm gc finds the program's stack starting pointer bychecking /proc/self/stat. Unfortunately, so far it readsqemu's stack pointer which clearly is wrong.
So let's instead fake the file so the guest program sees the...
linux-user: fake /proc/self/auxv
Gtk tries to read /proc/self/auxv to find its auxv table instead oftaking it from its own program memory space.
However, when running with linux-user, we see the host's auxv whichclearly exposes wrong information. so let's instead expose the guest...
linux-user: add SO_PEERCRED support for getsockopt
Signed-off-by: Akos PASZTORY <akos.pasztory@gmail.com>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: fix QEMU_STRACE=1 segfault
While debugging some issues with QEMU_STRACE I stumbled over segmentationfaults that were pretty reproducible. Turns out we tried to treat anormal return value as errno, resulting in an access over array boundaries...
linux-user: fix wait* syscall status returns
When calling wait4 or waitpid with a status pointer and WNOHANG, thesyscall can potentially not modify the status pointer input. Now if wehave guest code like:
int status = 0; waitpid(pid, &status, WNOHANG);...
linux-user: Allow NULL value pointer in setxattr and getxattr
It's valid to pass a NULL value pointer to setxattr, so don'tfail this case EFAULT.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c: Implement f and l versions of set/get/removexattr
Implement the f and l versions (operate on fd, don't follow links)of the setxattr, getxattr and removexattr syscalls.
linux-user: Implement *listxattr syscalls
Implement listxattr, flistxattr and llistxattr syscalls.
linux-user: add open() hijack infrastructure
There are a number of files in /proc that expose host informationto the guest program. This patch adds infrastructure to overridethe open() syscall for guest programs to enable us to on the flygenerate guest sensible files....
linux-user/syscall.c: Don't skip stracing for fcntl64 failure case
In an fcntl64 failure path, we were returning directly rather thansimply breaking out of the switch statement. This skips the stracecode for printing the syscall return value, so don't do that....
fix typo: delete redundant semicolon
Double semicolons should be single.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
configure: fix detection for xattr.h on modern distributions
Modern distributions place xattr.h in /usr/include/sys, and foldlibattr.so into libc. They also don't have an ENOATTR.
Make configure detect this, and add a qemu-xattr.h file thatdirects the #include to the right place....
linux-user: implement reboot syscall
For OBS, we're running a full cross-guest inside of a VM. When a buildis done there, we reboot the guest as shutdown mechanism.
Unfortunately, reboot is not implemented in linux-user. So this mechanismfails, spilling unpretty warnings. This patch implements sys_reboot()...
linux-user: fix abi_(u)long, target_ulong mismatch
abi_(u)long might be different from target_ulong, so don't use tswaplbut introduce a new tswapal
Signed-off-by: Matthias Braun <matze@braunis.de>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: fix openat
When running openat using qemu-arm, we stumbled over invalid permissionson the created files. The reason for this is that the mode parameter getstreates as an O_... flag, which it isn't - it's a permission bitmask.
This patch removes the needless translation of the mode parameter,...
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
Fix include statements for qemu-common.h
linux-user: Implement setxattr/getxattr/removexattr syscalls
This patch implements the setxattr, getxattr, and removexattr syscallsif CONFIG_ATTR is enabled.
Note that since libattr uses indirect syscalls for these, this changedepends on the fix for indirect syscall handling on MIPS....
linux-user: Fix initialization of the heap contents when allocating new pages
Technically the new mmapped pages are already initialized to zerosince they are anonymous, however we have to take care with thecontents that come from the remaining part of the previous page: it...
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Wrap recv to avoid warnings
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]...
linux-user: make MIPS and ARM eabi use same argument reordering
MIPS uses similar calling convention than ARM eabi, where when using64-bit values some registers are skipped. This patch makes MIPS and ARMeabi share the argument reordering code.
This affects ftruncate64, creating insane sized fails (or just failing)....
mips: rlimit codes are not the same
The codes for get/setrlimit differ between linux target platforms.This patch adds conversion.This is important else programs (rsyslog, python, ...) can go into anear infinite loop trying to close all the file descriptors from 0 to...
mips: rlimit incorrectly converts values
Byte swap was applied in the wrong order with testing forRLIM_INFINITY. On mips bigendian from an amd64 system this results ininfinity being misinterpretted as 2^31-1.
This is a serious bug because it causes setrlimit stack size to kill...
linux-user/syscall.c: Enforce pselect6 sigset size restrictions
Enforce the same restriction on the size of the sigset passed topselect6 as the Linux kernel does. This is both correct and silencesa gcc 4.6 warning about a write-only variable.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Implement prlimit64 syscall
Implement the prlimit64 syscall.
Slightly modified to apply upstream -Riku
linux-user: syscall should use sanitized arg1
Looking at the other architectures, we should be using "how" not "arg1".
Signed-off-by: Juan Quintela <quintela@redhat.com>[peter.maydell@linaro.org: remove unnecessary initialisation of how]Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Bump do_syscall() up to 8 syscall arguments
On 32 bit MIPS a few syscalls have 7 arguments, and so to callthem via NR_syscall the guest needs to be able to pass 8 argumentsto do_syscall(). Raise the number of arguments do_syscall() takesaccordingly....
linux-user: Fix sync_file_range on 32bit mips
As noticed while looking at "Bump do_syscall() up to 8 syscall arguments" patch, sync_file_range uses a pad argument on 32bit mips. Deal with itby reading the correct arguments when on mips.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Fix the computation of the requested heap size
There were several remaining bugs in the previous implementation ofdo_brk():
1. the value of "new_alloc_size" was one page too large when the requested brk was aligned on a host page boundary....
linux-user: add pselect6 syscall support
Some architectures (like Blackfin) only implement pselect6 (and skipselect/newselect). So add support for it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
syscall: really return ret code
We assign ret with the error code, but then return 0 unconditionally.
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Don't use MAP_FIXED in do_brk()
Since mmap() with MAP_FIXED will map over the top of existing mappings,it's a bad idea to use it to implement brk(), because brk() with alarge size is likely to overwrite important things like qemu itselfor the host libc. So we drop MAP_FIXED and handle "mapped but at...
s390x: s390x-linux-user support
This patch adds support for running s390x binaries in the linux-user emulationcode.
Signed-off-by: Ulrich Hecht <uli@suse.de>Signed-off-by: Alexander Graf <agraf@suse.de>
linux-user: Replace deprecated function
Function bzero is deprecated, so replace it by function memset.
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fix buffer overrun in sched_getaffinity
Zeroing of the cpu array should start from &cpus[kernel_ret]not &cpus[num_zeros_to_fill].
This fixes a crash in EFL's edje_cc running under qemu-arm.
Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
Don't zero out buffer in sched_getaffinity
The kernel doesn't fill the buffer provided to sched_getaffinitywith zero bytes, so neither should QEMU.
linux-user: add ioctl(SIOCGIWNAME, ...) support.
Allow to run properly following program from linux-user:
/* cc -o wifi wifi.c */
#include <stdio.h> #include <sys/ioctl.h> #include <sys/types.h> #include <sys/socket.h> #include <linux/wireless.h> #include <netinet/in.h>...
linux-user: add s390x to llseek list
We keep a list of host architectures that do llseek with the samesyscall as lseek. S390x is one of them, so let's add it to the list.
Original-patch-by: Ulrich Hecht <uli@suse.de>Signed-off-by: Alexander Graf <agraf@suse.de>...
linux-user: untie syscalls from UID16
Quite a number of uid/gid related syscalls are only defined on systemswith USE_UID16 defined. This is apperently based on the idea that thesesystem calls would never be called on non-UID16 systems. Make thesesyscalls available for all architectures that define them....
[v2] linux-user: bigger default stack
PTHREAD_STACK_MIN (16KB) is somewhat inadequate for a new stack for newQEMU threads. Set new limit to 256K which should be enough, yet doesn'tincrease memory pressure significantly.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>...
linux-user: convert ioctl(SIOCGIFCONF, ...) result.
The result needs to be converted as it is stored in an array of structifreq and sizeof(struct ifreq) differs according to target and hostalignment rules.
This patch allows to execute correctly the following program on arm...
linux-user: Fix unlock_user() call in return from poll()
Correct the broken attempt to calculate the third argumentto unlock_user() in the code path which unlocked the pollfdarray on return from poll() and ppoll() emulation. (Thisonly caused a problem if unlock_user() wasn't a no-op, eg...
linux-user: Fix large seeks by 32 bit guest on 64 bit host
When emulating a 32 bit Linux user-mode program on a 64 bit targetwe implement the llseek syscall in terms of lseek. Correct a bugwhich meant we were silently casting the result of host lseek()...
linux-user: Support the epoll syscalls
Support the epoll family of syscalls: epoll_create(), epoll_create1(),epoll_ctl(), epoll_wait() and epoll_pwait(). Note that epoll_create1()and epoll_pwait() are later additions, so we have to test separatelyin configure for their presence....
linux-user: add ppoll syscall support
Some architectures (like Blackfin) only implement ppoll (and skip poll).So add support for it using existing poll code.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Mike Frysinger <vapier@gentoo.org>...
linux-user: implement sched_{g,s}etaffinity
Signed-off-by: Mike Frysinger <vapier@gentoo.org>Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
linux-user: fix sizeof handling for getsockopt
linux-user: Add configure check for linux/fiemap.h and IOC_FS_FIEMAP
Add a configure check for the existence of linux/fiemap.h and theIOC_FS_FIEMAP ioctl. This fixes a compilation failure on Linuxsystems which don't have that header file.
linux-user: Implement FS_IOC_FIEMAP ioctl
Implement the FS_IOC_FIEMAP ioctl using the new support forcustom handling of ioctls; this is needed because the structthat is passed includes a variable-length array.
linux-user: Support ioctls whose parameter size is not constant
Some ioctls (for example FS_IOC_FIEMAP) use structures whose size isnot constant. The generic argument conversion code in do_ioctl()cannot handle this, so add support for implementing a special-case...
linux-user: Implement sync_file_range{,2} syscalls
Implement the missing syscalls sync_file_range and sync_file_range2.The latter in particular is used by newer versions of apt on Ubuntufor ARM.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Translate getsockopt level option
n setsockopt, the socket level options are translated to the hosts'architecture before the real syscall is called, e.g.TARGET_SO_TYPE -> SO_TYPE. This patch does the same with getsockopt.
Tested on a x86 host emulating MIPS. Without it:-...
linux-user: fix compiler error on nptl
Some compilers detect that new_stack isnt used after dd75d784
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>
linux-user: fix memory leaks with NPTL emulation
Running programs that create large numbers of threads, such as thissnippet from libstdc++'s pthread7-rope.cc:
const int max_thread_count = 4; const int max_loop_count = 10000; ... for (int j = 0; j < max_loop_count; j++)...
linux-user: fix socklen_t comparisons
On many systems, socklen_t is defined as unsigned. This means thatchecks for negative values are not meaningful.
Fix by explicitly casting to a signed integer.
This also avoids some warnings with GCC flag -Wtype-limits....
Usermode exec-stack fix
When loading a shared library that requires an executable stack,glibc uses the mprotext PROT_GROWSDOWN flag to achieve this.We don't support PROT_GROWSDOWN.Add a special case to handle changing the stack permissions in this way....
s390x: Avoid _llseek.
There's no _llseek on s390x either. Replace the existingtest for x86_64 with a functional test for __NR_llseek.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: do not warn for missing pselect6
Libc will fallback gracefully if pselect6 is not available. Thus putpselect6 to nowarn until the atomicity issues of the original pselect6patch are dealt with.
alpha-linux-user: Fix getxpid.
Put ppid in the second return register.
alpha-linux-user: Fix sigsuspend parameters.
Alpha passes the signal set in a register, not by reference.
alpha-linux-user: Fix sigprocmask.
Alpha passes oldset by value in a register, and returns the newsetas the return value; as compared to the standard implementation inwhich both are passed by reference. This requires being able todistinguish negative return values that are not errors. Do this in...
alpha-linux-user: Fix brk error return.
alpha-linux-user: Fix pipe return mechanism.
At the same time, tidy the code wrt MIPS and SH4 which have thesame two register return mechanism. Fix confusion between pipeand pipe2 with an explicit flags=0, when the guest will not beusing the two register return mechanism....
linux-user: rlimit conversion between host and target.
rlim_t conversion between host and target added.Otherwise there are some incorrect case like- RLIM_INFINITY on 32bit target > 64bit host. RLIM_INFINITY on 64bit host > mips and sparc target ? Big value(for 32bit target) on 64bit host -> 32bit target....
target-alpha: Enable NPTL.
linux-user: Fix sparc32plus stat64 syscalls.
Check TARGET_ABI_BITS, not TARGET_LONG_BITS, when decidingwhether or not the guest needs special 64-bit stat translation.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user: do_shmdt(): Fix page_set_flags's 2nd arg.
2nd arg of page_set_flags() should be start+size, but size.
Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>Acked-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Fix compilation with missing inotify_init1
Commit c05c7a7306a23a4b01d1606172b142c45caffc92breaks cross compilation for mips (and othercompilations without CONFIG_INOTIFY1):
make1: Entering directory `/qemu/bin/mips' CC i386-linux-user/syscall.o...
linux-user/ia64: workaround ia64 strangenesses
ia64 has some strangenesses that need to be workaround:- it has a __clone2() syscall instead of the using clone() one, with different arguments, and which is not declared in the usual headers.- ucontext.uc_sigmask is declared with type long int, while it is...
linux-user: add inotify_init1 syscall support
New syscall which gets actively used when you have afresh kernel.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: Fix syscall pipe2() retval on sh4
On linux/sh4 pipe() return values by r0:r1 as SH C calling convention. pipe2() return values on memory as traditional unix way.
Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
alpha-linux-user: Implement signals.
Move userland PALcode handling into linux-user main loop so thatwe can send signals from there. This also makes alpha_palcode.csystem-level only, so don't build it for userland. Add definesfor GENTRAP PALcall mapping to signals....
linux-user: adapt uname machine to emulated CPU
This patch for linux-user adapts the output of the emulated uname()syscall to match the configured CPU. Tested with x86, x86-64 and armemulation.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>Signed-off-by: Loïc Minier <lool@dooz.org>
alpha: fix stat64 issue
The stat64/fstat64 syscalls are broken for alpha linux-user.
This is because Alpha, even though it is native 64-bits, has a stat64syscall that is different than regular stat. This means that the"TARGET_LONG_BITS==64" check in syscall.c isn't enough. Below is...
target-alpha: Fixes for alpha-linux syscalls.
1. Add correct definitions of error numbers.2. Implement SYS_osf_sigprocmask3. Implement SYS_osf_get/setsysinfo for IEEE_FP_CONTROL.
This last requires exposing the FPCR value to do_syscall.Since this value is actually split up into the float_status,...
(x86/Sparc/PPC)-user: fix cpu_copy
b55a37c981914aa8ecd21b9a2a2fb37f39b917c5 moved the call to cpu_resetto user emulators. But cpu_copy also initializes a CPU structure, so add thecall also there.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Re: linux-user/syscall.c - don't add GUEST_BASE to NULL pointer
This patch fixes the mount call. GUEST_BASE shouldn't be added to a NULL pointer on arg5 . failing call:mount("rootfs", "/", 0x47a78, MS_MGC_VAL|MS_REMOUNT, 0x10000) = -1 EFAULT (Bad address)...
linux-user: KD/VT/FB ioctls
everything needed to run SDL on a framebuffer device in the userspace emulator
Signed-off-by: Ulrich Hecht <uli@suse.de>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
implementations of dup3 and fallocate that are good enough to fool LTP
updated fallocate check to new configure, added dup3 check as suggestedby Jan-Simon Möller.
Riku: updated to apply to current git.
linux-user: getpriority errno fix
getpriority returned wrong errno; fixes LTP test getpriority02.
Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.
The naming convention is goofy and it causes a massive merge problem. Somethinglike this must be presented on the list first so people can provide input...
Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the timebeing.
Signed-off-by: malc <av1474@comtv.ru>
linux-user: fix coding style nit
Put space between = and & when taking a pointer,to avoid confusion with old-style "&=".
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
F_DUPFD_CLOEXEC is not universally available
The same issue (and the same patch to the byte) was experienced/proposedby Vince Weaver.
linux-user: fadvise64 implementation
good enough to pass all LTP fadvise64 tests
linux-user: zero fstat buffer to initialize nsec fields
The fstat implementation does not initialize the nanosecond fields in thestat buffer; this caused funny values to turn up there, preventing, forinstance, cp -p from preserving timestamps because utimensat rejected...
m68k, linux-user: enable sigaltstack()
As setup_frame() and setup_rt_frame() are now implemented we can nowenable sigaltstack().
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: fix mq_* compilation problems
mqueue.h is only available if _NR_mq_open is defined. So don't includeit unconditionally. Similarly, the mq* family of syscalls depend on_NR_mq_open. Finally, the copy{from,to}_user_mq_attr functions should...
linux-user: fcntl fixes for LTP
Fixes swaps on l_pid which were pretty much of random size. ImplementsF_SETLEASE, F_GETLEASE. Now passes all LTP fcntl tests.
linux-user: enable getdents for > 32-bit systems
works perfectly fine with the example from getdents(2) and passes the LTPtests (tested with s390x on x86_64 emulation)
linux-user: add eventfd support
Straightforward implementation. This syscall is rare enough that wedon't need to support the odder cases, just disable it if host glibcis too old.
linux-user: make FUTEX_* calls honor timeout parameter
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>Signed-off-by: malc <av1474@comtv.ru>
rename USE_NPTL to CONFIG_USE_NPTL
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
rename HAVE_GPROF to TARGET_GPROF
Use was not consistent, in Makefile was TARGET_GPROF and in *h HAVE_GPROF
Fix most warnings (errors with -Werror) when debugging is enabled
I used the following command to enable debugging:perl -p -i -e 's/^\/\/#define DEBUG/#define DEBUG/g' * /* *//*
Update to a hopefully more future proof FSF address