summaryrefslogtreecommitdiffstats
path: root/linux-user/syscall.c
Commit message (Collapse)AuthorAgeFilesLines
* alloca one extra byte socketsJoakim Tjernlund2014-07-151-3/+3
| | | | | | | | | target_to_host_sockaddr() may increase the lenth with 1 byte for AF_UNIX sockets so allocate 1 extra byte. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: handle AF_PACKET sockaddrs in target_to_host_sockaddrJoakim Tjernlund2014-07-151-0/+7
| | | | | | | | | Implement conversion of the AF_PACKET sockaddr subtype in target_to_host_sockaddr. Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* qemu-user: Impl. setsockopt(SO_BINDTODEVICE)Joakim Tjernlund2014-07-151-0/+19
| | | | | | Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: support the KDSIGACCEPT ioctlPaul Burton2014-06-291-0/+7
| | | | | | | | Add a definition of the KDSIGACCEPT ioctl & allow its use by target programs. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: allow NULL tv argument for settimeofdayPaul Burton2014-06-291-4/+8
| | | | | | | | | | The tv argument to the settimeofday syscall is allowed to be NULL, if the program only wishes to provide the timezone. QEMU previously returned -EFAULT when tv was NULL. Instead, execute the syscall & provide NULL to the kernel as the target program expected. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: respect timezone for settimeofdayPaul Burton2014-06-291-1/+28
| | | | | | | | | | | | | The settimeofday syscall accepts a tz argument indicating the desired timezone to the kernel. QEMU previously ignored any argument provided by the target program & always passed NULL to the kernel. Instead, translate the argument & pass along the data userland provided. Although this argument is described by the settimeofday man page as obsolete, it is used by systemd as of version 213. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: allow NULL arguments to mountPaul Burton2014-06-291-22/+53
| | | | | | | | | | | | | | | | | | | | Calls to the mount syscall can legitimately provide NULL as the value for the source of filesystemtype arguments, which QEMU would previously reject & return -EFAULT to the target program. An example of this is remounting an already mounted filesystem with different properties. Instead of rejecting such syscalls with -EFAULT, pass NULL along to the kernel as the target program expects. Additionally this patch fixes a potential memory leak when DEBUG_REMAP is enabled and lock_user_string fails on the target or filesystemtype arguments but a prior argument was non-NULL and already locked. Since the patch already touched most lines of the TARGET_NR_mount case, it fixes the indentation & coding style for good measure. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: support SO_PASSSEC setsockopt optionPaul Burton2014-06-291-0/+3
| | | | | | | | | Translate the SO_PASSSEC option to setsockopt to the host value & perform the syscall as expected, allowing use of the option by target programs. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: support SO_{SND, RCV}BUFFORCE setsockopt optionsPaul Burton2014-06-291-0/+6
| | | | | | | | | Translate the SO_SNDBUFFORCE & SO_RCVBUFFORCE options to setsockopt to the host values & perform the syscall as expected, allowing use of those options by target programs. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: support SO_ACCEPTCONN getsockopt optionPaul Burton2014-06-291-0/+3
| | | | | | | | Translate the SO_ACCEPTCONN option to the host value & execute the syscall as expected. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: translate the result of getsockopt SO_TYPEPaul Burton2014-06-291-0/+34
| | | | | | | | | | | | | QEMU previously passed the result of the host syscall directly to the target program. This is a problem if the host & target have different representations of socket types, as is the case when running a MIPS target program on an x86 host. Introduce a host_to_target_sock_type helper function mirroring the existing target_to_host_sock_type, and call it to translate the value provided by getsockopt when called for the SO_TYPE option. Signed-off-by: Paul Burton <paul@archlinuxmips.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: added fake open() for /proc/self/cmdlineWim Vander Schelden2014-06-291-0/+46
| | | | | Signed-off-by: Wim Vander Schelden <wim@fixnum.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* Add support for MAP_NORESERVE mmap flag.Christophe Lyon2014-06-291-0/+2
| | | | | | | | | | mmap_flags_tbl contains a list of mmap flags, and how to map them to the target. This patch adds MAP_NORESERVE, which was missing to the list. Signed-off-by: Christophe Lyon <christophe.lyon@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* target-mips: implement UserLocal RegisterPetar Jovanovic2014-06-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | From MIPS documentation (Volume III): UserLocal Register (CP0 Register 4, Select 2) Compliance Level: Recommended. The UserLocal register is a read-write register that is not interpreted by the hardware and conditionally readable via the RDHWR instruction. This register only exists if the Config3-ULRI register field is set. Privileged software may write this register with arbitrary information and make it accessible to unprivileged software via register 29 (ULR) of the RDHWR instruction. To do so, bit 29 of the HWREna register must be set to a 1 to enable unprivileged access to the register. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Aurelien Jarno <aurelien@aurel32.net> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* linux-user: Return correct errno for unsupported netlink socketEd Swierk2014-06-171-1/+1
| | | | | | | | | This fixes "Cannot open audit interface - aborting." when the EAFNOSUPPORT errno differs between the target and host architectures (e.g. mips target and x86_64 host). Signed-off-by: Ed Swierk <eswierk@skyportsystems.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Don't overrun guest buffer in sched_getaffinityPeter Maydell2014-06-171-0/+16
| | | | | | | | | | | | | | | | | | If the guest's "long" type is smaller than the host's, then our sched_getaffinity wrapper needs to round the buffer size up to a multiple of the host sizeof(long). This means that when we copy the data back from the host buffer to the guest's buffer there might be more than we can fit. Rather than overflowing the guest's buffer, handle this case by returning EINVAL or ignoring the unused extra space, as appropriate. Note that only guests using the syscall interface directly might run into this bug -- the glibc wrappers around it will always use a buffer whose size is a multiple of 8 regardless of guest architecture. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: fix getrusage and wait4 failures with invalid rusage structPetar Jovanovic2014-05-051-3/+8
| | | | | | | | | | Implementations of system calls getrusage and wait4 have not previously handled correctly cases when incorrect address of struct rusage is passed. This change makes sure return values are correctly set for these cases. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: move uname functions to uname.cRiku Voipio2014-05-021-102/+0
| | | | | | | Make syscall.c slightly smaller by moving uname-related functions to uname.c. Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: rename cpu-uname -> unameRiku Voipio2014-05-021-1/+1
| | | | | | | To move more uname related functions out of syscall.c, rename cpu-uname.{c,h} to uname.{c.h} Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: avoid using glibc internals in _syscall5 and in definition of ↵Natanael Copa2014-05-021-1/+1
| | | | | | | | | | | | | | | | target_sigevent struct Use the public sigset_t instead of the glibc specific internal __sigset_t in _syscall. Calculate the sigevent pad size is calculated in similar way as kernel does it instead of using glibc internal field _pad. This is needed for building with musl libc. Signed-off-by: Natanael Copa <ncopa@alpinelinux.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
* linux-user: Handle arches with llseek instead of _llseekJames Hogan2014-05-021-0/+5
| | | | | | | | | | | | | | | Recently merged kernel ports (such as OpenRISC and Meta) have an llseek system call instead of _llseek. This is handled for the host architecture by defining __NR__llseek as __NR_llseek, but not for the target architecture. Handle it in the same way for these architectures, defining TARGET_NR__llseek as TARGET_NR_llseek. Signed-off-by: James Hogan <james.hogan@imgtec.com> Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Jia Liu <proljc@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Add support for SCM_CREDENTIALS.Huw Davies2014-05-021-0/+11
| | | | | Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Move if-elses to a switch statement.Huw Davies2014-05-021-18/+33
| | | | | | | This makes adding more message types cleaner. Signed-off-by: Huw Davies <huw@codeweavers.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Add /proc/self/exe open forwardingMaxim Ostapenko2014-05-021-0/+5
| | | | | | | | | | | QEMU already supports /proc/self/{maps,stat,auxv} so addition of /proc/self/exe is rather trivial. Fixes https://bugs.launchpad.net/qemu/+bug/1299190 Signed-off-by: Maxim Ostapenko <m.ostapenko@partner.samsung.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 accept4()Petar Jovanovic2014-04-011-2/+5
| | | | | | | | | | | Flags NONBLOCK and CLOEXEC can have different values on the host and the guest, so set correct host values before calling accept4(). This fixes several issues with accept4 system call and user-mode of QEMU. 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: Fix build if headers don't define _LINUX_CAPABILITY_VERSION_1Peter Maydell2014-03-191-1/+1
| | | | | | | | | | | Older kernel headers don't define _LINUX_CAPABILITY_VERSION_1. Switch to using the older _LINUX_CAPABILITY_VERSION; newer headers still define this for source compatibility. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reported-by: Laurent Desnogues <laurent.desnogues@gmail.com> Reviewed-by: Laurent Desnogues <laurent.desnogues@gmail.com> Acked-by: Riku Voipio <riku.voipio@iki.fi>
* linux-user: Implement capget, capsetPeter Maydell2014-03-171-2/+73
| | | | | | | | | Implement the capget and capset syscalls. This is useful because simple programs like 'ls' try to use it in AArch64, and otherwise we emit a lot of noise about it being unimplemented. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* signal: added a wrapper for sigprocmask functionAlex Barcelo2014-03-171-7/+7
| | | | | | | | | | | | | | | | | | Create a wrapper for signal mask changes initiated by the guest; (this includes syscalls and also the sigreturns from signal.c) this will give us a place to put code which prevents the guest from changing the handling of signals used by QEMU itself internally. The wrapper is called from all the guest-initiated sigprocmask, but is not called from internal qemu sigprocmask calls. Signed-off-by: Alex Barcelo <abarcelo@ac.upc.edu> [PMM: Added calls to wrapper for sigprocmask uses in signal.c when setting the signal mask on entry and exit from signal handlers, since these also are guest-provided signal masks.] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: implement F_[GS]ETOWN_EXAndreas Schwab2014-03-171-0/+36
| | | | | | | F_GETOWN is replaced by F_GETOWN_EX inside the glibc fcntl wrapper Signed-off-by: Andreas Schwab <schwab@suse.de> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Don't return uninitialized value for atomic_barrier syscallPeter Maydell2014-03-171-0/+1
| | | | | | | | QEMU's implementation of the m68k atomic_barrier syscall, like the kernel's, is just a no-op. However we still need to return a result code from it. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* cpu: Move opaque field from CPU_COMMON to CPUStateAndreas Färber2014-03-131-12/+18
| | | | Signed-off-by: Andreas Färber <afaerber@suse.de>
* linux-user: translate signal number on return from sigtimedwaitPetar Jovanovic2014-03-031-5/+11
| | | | | | | | | | | | On success, sigtimedwait() returns a signal number that needs to be translated from a host value to a target value. This change also fixes issues with sigwait (that is implemented using sigtimedwait()). Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
* linux-user: Implement sendmmsg syscallAlexander Graf2014-03-031-10/+76
| | | | | | | | | | | | | | | | | | | | | | Glibc when built for newer kernels assumes that the sendmmsg syscall is available. Without it, dns resolution simply fails to work. Wrap the syscall with existing infrastructure so that we don't have a host dependency on sendmmsg. To avoid locking the same area of guest memory twice (which will break if DEBUG_REMAP is defined) we pull the lock/unlock part of do_sendrecvmsg() out into its own function so the actual implementation can be shared. Signed-off-by: Alexander Graf <agraf@suse.de> [PMM: add recvmmsg support; handle errors (which also implies support for non-blocking operations); cap the vector length as the kernel implementation does; don't lock guest memory twice; support MSG_WAITFORONE flag] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net>
* linux-user: Fix getresuid, getresgid if !USE_UID16Peter Maydell2014-03-031-6/+12
| | | | | | | | | | | | | The size of the UID/GID types depends on whether USE_UID16 is defined. Define a new put_user_id() which writes a uid/gid type to guest memory. This fixes getresuid and getresgid, which were always storing 16 bits even if the uid type was 32 bits. Reported-by: Michael Matz <matz@suse.de> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Richard Henderson <rth@twiddle.net>
* linux-user: Fix error handling in target_to_host_semarray()Peter Maydell2014-02-191-1/+6
| | | | | | | | | | | Fix two issues in error handling in target_to_host_semarray(): * don't leak the host_array buffer if lock_user fails * return an error if malloc() fails v2: added missing * -Riku Voipio Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Implement BLKPG ioctlAndreas Färber2014-02-191-0/+1
| | | | | | Signed-off-by: Andreas Färber <afaerber@suse.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Fix error handling in lock_iovec()Peter Maydell2014-02-181-5/+7
| | | | | | | | | | In lock_iovec() if lock_user() failed we were doing an unlock_user but not a free(vec), which is the wrong way round. We were also assuming that free() and unlock_user() don't touch errno, which is not guaranteed. Fix both these problems. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: refactor do_socketcall()Michael Tokarev2014-02-151-258/+68
| | | | | | | | | | | | Refactor do_socketcall() to do argument conversion/checking first, according to a lookup table (which call has how many args) and by calling the right function second with ready-to-go arguments. This ensures that all arguments are handled as abi_long, according to socketcall prototype, and simplifies argument handling alot too. Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
* linux-user: fixed recvfrom() addrlenPavel Zbitskiy2014-01-151-1/+1
| | | | | | | | | | addrlen parameter of recvfrom() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes addrlen type to abi_ulong. Signed-off-by: Pavel Zbitskiy <pavel.zbitskiy@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* linux-user: fixed getsockopt() optlenPavel Zbitskiy2014-01-151-1/+1
| | | | | | | | | | optlen parameter of getsockopt() of type socklen_t* was read into variable of type socklen_t, that caused zeroing out of upper 4 bytes when running s390x on top of x86_64. This patch changes optlen type to abi_ulong. Signed-off-by: Pavel Zbitskiy <pavel.zbitskiy@gmail.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
* linux-user: Support the accept4 socketcallAndré Hentschel2014-01-101-0/+16
| | | | | | | | | Cc: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: André Hentschel <nerv@dawncrow.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Erik de Castro Lopo <erikd@mega-nerd.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: pass correct parameter to do_shmctl()Petar Jovanovic2013-11-291-1/+1
| | | | | | | Fix shmctl issue by passing correct parameter buf to do_shmctl(). Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: create target_structs header to place ipc_perm and shmid_dsPetar Jovanovic2013-11-291-48/+28
| | | | | | | | | Creating target_structs header in linux-user/$arch/ and making target_ipc_perm and target_shmid_ds its first inhabitants. The struct defintions may/should be further fine-tuned by arch maintainers. Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Implement handling of 5 POSIX timer syscalls.Erik de Castro Lopo2013-11-291-0/+176
| | | | | | | | Implement timer_create, timer_settime, timer_gettime, timer_getoverrun and timer_delete. Signed-off-by: Erik de Castro Lopo <erikd@mega-nerd.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Fix stat64 syscall for SPARC64Stefan Weil2013-11-071-3/+3
| | | | | | | | | | | | Some targets use a stat64 structure for the stat64 syscall while others use a stat structure. SPARC64 used the wrong kind. Instead of extending the conditional compilation in syscall.c, now a macro TARGET_HAS_STRUCT_STAT64 is defined whenever a target has a target_stat64. Signed-off-by: Stefan Weil <sw@weilnetz.de> Reviewed-by: Erik de Castro Lopo <erikd@mega-nerd.com>
* linux-user: Handle SOCK_CLOEXEC/NONBLOCK if unavailable on hostEdgar E. Iglesias2013-09-241-3/+37
| | | | | | | | | If the host lacks SOCK_CLOEXEC, bail out with -EINVAL. If the host lacks SOCK_ONONBLOCK, try to emulate it with fcntl() and O_NONBLOCK. Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* [v2] linux-user: implement m68k atomic syscallsRiku Voipio2013-09-241-0/+28
| | | | | | | | | | | | | | | | With nptl enabled, atomic_cmpxchg_32 and atomic_barrier system calls are needed. This patch enabled really dummy versions of the system calls, modeled after the m68k kernel code. With this patch I am able to execute m68k binaries with qemu linux-user (busybox compiled for coldfire). [v2] que an segfault instead of returning a EFAULT to keep in line with kernel code. Cc: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: correct how SOL_SOCKET is converted from target to host and backPetar Jovanovic2013-09-241-5/+13
| | | | | | | | | Previous implementation does not take into account that SOL_SOCKET constant can be arch specific. This change fixes some issues with sendmsg/recvmsg. 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: add some IPV6 commands in setsockop()Laurent Vivier2013-09-241-0/+20
| | | | | | Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
* linux-user: Add setsockopt(SO_ATTACH_FILTER)Laurent Vivier2013-09-241-0/+44
| | | | | | | | This is needed to be able to run dhclient. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
OpenPOWER on IntegriCloud