summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
Commit message (Collapse)AuthorAgeFilesLines
* linux-user: fix setgroups/getgroups for non-UID16 archsAndreas Schwab2013-04-191-3/+3
| | | | | | | Don't assume target_id is a short. Signed-off-by: Andreas Schwab <schwab@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: fix undefined shift in copy_to_user_fdsetAndreas Schwab2013-04-191-1/+1
| | | | | | | | If TARGET_ABI_BITS is bigger than 32 we shift by more than the size of int. Signed-off-by: Andreas Schwab <schwab@suse.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: change do_semop to return target errno when unsuccessfulPetar Jovanovic2013-04-191-2/+2
| | | | | | | | | | do_semop() is called from two places, and one of these fails to convert return error to target errno when semop fails. This patch changes the function to always return target errno in case of an unsuccessful call. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: pass correct host flags to eventfd2 callPetar Jovanovic2013-04-121-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>
* linux-user/syscall.c: Don't warn about unimplemented get_robust_listPeter Maydell2013-03-111-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>
* linux-user: Implement accept4Peter Maydell2013-03-111-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>
* linux-user: Implement sendfile and sendfile64Peter Maydell2013-03-111-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>
* linux-user: make bogus negative iovec lengths fail EINVALPeter Maydell2013-03-111-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>
* linux-user: Support setgroups syscall with no groupsDillon Amburgey2013-03-111-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>
* linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futexJohn Rigby2013-03-111-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>
* cpu: Move host_tid field to CPUStateAndreas Färber2013-02-161-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>
* Merge branch 'for-linux-user' of ↵Anthony Liguori2013-02-061-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>
| * linux-user: correct reboot()Laurent Vivier2013-01-301-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>
| * linux-user: correct setsockopt()Laurent Vivier2013-01-301-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>
| * linux-user: correct msgrcv()Laurent Vivier2013-01-301-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>
* | cpu: do not use object_deletePaolo Bonzini2013-02-011-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>
* alpha-linux-user: Correct selectLaurent Vivier2013-01-161-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>
* alpha-linux-user: Translate fcntl l_typeLaurent Vivier2013-01-161-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>
* linux-user/syscall.c: remove forward declarationsJohn Spencer2013-01-041-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>
* Merge remote-tracking branch 'bonzini/header-dirs' into stagingAnthony Liguori2012-12-191-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>
| * misc: move include files to include/qemu/Paolo Bonzini2012-12-191-1/+1
| | | | | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
* | linux-user/syscall.c: remove wrong forward decl of setgroups()John Spencer2012-12-181-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>
* linux-user: Merge pread/pwrite into pread64/pwrite64Peter Maydell2012-12-081-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>
* Merge branch 'linux-user-for-upstream' of ↵Aurelien Jarno2012-10-191-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
| * linux-user: register align p{read, write}64Alexander Graf2012-10-121-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>
| * linux-user: ppc: mark as long long alignedAlexander Graf2012-10-121-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>
| * linux-user: Fix siginfo handlingRichard Henderson2012-10-121-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>
| * linux-user: Implement gethostnameRichard Henderson2012-10-121-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>
| * linux-user: Perform more checks on iovec listsRichard Henderson2012-10-121-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>
| * linux-user: fix multi-threaded /proc/self/mapsAlexander Graf2012-10-121-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>
| * linux-user: fix statfsAlexander Graf2012-10-121-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>
* | microblaze: Support setting of TLS ptrEdgar E. Iglesias2012-10-191-0/+2
|/ | | | Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
* linux-user: Remove redundant null check and replace free by g_freeStefan Weil2012-09-231-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>
* linux-user: fix emulation of getdentsDmitry V. Levin2012-08-271-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>
* linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failureJim Meyering2012-08-221-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>
* linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_typeJing Huang2012-08-141-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>
* linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket optionJing Huang2012-08-141-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>
* linux-user: pass sockaddr from host to targetJing Huang2012-08-141-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>
* linux-user: Move target_to_host_errno_table[] setup out of ioctl loopPeter Maydell2012-08-131-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>
* alpha-linux-user: Fix the getpriority syscallRichard Henderson2012-08-041-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>
* alpha-linux-user: Properly handle the non-rt sigprocmask syscall.Richard Henderson2012-08-041-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>
* linux-user: Translate pipe2 flags; add to straceRichard Henderson2012-08-041-1/+2
| | | | | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
* linux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATHRichard Henderson2012-08-041-1/+14
| | | | | Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
* alpha-linux-user: Handle TARGET_SSI_IEEE_RAISE_EXCEPTION properlyRichard Henderson2012-08-041-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>
* target-or32: Add linux user supportJia Liu2012-07-271-1/+1
| | | | | | | Add QEMU OpenRISC linux user support. Signed-off-by: Jia Liu <proljc@gmail.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* linux-user: Use cpu_reset() after cpu_init() / cpu_copy()Andreas Färber2012-06-041-1/+1
| | | | | | Eliminates cpu_state_reset() usage. Signed-off-by: Andreas Färber <afaerber@suse.de>
* linux-user: fix emulation of /proc/self/mapsAlexander Graf2012-05-031-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>
* linux-user: Clean up interim solution for exit syscallAndreas Färber2012-05-031-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>
* linux-user: Fix exit syscall with QOM CPUAndreas Färber2012-04-151-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>
* linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAMEPeter Maydell2012-04-061-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>
OpenPOWER on IntegriCloud