summaryrefslogtreecommitdiff
path: root/linux-user/syscall_defs.h
AgeCommit message (Collapse)Author
2019-05-19target/alpha: Fix user-only floating-point exceptionsRichard Henderson
Record the software fp control register, as set by the osf_setsysinfo syscall. Add those masked exceptions to fpcr_exc_enable. Do not raise a signal for masked fp exceptions. Fixes: https://bugs.launchpad.net/bugs/1701835 Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
2019-01-11remove space-tab sequencesPaolo Bonzini
There are not many, and they are all simple mistakes that ended up being committed. Remove them. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <20181213223737.11793-2-pbonzini@redhat.com> Reviewed-by: Wainer dos Santos Moschetta <wainersm@redhat.com> Acked-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2018-10-19linux-user: Implement special usbfs ioctls.Cortland Tölva
Userspace submits a USB Request Buffer to the kernel, optionally discards it, and finally reaps the URB. Thunk buffers from target to host and back. Tested by running an i386 scanner driver on ARMv7 and by running the PowerPC lsusb utility on x86_64. The discardurb ioctl is not exercised in these tests. Signed-off-by: Cortland Tölva <cst@tolva.net> Message-Id: <20181008163521.17341-4-cst@tolva.net> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2018-10-19linux-user: Define ordinary usbfs ioctls.Cortland Tölva
Provide ioctl definitions for the generic thunk mechanism to convert most usbfs calls. Calculate arg size at runtime. Signed-off-by: Cortland Tölva <cst@tolva.net> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20181008163521.17341-3-cst@tolva.net> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2018-09-25linux-user: add SO_LINGER to {g,s}etsockoptCarlo Marcelo Arenas Belón
Original implementation for setsockopt by Chen Gang[1]; all bugs mine, including removing assignment for optname which hopefully makes the logic easier to follow and moving some variables to make the code more selfcontained. [1] http://patchwork.ozlabs.org/patch/565659/ Signed-off-by: Carlo Marcelo Arenas Belón <carenas@gmail.com> Co-Authored-By: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180824085601.6259-1-carenas@gmail.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2018-06-04linux-user: remove useless #ifLaurent Vivier
Remove a "#if defined(XX) || defined(YY) || ..." with all available targets Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-16-laurent@vivier.eu>
2018-06-04linux-user: move hppa signal definitions to hppa/target_signal.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-15-laurent@vivier.eu>
2018-06-04linux-user: move alpha signal definitions to alpha/target_signal.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-14-laurent@vivier.eu>
2018-06-04linux-user: move openrisc signal definitions to openrisc/target_signal.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-13-laurent@vivier.eu>
2018-06-04linux-user: move mips signal definitions to mips/target_signal.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-12-laurent@vivier.eu>
2018-06-04linux-user: move sparc signal definitions to sparc/target_signal.hLaurent Vivier
Remove sparc64/target_signal.h, use sparc/target_signal.h instead. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-11-laurent@vivier.eu>
2018-06-04linux-user: move generic signal definitions to generic/signal.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-10-laurent@vivier.eu>
2018-06-04linux-user: move get_sp_from_cpustate() to target_cpu.hLaurent Vivier
Remove useless includes Fix HPPA include guard. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180529194207.31503-9-laurent@vivier.eu>
2018-06-04linux-user: move sparc/sparc64 fcntl definitions to sparc/target_fcntl.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-8-laurent@vivier.eu>
2018-06-04linux-user: move ppc fcntl definitions to ppc/target_fcntl.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-7-laurent@vivier.eu>
2018-06-04linux-user: move mips/mips64 fcntl definitions to mips/target_fcntl.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-6-laurent@vivier.eu>
2018-06-04linux-user: move arm/aarch64/m68k fcntl definitions to ↵Laurent Vivier
[arm|aarch64|m68k]/target_fcntl.h No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180529194207.31503-5-laurent@vivier.eu>
2018-06-04linux-user: move hppa fcntl definitions to hppa/target_fcntl.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180529194207.31503-4-laurent@vivier.eu>
2018-06-04linux-user: move alpha fcntl definitions to alpha/target_fcntl.hLaurent Vivier
No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180529194207.31503-3-laurent@vivier.eu>
2018-06-04linux-user: move generic fcntl definitions to generic/fcntl.hLaurent Vivier
add a per target target_fcntl.h and include the generic one from them No code change. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180529194207.31503-2-laurent@vivier.eu>
2018-05-11linux-user: fix flock/flock64 paddingLaurent Vivier
include/uapi/asm-generic/fcntl.h insert a padding macro at the end of the structures flock and flock64. This macro is defined to "short __unused;" on sparc, and "long pad[4]" on mips. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Message-Id: <20180509231123.20864-3-laurent@vivier.eu>
2018-05-11linux-user: define correct fcntl() values for sparcLaurent Vivier
Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Max Filippov <jcmvbkbc@gmail.com> Message-Id: <20180509231123.20864-2-laurent@vivier.eu>
2018-05-03linux-user: remove useless padding in flock64 structureLaurent Vivier
Since commit 8efb2ed5ec ("linux-user: Correct signedness of target_flock l_start and l_len fields"), flock64 structure uses abi_llong for l_start and l_len in place of "unsigned long long" this should force them to be aligned accordingly to the target rules. So we can remove the padding field and the QEMU_PACKED attribute. I have compared the result of the following program before and after the change: cat -> flock64_dump <<EOF p/d sizeof(struct target_flock64) p/d &((struct target_flock64 *)0)->l_type p/d &((struct target_flock64 *)0)->l_whence p/d &((struct target_flock64 *)0)->l_start p/d &((struct target_flock64 *)0)->l_len p/d &((struct target_flock64 *)0)->l_pid quit EOF for file in build/all/*-linux-user/qemu-* ; do echo $file gdb -batch -nx -x flock64_dump $file 2> /dev/null done The sizeof() changes because we remove the QEMU_PACKED. The new size is 32 (except for i386 and m68k) and this is the real size of "struct flock64" on the target architecture. The following architectures differ: aarch64_be, aarch64, alpha, armeb, arm, cris, hppa, nios2, or1k, riscv32, riscv64, s390x. For a subset of these architectures, I have checked with the following program the new structure is the correct one: #include <stdio.h> #define __USE_LARGEFILE64 #include <fcntl.h> int main(void) { printf("struct flock64 %d\n", sizeof(struct flock64)); printf("l_type %d\n", &((struct flock64 *)0)->l_type); printf("l_whence %d\n", &((struct flock64 *)0)->l_whence); printf("l_start %d\n", &((struct flock64 *)0)->l_start); printf("l_len %d\n", &((struct flock64 *)0)->l_len); printf("l_pid %d\n", &((struct flock64 *)0)->l_pid); } [I have checked aarch64, alpha, hppa, s390x] For ARM, the target_flock64 becomes the EABI definition, so we need to define the OABI one in place of the EABI one and use it when it is needed. I have also fixed the alignment value for sh4 (to align llong on 4 bytes) (see c2e3dee6e0 "linux-user: Define target alignment size") [We should check alignment properties for cris, nios2 and or1k] Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20180502215730.28162-1-laurent@vivier.eu>
2018-04-03linux-user: fix TARGET___O_TMPFILE for sparcLaurent Vivier
Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180402102453.9883-3-laurent@vivier.eu>
2018-04-03linux-user: define TARGET_ARCH_HAS_KA_RESTORERLaurent Vivier
Sparc as an extended sigaction structure containing the field ka_restorer used in place of sa_restorer. Define TARGET_ARCH_HAS_KA_RESTORER and use it with sparc. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180402102453.9883-2-laurent@vivier.eu>
2018-03-17Merge remote-tracking branch 'remotes/xtensa/tags/20180316-xtensa' into stagingPeter Maydell
target/xtensa linux-user support. - small cleanup for xtensa registers dumping (-d cpu); - add support for debugging linux-user process with xtensa-linux-gdb (as opposed to xtensa-elf-gdb), which can only access unprivileged registers; - enable MTTCG for target/xtensa; - cleanup in linux-user/mmap area making sure that it works correctly with limited 30-bit-wide user address space; - import xtensa-specific definitions from the linux kernel, conditionalize user-only/softmmu-only code and add handlers for signals, exceptions, process/thread creation and core registers dumping. # gpg: Signature made Fri 16 Mar 2018 16:46:19 GMT # gpg: using RSA key 51F9CC91F83FA044 # gpg: Good signature from "Max Filippov <filippov@cadence.com>" # gpg: aka "Max Filippov <max.filippov@cogentembedded.com>" # gpg: aka "Max Filippov <jcmvbkbc@gmail.com>" # Primary key fingerprint: 2B67 854B 98E5 327D CDEB 17D8 51F9 CC91 F83F A044 * remotes/xtensa/tags/20180316-xtensa: MAINTAINERS: fix W: address for xtensa qemu-binfmt-conf.sh: add qemu-xtensa target/xtensa: add linux-user support linux-user: drop unused target_msync function linux-user: fix target_mprotect/target_munmap error return values linux-user: fix assertion in shmdt linux-user: fix mmap/munmap/mprotect/mremap/shmat target/xtensa: support MTTCG target/xtensa: use correct number of registers in gdbstub target/xtensa: mark register windows in the dump target/xtensa: dump correct physical registers Signed-off-by: Peter Maydell <peter.maydell@linaro.org> # Conflicts: # linux-user/syscall.c
2018-03-16target/xtensa: add linux-user supportMax Filippov
Import list of syscalls from the kernel source. Conditionalize code/data that is only used with softmmu. Implement exception handlers. Implement signal hander (only the core registers for now, no coprocessors or TIE). Cc: Riku Voipio <riku.voipio@iki.fi> Cc: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
2018-03-09linux-user: Support f_flags in statfs when available.Shea Levy
Signed-off-by: Shea Levy <shea@shealevy.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180301111500.15717-1-shea@shealevy.com> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2018-03-09linux-user: Drop unicore32 codePeter Maydell
We dropped the unicore32-linux-user target in commit 5e2b40f7271cf9 in 2016. Nobody has made any attempt to fix the issues that caused us to drop it, so remove the associated code. (The system emulation parts of unicore32 remain.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20180308144733.25615-2-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2018-03-07RISC-V Linux User EmulationMichael Clark
Implementation of linux user emulation for RISC-V. Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Sagar Karandikar <sagark@eecs.berkeley.edu> Signed-off-by: Michael Clark <mjc@sifive.com>
2018-01-23linux-user: Don't use CMSG_ALIGN(sizeof struct cmsghdr)Peter Maydell
The Linux struct cmsghdr is already guaranteed to be sufficiently aligned that CMSG_ALIGN(sizeof struct cmsghdr) is always equal to sizeof struct cmsghdr. Stop doing the unnecessary alignment arithmetic for host and target cmsghdr. This follows kernel commit 1ff8cebf49ed9e9ca2 and brings our TARGET_CMSG_* macros back into line with the kernel ones, as well as making them easier to understand. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <1513345976-22958-3-git-send-email-peter.maydell@linaro.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2017-11-07linux-user: Handle TARGET_MAP_STACK and TARGET_MAP_HUGETLBHelge Deller
Add the missing defines and for TARGET_MAP_STACK and TARGET_MAP_HUGETLB for alpha, mips, ppc, x86, hppa. Fix the mmap_flags translation table to translate MAP_HUGETLB between host and target architecture, and to drop MAP_STACK. Signed-off-by: Helge Deller <deller@gmx.de> Message-Id: <20170311183016.GA20514@ls3530.fritz.box> [rth: Drop MAP_STACK instead of translating it, since it is ignored in the kernel anyway. Fix tabs to spaces.] Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-11-07linux-user/hppa: Fix TARGET_F_RDLCK, TARGET_F_WRLCK, TARGET_F_UNLCKHelge Deller
Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <rth@twiddle.net> Message-ID: <20170311175019.GA7195@ls3530.fritz.box> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-11-07linux-user/hppa: Fix TARGET_MAP_TYPEHelge Deller
TARGET_MAP_TYPE needs to be 0x03 instead of 0x0f on the hppa architecture, otherwise it conflicts with MAP_FIXED which is 0x04. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <rth@twiddle.net> Message-ID: <20170311175019.GA7195@ls3530.fritz.box> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-11-07linux-user/hppa: Fix TARGET_SA_* definesHelge Deller
Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-11-07linux-user: Restrict usage of sa_restorerRichard Henderson
Reading and writing to an sa_restorer member that isn't supposed to exist corrupts user memory. Introduce TARGET_ARCH_HAS_SA_RESTORER, similar to the kernel's __ARCH_HAS_SA_RESTORER. Reported-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-10-19Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20171018' ↵Peter Maydell
into staging Linux-user updates for Qemu 2.11 # gpg: Signature made Wed 18 Oct 2017 13:20:14 BST # gpg: using RSA key 0xB44890DEDE3C9BC0 # gpg: Good signature from "Riku Voipio <riku.voipio@iki.fi>" # gpg: aka "Riku Voipio <riku.voipio@linaro.org>" # Primary key fingerprint: FF82 03C8 C391 98AE 0581 41EF B448 90DE DE3C 9BC0 * remotes/riku/tags/pull-linux-user-20171018: linux-user: Fix TARGET_MTIOCTOP/MTIOCGET/MTIOCPOS values linux-user/main: support dfilter linux-user: Fix target FS_IOC_GETFLAGS and FS_IOC_SETFLAGS numbers linux-user/sh4: Reduce TARGET_VIRT_ADDR_SPACE_BITS to 31 linux-user: Tidy and enforce reserved_va initialization tcg: Fix off-by-one in assert in page_set_flags linux-user: Allow -R values up to 0xffff0000 for 32-bit ARM guests linux-user: remove duplicate break in syscall target/m68k,linux-user: manage FP registers in ucontext linux-user: fix O_TMPFILE handling Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2017-10-17linux-user: Fix TARGET_MTIOCTOP/MTIOCGET/MTIOCPOS valuesPeter Maydell
The TARGET_MTIOCTOP/TARGET_MTIOCGET/TARGET_MTIOCPOS values were being defined in terms of host struct types, but these structures are such that their size might differ on different hosts. Switch to using a target struct definition instead. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-10-16linux-user: Add some random ioctlsMarco A L Barbosa
Signed-off-by: Marco A L Barbosa <malbarbo@gmail.com> Reviewed-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2017-10-16linux-user: Fix target FS_IOC_GETFLAGS and FS_IOC_SETFLAGS numbersPeter Maydell
We were defining TARGET_FS_IOC_GETFLAGS and TARGET_FS_IOC_SETFLAGS using the host 'long' type in the size field, which meant that they had the wrong values if the host and guest had different sized longs. Switch to abi_long instead. This fixes a bug where these ioctls don't work on 32-bit guests on 64-bit hosts (and makes the LTP test 'setxattr03' pass where it did not previously.) Reported-by: pgndev <pgnet.dev@gmail.com> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2017-10-16linux-user: fix O_TMPFILE handlingRiku Voipio
Since O_TMPFILE might differ between guest and host, add it to the bitmask_transtbl. While at it, fix the definitions of O_DIRECTORY etc which should arm32 according to kernel sources. This fixes open14 and openat03 ltp testcases. Fixes: https://bugs.launchpad.net/qemu/+bug/1709170
2017-02-27linux-user: Add sockopts for IPv6 ping and IPv6 tracerouteHelge Deller
Add the neccessary sockopts for ping and traceroute on IPv6. This fixes the following qemu warnings with IPv6: Unsupported ancillary data: 0/2 Unsupported ancillary data: 0/11 Unsupported ancillary data: 41/25 Unsupported setsockopt level=0 optname=12 Unsupported setsockopt level=41 optname=16 Unsupported setsockopt level=41 optname=25 Unsupported setsockopt level=41 optname=50 Unsupported setsockopt level=41 optname=51 Unsupported setsockopt level=41 optname=8 Unsupported setsockopt level=58 optname=1 Tested with hppa-linux-user (big-endian) on x86_64 (little-endian). Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Tested-by: Philippe Mathieu-Daudé <f4bug@amsat.org> Message-Id: <20170218223130.GA25278@ls3530.fritz.box> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2017-02-16linux-user: Add FICLONE and FICLONERANGE ioctlsHelge Deller
Add missing FICLONE and FICLONERANGE ioctls. Signed-off-by: Helge Deller <deller@gmx.de> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Message-Id: <20170211222602.GA6399@ls3530.fritz.box> Signed-off-by: Laurent Vivier <laurent@vivier.eu>
2017-01-24nios2: Add usermode binaries emulationMarek Vasut
Add missing bits for qemu-user required for emulating Altera Nios2 userspace binaries. Signed-off-by: Marek Vasut <marex@denx.de> Cc: Chris Wulff <crwulff@gmail.com> Cc: Jeff Da Silva <jdasilva@altera.com> Cc: Ley Foon Tan <lftan@altera.com> Cc: Sandra Loosemore <sandra@codesourcery.com> Cc: Yves Vandervennet <yvanderv@altera.com> Reviewed-by: Alexander Graf <agraf@suse.de> Message-Id: <20170118220146.489-4-marex@denx.de> Signed-off-by: Richard Henderson <rth@twiddle.net>
2017-01-23linux-user: Add HPPA definitions to syscall_defs.hRichard Henderson
2017-01-23linux-user: Add some hppa ioctlsHelge Deller
Add F_GETLK, F_SETLK, F_SETLKW, F_GETOWN, F_SETOWN, F_SETSIG, F_GETSIG, F_GETLK64, F_SETLK64 and F_SETLKW64 for hppa. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Richard Henderson <rth@twiddle.net>
2017-01-22linux-user: Add SIOCGPGRP, SIOCGSTAMP, SIOCGSTAMPNSHelge Deller
Mirror syscall_defs.h for the element type of struct timeval and struct timespec, even though that's not 100% accurate for each guest. Signed-off-by: Helge Deller <deller@gmx.de> [rth: Changed the MK_ARRAY types as per above; added ioctl.h entries.] Signed-off-by: Richard Henderson <rth@twiddle.net>
2017-01-22Revert "Remove remainders of HPPA backend"Richard Henderson
This reverts commit d41f3c3cc7a5fb9de144cc4022da14a9ff010671. Signed-off-by: Richard Henderson <rth@twiddle.net>
2016-10-21linux-user: Fix definition of target_sigevent for 32-bit guestsPeter Maydell
The sigevent structure includes a union with some fields which are pointers. For the QEMU target_sigevent structure we must represent these as abi_ulongs, not host function pointers. This error was causing the compiler to believe it should 8-align the _sigev_un union on a 64-bit host, which meant that the code in target_to_host_sigevent() was looking at the wrong offset to find the _tid field, and timer_create() would spuriously fail with EINVAL. This fixes the final loose end noted in LP:1042388. While we're editing the structure, switch the 'int32_t' fields to 'abi_int'; this will only matter for guests with non-standard integer alignment like m68k. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix syslog() syscall supportAleksandar Markovic
There are currently several problems related to syslog() support. For example, if the second argument "bufp" of target syslog() syscall is NULL, the current implementation always returns error code EFAULT. However, NULL is a perfectly valid value for the second argument for many use cases of this syscall. This is, for example, visible from this excerpt of man page for syslog(2): > EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is > NULL, or len is less than zero; or for type 8, the level is > outside the range 1 to 8). Moreover, the argument "bufp" is ignored for all cases of values of the first argument, except 2, 3 and 4. This means that for such cases (the first argument is not 2, 3 or 4), there is no need to pass "buf" between host and target, and it can be set to NULL while calling host's syslog(), without loss of emulation accuracy. Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the correct returned error code is EINVAL, not EFAULT. All these details are reflected in this patch. "#ifdef TARGET_NR_syslog" is also proprerly inserted when needed. Support for Qemu's "-strace" switch for syslog() syscall is included too. LTP tests syslog11 and syslog12 pass with this patch (while fail without it), on any platform. Changes to original patch by Riku Voipio: fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335 Should fix also the build error in: https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>