summaryrefslogtreecommitdiff
path: root/linux-user/syscall.c
AgeCommit message (Collapse)AuthorFilesLines
2013-04-12linux-user: pass correct host flags to eventfd2 callPetar Jovanovic1-1/+10
This change makes conversion of TARGET_O_NONBLOCK and TARGET_O_CLOEXEC flags to host flags before calling eventfd for TARGET_NR_eventfd2. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-03-11linux-user/syscall.c: Don't warn about unimplemented get_robust_listPeter Maydell1-1/+14
The nature of the kernel ABI for the get_robust_list and set_robust_list syscalls means we cannot implement them in QEMU. Make get_robust_list silently return ENOSYS rather than using the default "print message and then fail ENOSYS" code path, in the same way we already do for set_robust_list, and add a comment documenting why we do this. This silences warnings which were being produced for emulating even trivial programs like 'ls' in x86-64-on-x86-64. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-03-11linux-user: Implement accept4Peter Maydell1-8/+31
Implement the accept4 syscall (which is identical to accept but has an additional flags argument). Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-03-11linux-user: Implement sendfile and sendfile64Peter Maydell1-0/+53
Implement the sendfile and sendfile64 syscalls. This implementation passes all the LTP test cases for these syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-03-11linux-user: make bogus negative iovec lengths fail EINVALPeter Maydell1-1/+1
If the guest passes us a bogus negative length for an iovec, fail EINVAL rather than proceeding blindly forward. This fixes some of the error cases tests for readv and writev in the LTP. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-03-11linux-user: Support setgroups syscall with no groupsDillon Amburgey1-10/+12
Signed-off-by: Dillon Amburgey <dillona@dillona.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-03-11linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futexJohn Rigby1-1/+2
Upstream libc has recently changed to start using FUTEX_WAIT_BITSET instead of FUTEX_WAIT and this is causing do_futex to return -TARGET_ENOSYS. Pass bitset in val3 to sys_futex which will be ignored by kernel for the FUTEX_WAIT case. Signed-off-by: John Rigby <john.rigby@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2013-02-16cpu: Move host_tid field to CPUStateAndreas Färber1-1/+3
Change gdbstub's cpu_index() argument to CPUState now that CPUArchState is no longer used. Signed-off-by: Andreas Färber <afaerber@suse.de>
2013-02-06Merge branch 'for-linux-user' of ↵Anthony Liguori1-12/+36
https://git.gitorious.org/qemu-m68k/qemu-m68k into staging * 'for-linux-user' of https://git.gitorious.org/qemu-m68k/qemu-m68k: linux-user: correct reboot() linux-user: correct setsockopt() linux-user: correct print_timeval() swap tv_sec and tv_usec linux-user: correct msgrcv() Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-02-01cpu: do not use object_deletePaolo Bonzini1-1/+1
CPUs are never added to the composition tree, so delete is achieved simply by removing the last references to them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2013-01-30linux-user: correct reboot()Laurent Vivier1-4/+12
According to man reboot(2), the 4th argument is only used with LINUX_REBOOT_CMD_RESTART2. In other cases, trying to convert the value can generate EFAULT. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2013-01-30linux-user: correct setsockopt()Laurent Vivier1-6/+22
SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int To test this, you can use : QEMU_STRACE= ping localhost 2>&1 |grep TIMEO 568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) = 0 568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) = 0 Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2013-01-30linux-user: correct msgrcv()Laurent Vivier1-2/+2
All parameters must be swapped before the call of do_msgrcv(). Allow faked (debian fakeroot daemon) to work properly. WITHOUT this patch: $ faked-sysv --foreground --debug using 1723744788 as msg key msg_key=1723744788 1723744788:431 FAKEROOT: msg=131072, key=1723744788 FAKEROOT: r=-1, received message type=-150996052, message=-160219330 FAKEROOT, get_msg: Bad address r=14, EINTR=4 fakeroot: clearing up message queues and semaphores, signal=-1 fakeroot: database save FAILED WITH this patch: $ faked-sysv --foreground --debug using 1569385744 as msg key msg_key=1569385744 1569385744:424 FAKEROOT: msg=0, key=1569385744 ^C fakeroot: clearing up message queues and semaphores, signal=2 fakeroot: database save FAILED Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
2013-01-16alpha-linux-user: Correct selectLaurent Vivier1-6/+6
Alpha, like s390x, passes all select arguments in registers. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
2013-01-16alpha-linux-user: Translate fcntl l_typeLaurent Vivier1-6/+22
The values of F_RDLCK, F_WRLCK, F_UNLCK, F_EXLCK, F_SHLCK differ between alpha and other linux architectures. This patch allows to run "dpkg" (database lock). Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Richard Henderson <rth@twiddle.net>
2013-01-04linux-user/syscall.c: remove forward declarationsJohn Spencer1-5/+3
instead use the correct headers that define these functions. Requested-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: John Spencer <maillist-qemu@barfooze.de> Reviewed-by: Amos Kong <kongjianjun@gmail.com> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-19Merge remote-tracking branch 'bonzini/header-dirs' into stagingAnthony Liguori1-1/+1
* bonzini/header-dirs: (45 commits) janitor: move remaining public headers to include/ hw: move executable format header files to hw/ fpu: move public header file to include/fpu softmmu: move remaining include files to include/ subdirectories softmmu: move include files to include/sysemu/ misc: move include files to include/qemu/ qom: move include files to include/qom/ migration: move include files to include/migration/ monitor: move include files to include/monitor/ exec: move include files to include/exec/ block: move include files to include/block/ qapi: move include files to include/qobject/ janitor: add guards to headers qapi: make struct Visitor opaque qapi: remove qapi/qapi-types-core.h qapi: move inclusions of qemu-common.h from headers to .c files ui: move files to ui/ and include/ui/ qemu-ga: move qemu-ga files to qga/ net: reorganize headers net: move net.c to net/ ... Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-18linux-user/syscall.c: remove wrong forward decl of setgroups()John Spencer1-1/+1
this declaration is wrong: the correct prototype on linux is: int setgroups(size_t size, const gid_t *list); since by default musl libc exposes this symbol in unistd.h additionally to grp.h, the wrong declaration causes a build error. the proper fix is to simply include the correct header. Signed-off-by: John Spencer <maillist-qemu@barfooze.de> Reviewed-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-08linux-user: Merge pread/pwrite into pread64/pwrite64Peter Maydell1-18/+0
The Linux syscalls underlying pread() and pwrite() take a 64 bit offset on all architectures, even if some of them name the syscall "pread/pwrite" rather than "pread64/pwrite64" for historical reasons. So move the four QEMU target architectures (arm, i386, sparc, unicore32) which were defining TARGET_NR_pread/pwrite to define TARGET_NR_pread64/pwrite64 instead, and drop the TARGET_NR_pread/pwrite implementation code completely. (Based on examination of the kernel sources for the four architectures this patch affects.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-10-19Merge branch 'linux-user-for-upstream' of ↵Aurelien Jarno1-64/+136
git://git.linaro.org/people/rikuvoipio/qemu * 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio/qemu: linux-user: register align p{read, write}64 linux-user: ppc: mark as long long aligned tcg: Remove TCG_TARGET_HAS_GUEST_BASE define configure: Remove unnecessary host_guest_base code linux-user: If loading fails, print error as string, not number linux-user: Fix siginfo handling alpha-linux-user: Fix sigaltstack structure definition linux-user: Implement gethostname linux-user: Perform more checks on iovec lists linux-user: fix multi-threaded /proc/self/maps linux-user: fix statfs
2012-10-19microblaze: Support setting of TLS ptrEdgar E. Iglesias1-0/+2
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
2012-10-12linux-user: register align p{read, write}64Alexander Graf1-0/+8
pread64 and pwrite64 pass 64bit parameters which for some architectures need to be aligned to special argument pairs, creating a gap argument. Handle this special case the same way we handle it in other places of the code. Reported-by: Alex Barcelo <abarcelo@ac.upc.edu> Signed-off-by: Alexander Graf <agraf@suse.de> Tested-by: Alex Barcelo <abarcelo@ac.upc.edu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: ppc: mark as long long alignedAlexander Graf1-1/+6
The SysV PPC32 ABI dictates that long long (64bit) parameters are pass in odd/even register pairs. Because unlike ARM and MIPS we start at an odd register number, we can reuse the same aligning code that ARM and MIPS use. Clarified inline comment that it is SysV ABI that requires long long aligned parameters - Riku Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: Fix siginfo handlingRichard Henderson1-1/+1
Compare signal numbers in the proper domain. Convert all of the fields for SIGIO and SIGCHLD. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: Implement gethostnameRichard Henderson1-0/+13
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: Perform more checks on iovec listsRichard Henderson1-60/+102
Validate count between 0 and IOV_MAX. Limit total length of operation in the same way the kernel does. Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: fix multi-threaded /proc/self/mapsAlexander Graf1-2/+2
When reading our faked /proc/self/maps from a secondary thread, we get an invalid stack entry. This is because ts->stack_base is not initialized in non-primary threads. However, ts->info is, and the stack layout information we're looking for is there too. So let's use that one instead! Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-10-12linux-user: fix statfsAlexander Graf1-0/+4
The statfs syscall should always memset(0) its full struct extent before writing to it. Newer versions of the syscall use one of the reserved fields for flags, which would otherwise get stale values from uncleaned memory. This fixes libarchive for me, which got confused about the return value of pathconf("/", _PC_REC_XFER_ALIGN) otherwise, as it some times gave old pointers as return value. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-09-23linux-user: Remove redundant null check and replace free by g_freeStefan Weil1-3/+1
Report from smatch: linux-user/syscall.c:3632 do_ioctl_dm(220) info: redundant null check on big_buf calling free() 'big_buf' was allocated by g_malloc0, therefore free was also replaced by g_free. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
2012-08-27linux-user: fix emulation of getdentsDmitry V. Levin1-6/+5
In case when TARGET_ABI_BITS == 32 && HOST_LONG_BITS == 64, the last byte of the target dirent structure (aka d_type byte) was never copied from the host dirent structure, thus breaking everything that relies on valid d_type value, e.g. glob(3). Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-08-22linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failureJim Meyering1-2/+2
Also, use g_malloc to avoid NULL-deref upon OOM. Signed-off-by: Jim Meyering <meyering@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-08-14linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_typeJing Huang1-4/+16
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket optionJing Huang1-0/+20
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-14linux-user: pass sockaddr from host to targetJing Huang1-3/+13
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-13linux-user: Move target_to_host_errno_table[] setup out of ioctl loopPeter Maydell1-5/+6
The code to initialise the target_to_host_errno_table[] array was accidentally inside the loop through checking and initialising all the supported ioctls. This was harmless but meant that we reinitialised the array several hundred times on startup. Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2012-08-04alpha-linux-user: Fix the getpriority syscallRichard Henderson1-5/+15
Alpha uses unbiased priority values in the syscall, with the a3 return value signaling error conditions. Therefore, properly interpret the libc getpriority as needed for the guest rather than passing the host value through unchanged. Signed-off-by: Richard Henderson <rth@twiddle.net>
2012-08-04alpha-linux-user: Properly handle the non-rt sigprocmask syscall.Richard Henderson1-2/+1
Name the syscall properly for QEMU, kernel source notwithstanding. Fix syntax errors in the code thus enabled within do_syscall. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2012-08-04linux-user: Translate pipe2 flags; add to straceRichard Henderson1-1/+2
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2012-08-04linux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATHRichard Henderson1-1/+14
Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2012-08-04alpha-linux-user: Handle TARGET_SSI_IEEE_RAISE_EXCEPTION properlyRichard Henderson1-10/+51
We weren't aggregating the exceptions, nor raising signals properly. Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2012-07-27target-or32: Add linux user supportJia Liu1-1/+1
Add QEMU OpenRISC linux user support. Signed-off-by: Jia Liu <proljc@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-06-04linux-user: Use cpu_reset() after cpu_init() / cpu_copy()Andreas Färber1-1/+1
Eliminates cpu_state_reset() usage. Signed-off-by: Andreas Färber <afaerber@suse.de>
2012-05-03linux-user: fix emulation of /proc/self/mapsAlexander Graf1-1/+41
Improve the emulation of /proc/self/maps by reading the underlying host maps file and passing lines through with addresses adjusted to be guest addresses. This is necessary to avoid false triggers of the glibc check that a format string containing '%n' is not in writable memory. (For an example see the bug reported in https://bugs.launchpad.net/qemu-linaro/+bug/947888 where gpg aborts.) Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-05-03linux-user: Clean up interim solution for exit syscallAndreas Färber1-4/+0
After all target CPUs have been QOM'ified, we no longer need an #ifdef to switch between object_delete() and g_free() in NPTL thread exit. Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-04-15linux-user: Fix exit syscall with QOM CPUAndreas Färber1-0/+4
For QOM'ified CPUs we cannot g_free() CPUArchState, we must object_delete() the object it is embedded into. Fixes LP#982321 (invalid free() while executing pacman with qemu-arm). Reported-by: Serge Schneider <serge@xecdesign.com> Reported-by: Russell Keith Davis <russell@russelldavis.org> Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Tested-by: Serge Schneider <serge@xecdesign.com> Tested-by: Russell Keith Davis <russell@russelldavis.org> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2012-04-06linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAMEPeter Maydell1-0/+24
Add support for the prctl options PR_GET_NAME and PR_SET_NAME, which take or return a name in a 16 byte buffer pointed to by arg2. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-04-06linux-user/syscall.c: Fix indentation in prctl handlingPeter Maydell1-14/+15
Clean up the odd indentation of this switch statement before we double its size by adding new cases to it. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-04-06linux-user: fix fallocateAlexander Graf1-0/+5
Fallocate gets off_t parameters passed in, so we should also read them out accordingly. Signed-off-by: Alexander Graf <agraf@suse.de> --- v1 -> v2: - unbreak 64-bit guests Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2012-04-06linux-user: implement device mapper ioctlsAlexander Graf1-0/+226
This patch implements all ioctls currently implemented by device mapper, enabling us to run dmsetup and kpartx inside of linux-user. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>