linux-user: Use qemu_getauxval for AT_EXECFD
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Richard Henderson <rth@twiddle.net>
util: Use qemu_getauxval in linux qemu_cache_utils_init
With this we no longer pass down envp, and thus all systems can havethe same void prototype. So also eliminate a useless thunk.
osdep: Create qemu_getauxval and qemu_init_auxval
Abstract away dependence on a system implementation of getauxval.
Signed-off-by: Richard Henderson <rth@twiddle.net>
linux-user: Fix stat64 syscall for SPARC64
Some targets use a stat64 structure for the stat64 syscall while othersuse a stat structure. SPARC64 used the wrong kind.
Instead of extending the conditional compilation in syscall.c, now amacro TARGET_HAS_STRUCT_STAT64 is defined whenever a target has a...
cpu: Drop cpu_model_str from CPU_COMMON
Since this is only read in cpu_copy() and linux-user has a globalcpu_model, drop the field from generic code.
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Move cpu_copy() into linux-user
It is only used there and is deemed very fragile if not incorrect in itscurrent memcpy() form. Moving it into linux-user will allow to moveparts into target_cpu.h headers and only copy what the ABI mandates.
linux-user: allow use of TIOCGSID
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 some IPV6 commands in setsockop()
linux-user: add support of binfmt_misc 'O' flag
The binfmt_misc module can calculate the credentials and securitytoken according to the binary instead of to the interpreter if the'C' flag is enabled.
To be able to execute non-readable binaries, this flag implies 'O'...
linux-user: correct how SOL_SOCKET is converted from target to host and back
Previous implementation does not take into account that SOL_SOCKET constantcan be arch specific. This change fixes some issues with sendmsg/recvmsg.
Signed-off-by: Petar Jovanovic <petar.jovanovic@imgtec.com>...
linux-user: Check type of microMIPS break instruction
microMIPS instructions that cause breakpoint exceptions come in16-bit and 32-bit variants. When handling exceptions caused bysuch instructions, the instruction type needs to be taken intoaccount when extracting the break code....
[v2] linux-user: implement m68k atomic syscalls
With nptl enabled, atomic_cmpxchg_32 and atomic_barriersystem calls are needed. This patch enabled really dummyversions of the system calls, modeled after the m68kkernel code.
With this patch I am able to execute m68k binaries...
linux-user: Handle SOCK_CLOEXEC/NONBLOCK if unavailable on host
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>...
alpha-linux-user: Fix umount syscall numbers
It has been pointed out on LKML that the alpha umount syscall numbersare named wrong, and a patch to rectify that has been posted for 3.11.
Glibc works around this by treating NR_umount as NR_umount2 ifNR_oldumount exists. That's more complicated than we need in QEMU,...
mips-linux-user: Adjust names in mips_syscall_args
The name field of MIPS_SYS isn't actually used; it's just documentation.But adjust the umount entries to match mips/syscall_nr.h anyway.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: convert /proc/net/route when endianess differs
This patch allows to have IP addresses in correct orderin the case of "netstat -nr" when the endianess of theguest differs from one of the host.
For instance, an m68k guest on an x86_64 host:...
linux-user: Add setsockopt(SO_ATTACH_FILTER)
This is needed to be able to run dhclient.
*-user: Fix typo in comment (ulocking -> unlocking)
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
*-user: Improve documentation for lock_user function
Add a missing "function" and replace "and" by "any".BSD and Linux use the same documentation here, so fix both.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Implement cpu_set_tls() and cpu_clone_regs() for AArch64
Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: John Rigby <john.rigby@linaro.org>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Message-id: 1378235544-22290-19-git-send-email-peter.maydell@linaro.org...
linux-user: Add AArch64 termbits.h definitions
Add the AArch64 termbits.h with all the target's termios relatedconstants and structures.
Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: John Rigby <john.rigby@linaro.org>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Allow targets to specify a minimum uname release
For newer target architectures, glibc can be picky about the kernelversion: for example, it will not run on an aarch64 system unlessthe kernel reports itself as at least 3.8.0. Accommodate this by...
linux-user: Add AArch64 support
This patch adds support for AArch64 in all the small corners oflinux-user (primarily in image loading and startup code).
linux-user: Don't treat AArch64 cpu names specially
32-bit ARM has a lot of different names for different types of CPUs it supports.On AArch64, we don't have this, so we really don't want to execute the 32-bitlogic. Stub it out for AArch64 linux-user guests....
linux-user: Add cpu loop for AArch64
Add the main linux-user cpu loop for AArch64. Since AArch64has a different system call interface, doesn't need to worryabout FPA emulation and may in the future keep the prefetch/dataabort information in different system registers, it's simplest...
linux-user: Add syscall number definitions for AArch64
The AArch64 syscall definitions are all publicly available in the Linuxkernel. Let's add them to our linux-user emulation target, so that wecan easily handle AArch64 syscalls.
Signed-off-by: Alexander Graf <agraf@suse.de>...
linux-user: Fix up AArch64 syscall handlers
Some syscall handlers have special code for ARM enabled that we don'tneed on AArch64. Exclude AArch64 in those cases. In other places wecan share struct definitions with other targets or have to provide ourown....
linux-user: Add signal handling for AArch64
This patch adds signal handling for AArch64. The code is based on therespective source in the Linux kernel.
Signed-off-by: Andreas Schwab <schwab@suse.de>Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: John Rigby <john.rigby@linaro.org>...
linux-user: Make sure NWFPE code is 32 bit ARM only
On ARM, linux-user emulation includes NWFPE support for emulating theancient FPA floating point coprocessor. This has long since beensuperseded by VFP and is only required for legacy binaries. TheAArch64 linux-user target doesn't compile in NWFPE support, so make...
cpu: Use QTAILQ for CPU list
Introduce CPU_FOREACH(), CPU_FOREACH_SAFE() and CPU_NEXT() shorthandmacros.
linux-user/signal.c: PPC: Silence clang uninitialized-use warning
Silence a clang warning in a PPC signal return function:
/home/petmay01/linaro/qemu-from-laptop/qemu/linux-user/signal.c:4611:9: error: variable 'sr_addr' is used uninitialized whenever 'if' condition is true [-Werror,-Wsometimes-uninitialized]...
linux-user/signal.c: Avoid using uninitialized data in ARM sigreturn
Rephrase code used in ARM sigreturn functions to avoid usinguninitialized variables. This fixes one genuine problem ('frame'would not be initialized if we took the error-exit path because...
linux-user: Return success from m68k set_thread_area syscall
The m68k set_thread_area syscall implementation failed to set thereturn value. Correctly set it zero, since this syscall will alwayssucceed.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: correct argument number for sys_mremap and sys_splice
sys_mremap missed 5th argument (new_address), which caused examples thatremap to a specific address to fail.sys_splice missed 5th and 6th argument which caused different examples tofail....
linux-user: Avoid redundant ENV_GET_CPU()
This fixes a mismerge in 874ec3c5b3821bb964f9f37b2f930f2a9ce51652.
Acked-by: Riku Voipio <riku.voipio@iki.fi>Signed-off-by: Andreas Färber <afaerber@suse.de>
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging
linux-user: Handle compressed ISA encodings when processing MIPS exceptions
Decode trap instructions during the handling of an EXCP_BREAK or EXCP_TRAPaccording to the current ISA mode.
Signed-off-by: Kwok Cheung Yeung <kcy@codesourcery.com>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Fix target_stat and target_stat64 for OpenRISC
OpenRISC uses the asm-generic versions of target_stat andtarget_stat64, but it was incorrectly using the x86/ARM/etc versiondue to a misplaced defined(TARGET_OPENRISC). The previously unusedOpenRISC section of the ifdef ladder also defined an incorrect...
linux-user: Fix pipe syscall return for SPARC
SPARC is one of the CPUs which has a funny syscall ABI for thepipe syscall; add it to the set of special cases in do_pipe().
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Fix epoll on ARM hosts
The epoll emulation uses data structures without packing them, so thecompiler might choose to add padding inside.
This patch makes the most offending one (target_epoll_event) a packedstructure to make sure we don't pad it by accident. ARM would pad it,...
linux-user: Reset copied CPUs in cpu_copy() always
When a new thread gets created, we need to reset non arch specific state toget the new CPU into clean state.
However this reset should happen before the arch specific CPU contents getcopied over. Otherwise we end up having clean reset state in our newly created...
gdbstub: Change gdb_handlesig() argument to CPUState
Prepares for changing GDBState::c_cpu to CPUState.
linux-user: Use X86CPU property to retrieve CPUID family
Avoids duplicating the calculation.
Reviewed-by: Igor Mammedov <imammedo@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
linux-user: Avoid conditional cpu_reset()
Some CPUs reset as part of cpu_init(), some others were resetafterwards, some not at all. While some targets didn't implement acpu_[state_]reset() function, QOM cpu_reset() is always available.There's nothing wrong with resetting twice on startup, so drop...
configure: Make NPTL non-optional
Now all linux-user targets support building with NPTL, we can make itmandatory. This is a good idea because: * NPTL is no longer new and experimental; it is completely standard * in practice, linux-user without NPTL is nearly useless for...
linux-user: Enable NPTL for x86-64
Add x86-64 implementation of cpu_set_tls() (like the kernel, wejust have to call do_arch_prctl() to set FS); this allows us toenable NPTL.
linux-user: Add i386 TLS setter
We can easily set the TLS on i386. Add code to do so.
Signed-off-by: Alexander Graf <agraf@suse.de>[PMM: also remove "target_nptl=no" line from configure, for consistency with other patches in this series]Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Clean up handling of clone() argument order
Linux manages to have three separate orderings of the arguments tothe clone() syscall on different architectures. In the kernel theseare selected via CONFIG_CLONE_BACKWARDS and CONFIG_CLONE_BACKWARDS2....
linux-user: Add missing 'break' in i386 get_thread_area syscall
The i386 code for the get_thread_area syscall was missing a'break' which meant it would have fallen through into theimplementation of the following syscall; add it.
linux-user: Enable NPTL for m68k
For m68k, per-thread data is a purely kernel construct with noCPU level support. Implement it via a field in the TaskState structure,used by cpu_set_tls() and the set_thread_area/get_thread_areasyscalls. This allows us to enable compilation with NPTL....
linux-user: Enable NPTL for SPARC targets
Provide the missing cpu_set_tls(), and resolve the FIXME incpu_clone_regs() by clearing the carry flag for the child.This allows us to turn on building with NPTL for SPARC.
linux-user: Enable NPTL for OpenRISC
The OpenRISC kernel ignores CLONE_SETTLS in its copy_thread()implementation, so a cpu_set_tls() implementation is a no-op.cpu_clone_regs() was setting the syscall return value in thewrong register -- it is gpr11, not gpr2. With these two...
linux-user: Move includes of target-specific headers to end of qemu.h
The target-specific headers (target_cpu.h and target_signal.h)might need to use the target-independent structure and functiondefinitions of qemu.h; so include them only at the bottom of...
linux-user: declare sys_futex to have 6 arguments
sys_futex has 6 arguments, and all of these need to be copied. Fix incorrectdeclaration in the mips_syscall_args array.
This change fixes the cases where the 5th and 6th arguments have non-zerovalue and have importance. An example is a Linux implementation of...
Merge remote-tracking branch 'afaerber/tags/qom-cpu-for-anthony' into staging
QOM CPUState refactorings
log: Change log_cpu_state[_mask]() argument to CPUState
Since commit 878096eeb278a8ac1ccd6667af73e026f29b4cf5 (cpu: Turncpu_dump_{state,statistics}() into CPUState hooks) CPUArchState is nolonger needed.
Add documentation and make the functions available through qemu/log.h...
linux-user: Change thread_env to CPUState
cpu: Make first_cpu and next_cpu CPUState
Move next_cpu from CPU_COMMON to CPUState.Move first_cpu variable to qom/cpu.h.
gdbstub needs to use CPUState::env_ptr for now.cpu_copy() no longer needs to save and restore cpu_next.
Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
linux-user: Move cpu_clone_regs() and cpu_set_tls() into linux-user
The functions cpu_clone_regs() and cpu_set_tls() are not purely CPUrelated -- they are specific to the TLS ABI for a a particular OS.Move them into the linux-user/ tree where they belong....
linux-user: Clean up do_syscall() Coding Style for TARGET_NR_exit
In particular fix 6-/10-char indentation.
linux-user: handle /proc/$$ like /proc/self
Some applications use /proc/$$/... (where $$ is the own pid) instead of/proc/self/... to refer to their own proc files. Extend the interceptionfor open and readlink to handle this case. Also, do the same interception...
linux-user: add SIOCADDRT/SIOCDELRT support
This allows to pass the device name.
You can test this with the "route" command.
WITHOUT this patch:
$ sudo route add -net default gw 10.0.3.1 eth0SIOCADDRT: Bad address$ netstat -nrKernel IP routing table...
linux-user: fix signal number range check
When translating between host and target signal numbers keep negativenumbers unchanged, avoiding access beyond array bounds.
Signed-off-by: Andreas Schwab <schwab@linux-m68k.org>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Fix sys_utimensat (would not compile on old glibc)
Commit c0d472b12e accidentally dropped the definition of__NR_SYS_utimensat even though its use is guarded byCONFIG_UTIMENSAT, not CONFIG_ATFILE. Some older glibc don'thave utimensat() (even if they have the other *at() functions)....
linux-user: improve target_to_host_sock_type conversion
Previous implementation has failed to take into account different value ofSOCK_NONBLOCK on target and host, and existence of SOCK_CLOEXEC.The same conversion has to be applied both for do_socket and do_socketpair,...
linux-user: Do not ignore mmap failure from host
File mapping may fail with EACCES.
Signed-off-by: Jürg Billeter <j@bitron.ch>Message-id: 1372498892-23676-1-git-send-email-j@bitron.chReviewed-by: Peter Maydell <peter.maydell@linaro.org>
cpu: Change cpu_exit() argument to CPUState
It no longer depends on CPUArchState, so move it to qom/cpu.c.
cpu: Turn cpu_dump_{state,statistics}() into CPUState hooks
Make cpustats monitor command available unconditionally.
Prepares for changing kvm_handle_internal_error() and kvm_cpu_exec()arguments to CPUState.
main: use TARGET_ARCH only for the target-specific #define
Everything else needs to match the executable name, which isTARGET_NAME.
Before: $ sh4eb-linux-user/qemu-sh4eb --help usage: qemu-sh4 [options] program [arguments...] Linux CPU emulator (compiled for sh4 emulation)...
linux-user: Allow getdents to be provided by getdents64
Newer architectures may only implement the getdents64 syscall, notgetdents. Provide an implementation of getdents in terms of getdents64so that we can run getdents-using targets on a getdents64-only host....
linux-user: Drop direct use of openat etc syscalls
The linux-user syscall emulation layer currently supports theopenat family of syscalls via two mechanisms: simply callingthe corresponding libc functions, and making direct syscalls.Since glibc has supported these functions since at least glibc...
linux-user: Fix typo in comment
Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
Merge remote-tracking branch 'mjt/trivial-patches' into staging
linux-user: Fix MIPS ISA transitions during signal handling
Processors supporting the MIPS16 or microMIPS ISAs set bit 0 in targetaddresses to indicate that the target is written using a compressed ISA.
During signal handling, when jumping to or returning from a signal...
linux-user: Save the correct resume address for MIPS signal handling
The current ISA mode needs to be saved in bit 0 of the resume address.If the current instruction happens to be in a branch delay slot, thenthe address of the preceding jump instruction should be stored instead....
fix /proc/self/maps output
Add a space at end of line when there is no filename to print, toconform to linux kernel format (see show_map_vma() infs/proc/task_mmu.c).
Signed-off-by: Christophe Lyon <christophe.lyon@linaro.org>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
target-i386: Replace cpuid_*features fields with a feature word array
This replaces the feature-bit fields on both X86CPU and x86_def_tstructs with an array.
With this, we will be able to simplify code that simply does the sameoperation on all feature words (e.g. kvm_check_features_against_host(),...
linux-user: fix compile error due to stray colon at end of #ifdef line
Remove a stray colon from the end of a #ifdef line. Some versionsof gcc complain about this: linux-user/syscall.c: In function ‘do_syscall’: linux-user/syscall.c:7606:28: error: extra tokens at end of #ifdef directive [-Werror]...
linux-user: change do_semop to return target errno when unsuccessful
do_semop() is called from two places, and one of these fails to convertreturn error to target errno when semop fails. This patch changes thefunction to always return target errno in case of an unsuccessful call....
linux-user: fix undefined shift in copy_to_user_fdset
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: fix setgroups/getgroups for non-UID16 archs
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>
elfload: fix size of ABI-dependent fields in core dumps
Some fields in core dumps are 32-bit in 32-or-64 environments (ppc64abi32,sparc32plus). Use abi_long/ulong for those.
Also, the fields of target_elf_siginfo are ints. Use tswap32 to convert them....
elfload: fix size of registers for N32
Registers are 64-bit in size for the MIPS n32 ABI. Definetarget_elf_greg_t accordingly, and use the correct functionto do endian swaps.
Reviewed-by: Peter Maydell <peter.maydell@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
elfload: use tswapreg consistently in elf_core_copy_regs
Reviewed-by: Peter Maydell <peter.maydell@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
elfload: use abi_short/ushort instead of target_short/ushort
The alignment is a characteristic of the ABI, not the CPU.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
elfload: use abi_int/uint instead of target_int/uint
elfload: use abi_llong/ullong instead of target_llong/ullong
linux-user: pass correct host flags to eventfd2 call
This change makes conversion of TARGET_O_NONBLOCK and TARGET_O_CLOEXEC flagsto 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>...
linux-user: Don't omit comma for strace of rt_sigaction()
Pass the 'last' parameter of print_signal() through toprint_raw_param(); this fixes a problem where we weren't printingthe comma separator for strace of rt_sigaction() when the signalwas an unnamed (ie realtime) one:...
linux-user/syscall.c: Don't warn about unimplemented get_robust_list
The nature of the kernel ABI for the get_robust_list and set_robust_listsyscalls means we cannot implement them in QEMU. Make get_robust_listsilently return ENOSYS rather than using the default "print message and...
linux-user: Implement accept4
Implement the accept4 syscall (which is identical to acceptbut 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 sendfile64
Implement the sendfile and sendfile64 syscalls. This implementationpasses all the LTP test cases for these syscalls.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Richard Henderson <rth@twiddle.net>...
linux-user: make bogus negative iovec lengths fail EINVAL
If the guest passes us a bogus negative length for an iovec, failEINVAL rather than proceeding blindly forward. This fixes some ofthe error cases tests for readv and writev in the LTP.
linux-user: Fix layout of usage table to account for option text
The linux-user usage message attempts to line up the columns inits table by calculating the maximum width of any item in them.However for the 'Argument' column it was only accounting for the...
linux-user: Add more sparc syscall numbers
Signed-off-by: Dillon Amburgey <dillona@dillona.com>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Support setgroups syscall with no groups
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: fix futex strace of FUTEX_CLOCK_REALTIME
Handle same as existing FUTEX_PRIVATE_FLAG.
Signed-off-by: John Rigby <john.rigby@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c: handle FUTEX_WAIT_BITSET in do_futex
Upstream libc has recently changed to start usingFUTEX_WAIT_BITSET instead of FUTEX_WAIT and thisis causing do_futex to return -TARGET_ENOSYS.
Pass bitset in val3 to sys_futex which will beignored by kernel for the FUTEX_WAIT case....
linux-user: improve print_fcntl()
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Add Alpha socket constants
Without these, some networking programs will not work
Signed-off-by: Dillon Amburgey <dillona@dillona.com>Reviewed-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>