Add new user mode option -ignore-environment
An empty environment is sometimes useful in user mode.The new option provides it for linux-user and bsd-user(darwin-user still has no environment related options).
The patch also adds the documentation for other...
Replace most gcc format attributes by macro GCC_FMT_ATTR (format checking)
Since version 4.4.x, gcc supports additional format attributes. attribute ((format (gnu_printf, 1, 2)))should be used instead of attribute ((format (printf, 1, 2))...
linux-user: fix socklen_t comparisons
On many systems, socklen_t is defined as unsigned. This means thatchecks for negative values are not meaningful.
Fix by explicitly casting to a signed integer.
This also avoids some warnings with GCC flag -Wtype-limits....
linux-user: fix types in a comparison
-1ul is unsigned long, which does not necessarily match abi_ulongtype.
Fix by using abi_long instead.
This also avoids a warning with GCC flag -Wtype-limits.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user: improve flatload error checking
Because of the use of unsigned type, possible errors duringload were ignored.
Fix by using a signed type.
microblaze: User-mode emulation of hw-excp signals
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@petalogix.com>
microblaze: Fix the target version of stat64 struct
MicroBlaze needs TARGET_STAT64_HAS_BROKEN_ST_INO.
linux-user: fix build on hosts not using guest base
Commit 68a1c816868b3e35a1da698af412b29e61b1948a broke qemu on hosts notusing guest base. It uses reserved_va unconditionally in mmap.c. Toavoid to many #ifdef #endif blocks, define RESERVED_VA as either...
linux-user: Protect against allocation failure in load_symbols.
Cc: malc <av1474@comtv.ru>Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: malc <av1474@comtv.ru>
linux-user: Reduce lseek+reads while loading elf files.
Define BPRM_BUF_SIZE to 1k and read that amount initially. If thedata we want from the binary is in this buffer, use it instead ofreading from the file again.
Signed-off-by: Richard Henderson <rth@twiddle.net>...
linux-user: Define ELF_DATA generically.
The only consideration on this value is the target endianness.The existing defines were incorrect for alpha and sh4eb.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
linux-user: Clean up byte-swapping in elfload.c.
Remove ifdefs from code by defining empty inline functionswhen byte swapping isn't needed. Push loops over swappingarrays of structures into the swapping functions.
linux-user: Load symbols from the interpreter.
First, adjust load_symbols to accept a load_bias parameter. At the sametime, read the entire section header table in one go, use pread insteadf lseek+read for the symbol and string tables, and properly free...
linux-user: Improve consistency checking in elf headers.
Validate more fields of the elf header. Extract those checksinto two common functions to be used in both load_elf_interpand load_elf_binary.
linux-user: Put the stack guard page at the top.
There are no supported stack-grows-up targets. We were puttingthe guard page at the highest address, i.e. the bottom of the stack.Use the maximum of host and guest page size for the guard size.
linux-user: Remove partial support for a.out interpreters.
At the bottom of the a.out support was the unimplemented load_aout_interpfunction. There were other portions of the support that didn't lookright; when I went to look in the Linux kernel for clarification, I found...
linux-user: Extract load_elf_image from load_elf_interp.
Moving toward a single copy of the elf binary loading code.Fill in the details of the loaded image into a struct image_info.
Adjust create_elf_tables to read from such structures insteadof from a collection of passed arguments. Don't return error...
linux-user: Re-use load_elf_image for the main binary.
This requires moving the PT_INTERP extraction and GUEST_BASEhandling into load_elf_image. Key this off a non-null pointerargument to receive the interpreter name.
linux-user: Handle filesz < memsz for any PT_LOAD segment.
I caught padzero not properly initializing the .bss segmenton a statically linked Alpha program. Rather than a minimalpatch, replace the gross code with a single mmap+memset.
Share more code between load_elf_interp and load_elf_binary....
Add more DT_* and AT_* constants to qemu's copy of elf.h.
Moving some PPC AT_* constants from elfload.c at the same time.
linux-user: Reindent elfload.c.
microblaze: Pass a ucontext * as 3rd sighandler arg
There is disagreement between microblaze glibc and the kernelto what the third arg of signal handlers should point to.
Change QEMU linux-user to match the kernel port. glibc patchesare pending.
linux-user: display cpu list.
As it is done for qemu-system with "-cpu ?", when cpu_list_id() is missingfor a target, call cpu_list() instead.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
microblaze: Correct signal frame setup.
Pass the context in r7.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
Strace mprotect flags.
Teach strace code about linux specific mprotect flags.
Signed-off-by: Paul Brook <paul@codesourcery.com>
Usermode exec-stack fix
When loading a shared library that requires an executable stack,glibc uses the mprotext PROT_GROWSDOWN flag to achieve this.We don't support PROT_GROWSDOWN.Add a special case to handle changing the stack permissions in this way....
s390x: Avoid _llseek.
There's no _llseek on s390x either. Replace the existingtest for x86_64 with a functional test for __NR_llseek.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
rename CONFIG_QEMU_PREFIX
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: honor low bit of entry PC for MIPS
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Pre-allocate guest address space
Allow pre-allocation of the guest virtual address space in usermode emulation.
alpha-linux-user: Fill in SI_CODE for SIGSEGV.
linux-user: Use qemu-malloc.c.
Since we're no longer setting PAGE_RESERVED, there's no need toimplement qemu_malloc via mmap.
linux-user: Fix compilation with DEBUG defined
Signed-off-by: Riccardo Magliocchetti <riccardo.magliocchetti@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: do not warn for missing pselect6
Libc will fallback gracefully if pselect6 is not available. Thus putpselect6 to nowarn until the atomicity issues of the original pselect6patch are dealt with.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>...
tcg: Initialize the prologue after GUEST_BASE is fixed.
This will allow backends to make intelligent choices about howto implement GUEST_BASE.
alpha-linux-user: Fix getxpid.
Put ppid in the second return register.
alpha-linux-user: Fix sigsuspend parameters.
Alpha passes the signal set in a register, not by reference.
alpha-linux-user: Fix sigprocmask.
Alpha passes oldset by value in a register, and returns the newsetas the return value; as compared to the standard implementation inwhich both are passed by reference. This requires being able todistinguish negative return values that are not errors. Do this in...
alpha-linux-user: Fix brk error return.
alpha-linux-user: Fix siginfo.si_addr for SIGSEGV and SIGBUS.
alpha-linux-user: Add correct sigaction constants.
alpha-linux-user: Fix pipe return mechanism.
At the same time, tidy the code wrt MIPS and SH4 which have thesame two register return mechanism. Fix confusion between pipeand pipe2 with an explicit flags=0, when the guest will not beusing the two register return mechanism....
linux-user: fix 32-bit host breakage
Fix breakage introduced by commit 81bbe906c89b6b7af58a1eeb96ec5a0bfdc3386f.
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
microblaze: Update elf machine nums.
189 was allocated in upstream binutils.
0xbaab was the old temporary value. Still used by some tools and thelinux kernel.
I've seen 115 in older gdb versions, but lets ignore that one.
microblaze: Add linux-user core dumping support.
linux-user: rlimit conversion between host and target.
rlim_t conversion between host and target added.Otherwise there are some incorrect case like- RLIM_INFINITY on 32bit target > 64bit host. RLIM_INFINITY on 64bit host > mips and sparc target ? Big value(for 32bit target) on 64bit host -> 32bit target....
sparc: Fix lazy flag calculation on interrupts, refactor
Recalculate Sparc64 CPU flags on interrupts, otherwise some earlierflags could be stored to pstate.
Refactor PSR/CCR/CWP handling: concentrate the actualfunctions to op_helper.c.
Thanks to Igor Kovalenko for reporting....
Remove PAGE_RESERVED
The usermode PAGE_RESERVED code is not required by the current mmapimplementation, and is already broken when guest_base != 0.Unfortunately the bsd emulation still uses the old mmap implementation,so we can't rip it out altogether....
Better default guest_base
Avoid loading linux-user applications in address space already used/reservedby the host.
target-alpha: Implement rs/rc properly.
This is a per-cpu flag; there's no need for a spinlock of any kind.
We were also failing to manipulate the flag with $31 as a target regand failing to clear the flag on execution of a return-from-interruptinstruction....
target-alpha: Enable NPTL.
target-alpha: Fix load-locked/store-conditional.
Use an exception plus start_exclusive to implement the compare-and-swap.This follows the example set by the MIPS and PPC ports.
linux-user: Fix sparc32plus stat64 syscalls.
Check TARGET_ABI_BITS, not TARGET_LONG_BITS, when decidingwhether or not the guest needs special 64-bit stat translation.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user: Fix Sparc64 syscall returns.
linux-user: Remove ELFLOAD32.
The ABI-specific types used by linux_binprm and image_infoare different after forcing TARGET_ABI32 on. Which meansthat the parameters that load_elf_binary_multi sees are notthose that loader_exec passed. This is inherently broken...
linux-user: do_shmdt(): Fix page_set_flags's 2nd arg.
2nd arg of page_set_flags() should be start+size, but size.
Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>Acked-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: switch default ppc64 CPU to 970fx from 970
Fix compilation with missing inotify_init1
Commit c05c7a7306a23a4b01d1606172b142c45caffc92breaks cross compilation for mips (and othercompilations without CONFIG_INOTIFY1):
make1: Entering directory `/qemu/bin/mips' CC i386-linux-user/syscall.o...
linux-user/ia64: workaround ia64 strangenesses
ia64 has some strangenesses that need to be workaround:- it has a __clone2() syscall instead of the using clone() one, with different arguments, and which is not declared in the usual headers.- ucontext.uc_sigmask is declared with type long int, while it is...
Compile qemu-timer only once
Arrange various declarations so that also non-CPU code can accessthem, adjust users.
Move CPU specific code to cpus.c.
linux-user/ppc: use the Linux register layout
The dynamic linker converts the Linux layout to the AIX layout and isreentrant so it won't do it a second time if it's already beenconverted. In short it work just fine with either register layout.
OTOH, statically linked binaries expect a Linux layout....
linux-user: Use RLIMIT_STACK for default stack size.
The current default stack limit of 512kB is far too small; a fairnumber of gcc testsuite failures (for all guests) are directlyattributable to this. Using the -s option in every invocation ofthe emulator is annoying to say the least....
linux-user: Add the syscall id for pselect6 on ARM
As this is now supported in newer linux kernels.
Signed-off-by: Michael Casadevall <mcasadevall@ubuntu.com>Signed-off-by: Riku Voipio <riku.voipio@nokia.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: add inotify_init1 syscall support
New syscall which gets actively used when you have afresh kernel.
Signed-off-by: Riku Voipio <riku.voipio@nokia.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Replace assert(0) with abort() or cpu_abort()
When building with -DNDEBUG, assert(0) will not stop executionso it must not be used for abnormal termination.
Use cpu_abort() when in CPU context, abort() otherwise.
Fix build with -DNDEBUG in CFLAGS
Fix usermode virtual address type
Usermode virtual addresses are abi_ulong, not target_ulong.
linux-user: Fix mmap_find_vma returning invalid addresses.
Don't return addresses that aren't properly aligned for the guest,e.g. when the guest has a larger page size than the host. Don'treturn addresses that are outside the virtual address space for the...
linux-user: Use h2g_valid in qemu_vmalloc.
Signed-off-by: Richard Henderson <rth@twiddle.net>
Update to a hopefully more future proof FSF address
See also 8167ee883931cb20c6264fc19d040ce2dc6ceaaa,530e7615ce3c01882e582c84dc6304ab98a3d5c5 andfad6cb1a565bb73f83fc0e2654489457b489e436.
linux-user: Save/restore fpu registers to signal context on sh4
As "todo" comment in source code.And modify restore_sigcontext() to have three args as kernel's does.
Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
linux-user: Fix syscall pipe2() retval on sh4
On linux/sh4 pipe() return values by r0:r1 as SH C calling convention. pipe2() return values on memory as traditional unix way.
Disassembler symbol lookup fix
Fix function signature for userspace disassembler symbol lookup.
alpha-linux-user: Implement signals.
Move userland PALcode handling into linux-user main loop so thatwe can send signals from there. This also makes alpha_palcode.csystem-level only, so don't build it for userland. Add definesfor GENTRAP PALcall mapping to signals....
target-alpha: Reduce internal processor registers for user-mode.
The existing set of IPRs is totally irrelevant to user-mode emulation.Indeed, they most are irrelevant to implementing kernel-mode emulation,and would only be relevant to PAL-mode emulation, which I suspect that...
Add cpu model configuration support..
This is a reimplementation of prior versions which addsthe ability to define cpu models for contemporary processors.The added models are likewise selected via -cpu <name>,and are intended to displace the existing convention...
Fix strace or FUTEX_PRIVATE_FLAG
FUTEX_PRIVATE_FLAG is a bit orred with an existing futex op,not a distinct value.
linux-user: adapt uname machine to emulated CPU
This patch for linux-user adapts the output of the emulated uname()syscall to match the configured CPU. Tested with x86, x86-64 and armemulation.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>Signed-off-by: Loïc Minier <lool@dooz.org>
linux-user/mmap.c: fix warnings with _FORTIFY_SOURCE
CC i386-linux-user/mmap.occ1: warnings being treated as errors/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c: In function 'mmap_frag':/usr/src/RPM/BUILD/qemu-0.11.92/linux-user/mmap.c:253: error: ignoring return value of 'pread', declared with attribute warn_unused_result...
mmap_frag() users only check for -1 error
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
fix linux-user microblaze ELF_ARCH definition
Signed-off-by: Mike Frysinger <vapier@gentoo.org>Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
alpha: fix stat64 issue
The stat64/fstat64 syscalls are broken for alpha linux-user.
This is because Alpha, even though it is native 64-bits, has a stat64syscall that is different than regular stat. This means that the"TARGET_LONG_BITS==64" check in syscall.c isn't enough. Below is...
linux-user: fix build with gcc-4.1
PPC: Make DCR uint32_t
For what I know DCR is always 32 bits wide, so we should also use uint32_t topass it along the stacks.
This fixes a warning when compiling qemu-system-ppc64 with KVM enabled, makingit compile without --disable-werror
Signed-off-by: Alexander Graf <agraf@suse.de>...
PPC64: Fix alternate timebase
Fix the alternate time base the same way as the default timebase. SPR_ATBLshould return a 64-bit value on 64 bit implementations.
PPC64: Fix timebase
On PPC we have a 64-bit time base. Usually (PPC32) this is accessed usingtwo separate 32 bit SPR accesses to SPR_TBU and SPR_TBL.
On PPC64 the SPR_TBL register acts as 64 bit though, so we get the full64 bits as return value. If we only take the lower ones, fine. But Linux...
linux-user: Add aliases for some Alpha syscalls
Alpha always used 32-bit uids, but never renamed the syscallsto match i386 when 32-bit uids were added there. This enablesthe proper bits in syscall.c.
linux-user: use TARGET_ABI_FMT_lx to print abi_ulong types
linux-user: fix ELF_USE_CORE_DUMP/USE_ELF_CORE_DUMP confusion
linux-user: commonify definitions of target typedefs
There's no sense in separately declaring target_{elf_greg,uid,gid,pid}_tfor every architecture. Just declare them once with appropriateUSE_UID16 handling.
Signed-off-by: Nathan Froyd <froydnj@codesourcery.com>...
linux-user: fix ARM core dumps on opposite-endian hosts
linux-user: add core dump support for PPC
linux-user: add core dump support for MIPS
linux-user: add core dump support for M68K
linux-user: add core dump support for SH
linux-user: Fix mmap_lock ordering
mmap_lock() can be called while tb_lock() is being held. Toavoid deadlock when one thread is holding mmap_lock and anothertb_lock, always lock first tb_lock().
linux-user: cleanup force_sig() calls
Force_sig should be always called with TARGET_ signals.Not that it really matters with SEGV, so this patch isjust for cleanup and improving consistency.
target-alpha: Drop bogus UNIQ initial value on Linux.
target-alpha: Fixes for alpha-linux syscalls.
1. Add correct definitions of error numbers.2. Implement SYS_osf_sigprocmask3. Implement SYS_osf_get/setsysinfo for IEEE_FP_CONTROL.
This last requires exposing the FPCR value to do_syscall.Since this value is actually split up into the float_status,...
Fix ARM userspace strex implementation.