Spelling fixes in comments (it's -> its)
Reviewed-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Stefan Weil <sw@weilnetz.de>...
linux-user: brk() debugging
Fix format type mismatches in do_brk debug printfs.
Signed-off-by: Paul Brook <paul@codesourcery.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
linux-user: fail execve() if env/args too big
If the host's page size is equal to or smaller than the target's, nativeexecve() will fail appropriately with E2BIG if called with too big anenvironment for the target to handle. It may falsely succeed, however, if...
linux-user: Define TARGET_QEMU_ESIGRETURN for mips64
Copied from mips/syscall.h.
Signed-off-by: Khansa Butt <khansa@kics.edu.pk>Signed-off-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Fix sa_flags byte swaps for mips
sa_flags is uint32_t for mips{,n32,64}, so don't use tswapal().
edited by Riku Voipio: likewise on alpha
Reported-by: Khansa Butt <khansa@kics.edu.pk>Suggested-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Andreas Färber <afaerber@suse.de>...
linux-user: fake /proc/self/maps
glibc's pthread_attr_getstack tries to find the stack range from/proc/self/maps. Unfortunately, /proc is usually the host's /procwhich means linux-user guests see qemu's stack there.
Fake the file with a constructed maps entry that exposes the guest's...
linux-user: fake /proc/self/stat
The boehm gc finds the program's stack starting pointer bychecking /proc/self/stat. Unfortunately, so far it readsqemu's stack pointer which clearly is wrong.
So let's instead fake the file so the guest program sees the...
linux-user: fake /proc/self/auxv
Gtk tries to read /proc/self/auxv to find its auxv table instead oftaking it from its own program memory space.
However, when running with linux-user, we see the host's auxv whichclearly exposes wrong information. so let's instead expose the guest...
linux-user/main.c: Add option to user-mode emulation so that user can specify log file name
QEMU linux user-mode's default log file name is "/tmp/qemu.log". In order tochange the log file name, user need to modify the source code then recompileQEMU. This patch allow user use "-D logfile" option to specify the log file...
linux-user: add SO_PEERCRED support for getsockopt
Signed-off-by: Akos PASZTORY <akos.pasztory@gmail.com>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: fix QEMU_STRACE=1 segfault
While debugging some issues with QEMU_STRACE I stumbled over segmentationfaults that were pretty reproducible. Turns out we tried to treat anormal return value as errno, resulting in an access over array boundaries...
linux-user/strace.c: Correct errno printing for mmap etc
Correct the printing of errnos for syscalls which are handledvia print_syscall_ret_addr (mmap, mmap2, brk, shmat): errnosare returned as negative returned values at this level, notvia the host 'errno' variable....
linux-user: fix wait* syscall status returns
When calling wait4 or waitpid with a status pointer and WNOHANG, thesyscall can potentially not modify the status pointer input. Now if wehave guest code like:
int status = 0; waitpid(pid, &status, WNOHANG);...
linux-user: Allow NULL value pointer in setxattr and getxattr
It's valid to pass a NULL value pointer to setxattr, so don'tfail this case EFAULT.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user/syscall.c: Implement f and l versions of set/get/removexattr
Implement the f and l versions (operate on fd, don't follow links)of the setxattr, getxattr and removexattr syscalls.
linux-user: Implement *listxattr syscalls
Implement listxattr, flistxattr and llistxattr syscalls.
linux-user: Define TARGET_QEMU_ESIGRETURN for mipsn32
Signed-off-by: Ulrich Hecht <uli@suse.de>Signed-off-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: save auxv length
We create our own AUXV segment on stack and save a pointer to it.However we don't save the length of it, so any code that wants todo anything useful with it later on has to walk it again.
Instead, let's remember the length of our AUXV segment. This...
linux-user: add open() hijack infrastructure
There are a number of files in /proc that expose host informationto the guest program. This patch adds infrastructure to overridethe open() syscall for guest programs to enable us to on the flygenerate guest sensible files....
linux-user: stack_base is now mandatory on all targets
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
elf: Improve symbol lookup (optimize, fix for bsd-user)
Coverity complained about local variable key which was only partiallyinitiated. Only key.st_value was set. As this was also the only partof key which was used in function symfind, the code could be optimized...
Fix spelling in comments, documentation and messages
accidently->accidentallyannother->anotherchoosen->chosenconsideres->considersdecriptor->descriptordevelopement->developmentparamter->parameterpreceed->precedepreceeding->precedingpriviledge->privilege...
linux-user/syscall.c: Don't skip stracing for fcntl64 failure case
In an fcntl64 failure path, we were returning directly rather thansimply breaking out of the switch statement. This skips the stracecode for printing the syscall return value, so don't do that....
linux-user/arm/nwfpe/fpopcode.h: Fix non-UTF-8 characters
Fix some stray non-UTF-8 characters used in some ASCII art tablesby converting them to plain ASCII '|' instead.
Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user/cpu-uname.c: Convert to UTF-8
Convert comment from ISO-8859-1 encoding to UTF-8 to match the restof QEMU's source code.
Reviewed-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
fix typo: delete redundant semicolon
Double semicolons should be single.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
fix spelling in linux-user sub directory
Cc: Riku Voipio <riku.voipio@iki.fi>Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
linux-user/elfload.c: Don't memset(NULL..) if malloc() failed
If a malloc() in copy_elf_strings() failed we would call memset()before the "did malloc fail?" check. Fix this by moving to theglib alloc/free routines for this memory so we can use g_try_malloc0...
configure: fix detection for xattr.h on modern distributions
Modern distributions place xattr.h in /usr/include/sys, and foldlibattr.so into libc. They also don't have an ENOATTR.
Make configure detect this, and add a qemu-xattr.h file thatdirects the #include to the right place....
Merge remote-tracking branch 'riku/linux-user-for-upstream' into staging
ppc64-linux-user: Properly interpret the entry function descriptor.
Don't confuse the load address with the load bias. They're equalfor ET_DYN objects (i.e. ld.so) but different for ET_EXEC objects(i.e. statically linked).
Signed-off-by: Richard Henderson <rth@twiddle.net>...
ppc64-linux-user: Fix syscall return type.
Use target_ulong instead of hard-coded uint32_t.Remove the disabled printf's that are redundant with -strace.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
sparc-linux-user: Handle SIGILL.
sparc-linux-user: Fixup sending SIGSEGV
sparc-linux-user: Add some missing syscall numbers
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: implement reboot syscall
For OBS, we're running a full cross-guest inside of a VM. When a buildis done there, we reboot the guest as shutdown mechanism.
Unfortunately, reboot is not implemented in linux-user. So this mechanismfails, spilling unpretty warnings. This patch implements sys_reboot()...
linux-user: fix TARGET_RLIM_INFINITY declaration
Signed-off-by: Matthias Braun <matze@braunis.de>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: fix rlimit syscalls on sparc(64)
Signed-off-by: Matthias Braun <matze@braunis.de>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: fix abi_(u)long, target_ulong mismatch
abi_(u)long might be different from target_ulong, so don't use tswaplbut introduce a new tswapal
linux-user: fix openat
When running openat using qemu-arm, we stumbled over invalid permissionson the created files. The reason for this is that the mode parameter getstreates as an O_... flag, which it isn't - it's a permission bitmask.
This patch removes the needless translation of the mode parameter,...
target-sparc: Change fpr representation to doubles.
This allows a more efficient representation for 64-bit hosts.It should be about the same for 32-bit hosts, as we can stillaccess the individual pieces of the double.
Signed-off-by: Richard Henderson <rth@twiddle.net>
linux-user: Fix broken "-version" option
Fix the "-version" option, which was accidentally broken in commitfc9c541: * exit after printing version information rather than proceeding blithely onward (and likely printing the full usage message) * correct the cut-n-paste error in the usage message for it...
linux-user: Remove unused code
The code is unused since 8 years, so remove it.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
Fix include statements for qemu-common.h
introduce environment variables for all qemu-user options
(Edits by Riku Voipio to apply to current HEAD)
Rework option parsing code for linux-user in a table-driven manner to allowenvironment variables for all commandline options.
Also generate usage() output from option table....
linux-user: Implement setxattr/getxattr/removexattr syscalls
This patch implements the setxattr, getxattr, and removexattr syscallsif CONFIG_ATTR is enabled.
Note that since libattr uses indirect syscalls for these, this changedepends on the fix for indirect syscall handling on MIPS....
linux-user: Verify MIPS syscall arguments
On MIPS, some syscall arguments are taken from the stack. This patch addsverification such that do_syscall() is only invoked if all argumentshave been successfully taken from the stack.
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>...
linux-user: Fix MIPS indirect syscall handling
Change the number of argument for MIPS sys_syscall from 0 to 8. Thisallows arguments for indirect syscalls to be processed correctly.
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Exit with an error if we couldn't set up gdbserver
If gdbserver_start() fails (usually because we couldn't bind to therequested TCP port) then exit qemu rather than blithely continuing.This brings the linux-user behaviour in to line with system mode....
linux-user: Implement new ARM 64 bit cmpxchg kernel helper
Linux 3.1 will have a new kernel-page helper for ARM implementing64 bit cmpxchg. Implement this helper in QEMU linux-user mode: * Provide kernel helper emulation for 64bit cmpxchg...
linux-user: Fix initialization of the heap contents when allocating new pages
Technically the new mmapped pages are already initialized to zerosince they are anonymous, however we have to take care with thecontents that come from the remaining part of the previous page: it...
Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:
git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...
linux-user: Correct a few missuses of host addresses
Fix a few cases where we were passing host pointers to theguest.
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
microblaze-user: Deliver SIGFPE on div by zero
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Avoid allocating TCG resources in non-TCG mode
Do not allocate TCG-only resources like the translation buffer whenrunning over KVM or XEN. Saves a "few" bytes in the qemu address spaceand is also conceptually cleaner.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
user: Restore debug usage message for '-d ?' in user mode emulation
The code which prints the debug usage message on '-d ?' for *-userhas to come before the check for "not enough arguments", so that"qemu-foo -d ?" prints the list of possible debug log items rather than...
Wrap recv to avoid warnings
Avoid warnings like these by wrapping recv(): CC slirp/ip_icmp.o/src/qemu/slirp/ip_icmp.c: In function 'icmp_receive':/src/qemu/slirp/ip_icmp.c:418:5: error: passing argument 2 of 'recv' from incompatible pointer type [-Werror]...
set ELF_HWCAP for SPARC and SPARC64
setting ELF_HWCAP fixes dynamic library loading for Linux/sparc64This patch allows loading busybox from Debian 6 initrd
Signed-off-by: Artyom Tarasenko <atar4qemu@gmail.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user/signal.c: Rename s390 target_ucontext fields to fix ia64
The ia64 sys/ucontext.h defines macros 'uc_link', 'uc_sigmask' and'uc_stack'. Rename the s390 target_ucontext struct members to tuc_*,bringing them into line with the other targets and fixing a compile...
linux-user: make MIPS and ARM eabi use same argument reordering
MIPS uses similar calling convention than ARM eabi, where when using64-bit values some registers are skipped. This patch makes MIPS and ARMeabi share the argument reordering code.
This affects ftruncate64, creating insane sized fails (or just failing)....
linux-user: correct syscall 123 on sh4
As reported by Cédric VINCENT:
The syscall #123 on SH4 should be "TARGET_NR_cacheflush" instead of"TARGET_NR_modify_ldt" [1]. The only consequence of this misnaming isthat many "Unsupported syscall" warnings are issued when emulating JIT...
mips: rlimit codes are not the same
The codes for get/setrlimit differ between linux target platforms.This patch adds conversion.This is important else programs (rsyslog, python, ...) can go into anear infinite loop trying to close all the file descriptors from 0 to...
mips: rlimit incorrectly converts values
Byte swap was applied in the wrong order with testing forRLIM_INFINITY. On mips bigendian from an amd64 system this results ininfinity being misinterpretted as 2^31-1.
This is a serious bug because it causes setrlimit stack size to kill...
mips: null pointer deref should segfault
Dereferencing a null pointer causes an exception 0xC (EXCP_AdEL)instead of EXCP_TLBL. This should also trigger a segfault.
Signed-off-by: Wesley W. Terpstra <terpstra@debian.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
mips: missing syscall returns wrong errno
Return -TARGET_ENOSYS instead of -ENOSYS from linux-user/main.c * Caused strange 'Level 2 synchronization messages' instead ofcorrectly reporting the syscall was missing. * Made glibc simply fail instead of using older syscalls...
mips: sigaltstack args
The syscall sigaltstack takes two parameters, not zero. This patchshould have no impact as only values above 4 influence the runtimebehaviour. Nevertheless, it is wrong.
linux-user/syscall.c: Enforce pselect6 sigset size restrictions
Enforce the same restriction on the size of the sigset passed topselect6 as the Linux kernel does. This is both correct and silencesa gcc 4.6 warning about a write-only variable.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
linux-user: Implement prlimit64 syscall
Implement the prlimit64 syscall.
Slightly modified to apply upstream -Riku
linux-user: Add syscall numbers from kernel 2.6.39.2
Add syscall numbers for new syscall numbers; this brings usinto line with Linux 2.6.39.2.
linux-user: Add support for even more FB ioctls
This patch was validated with programs from DirectFB-1.0 andWebKit/DirectFB.
Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>Cc: Riku Voipio <riku.voipio@iki.fi>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Add support for more VT ioctls
DirectFB-1.0 uses at least two of the four added ioctls, and the twoothers were added for completeness. This patch was validated with theprogram "vlock -all/-new".
Signed-off-by: Cédric VINCENT <cedric.vincent@st.com>...
linux-user: Add support for KD...LED ioctls
DirectFB-1.0 uses at least one of the four added ioctls, and the threeothers were added for completeness. This patch was validated with theprogram "setleds" and the following Makefile:
SETLEDS_INIT = setleds -v -num -caps -scroll...
user: Fix -d debug logging for usermode emulation
Remove exec-all.h include directives
Most exec-all.h include directives are now useless, remove them.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user: syscall should use sanitized arg1
Looking at the other architectures, we should be using "how" not "arg1".
Signed-off-by: Juan Quintela <quintela@redhat.com>[peter.maydell@linaro.org: remove unnecessary initialisation of how]Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
flatload: end_code was only used in a debug message
Just unfold its definition in only use.
Signed-off-by: Juan Quintela <quintela@redhat.com>[peter.maydell@linaro.org: fixed typo in the debug code,added parentheses to fix precedence issue]Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
flatload: memp was a write-only variable
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Bump do_syscall() up to 8 syscall arguments
On 32 bit MIPS a few syscalls have 7 arguments, and so to callthem via NR_syscall the guest needs to be able to pass 8 argumentsto do_syscall(). Raise the number of arguments do_syscall() takesaccordingly....
linux-user/signal.c: Remove only-ever-set variable fpu_save_addr
Move the access of fpu_save into the commented out skeleton code forrestoring FPU registers on SPARC sigreturn, thus silencing a gcc4.6 "variable set but never used" warning.(This doesn't affect the calculation of 'err' because in fact...
linux-user/signal.c: Remove unused fenab
Remove fenab as it is only written, never used. Add a FIXMEcomment about the discrepancy between our behaviour and thatof the Linux kernel for this routine.
linux-user: Fix sync_file_range on 32bit mips
As noticed while looking at "Bump do_syscall() up to 8 syscall arguments" patch, sync_file_range uses a pad argument on 32bit mips. Deal with itby reading the correct arguments when on mips.
Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Fix the computation of the requested heap size
There were several remaining bugs in the previous implementation ofdo_brk():
1. the value of "new_alloc_size" was one page too large when the requested brk was aligned on a host page boundary....
linux-user: add pselect6 syscall support
Some architectures (like Blackfin) only implement pselect6 (and skipselect/newselect). So add support for it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>Signed-off-by: Riku Voipio <riku.voipio@iki.fi>
linux-user: Define AT_RANDOM to support target stack protection mechanism.
The dynamic linker from the GNU C library v2.10+ uses the ELFauxiliary vector AT_RANDOM [1] as a pointer to 16 bytes with randomvalues to initialize the stack protection mechanism. Technically the...
linuxload: id_change was a write only variable
syscall: really return ret code
We assign ret with the error code, but then return 0 unconditionally.
linux-user: Handle images where lowest vaddr is not page aligned
Fix a bug in the linux-user ELF loader code where it was not correctlyhandling images where the lowest vaddr to be loaded was not page aligned.The problem was that the code to probe for a suitable guest base address...
linux-user: Don't use MAP_FIXED in do_brk()
Since mmap() with MAP_FIXED will map over the top of existing mappings,it's a bad idea to use it to implement brk(), because brk() with alarge size is likely to overwrite important things like qemu itselfor the host libc. So we drop MAP_FIXED and handle "mapped but at...
linux-user: Fix the load of ELF files that have no "useful" symbol
This patch fixes a "double free()" due to "realloc(syms, 0)" in theloader when the ELF file has no "useful" symbol, as with the followingexample (compiled with "sh4-linux-gcc -nostdlib"):...
Don't translate pointer when in restore_sigcontext
Fixes crash in i386 when user emulation base address is non-zero.
21797 rt_sigreturn(8,1082124603,1,0,1082126048,1082126248)Exit reason and status: signal 11
Signed-off-by: Mike McCormack <mj.mccormack@samsung.com>...
Command line support for altering the log file location
Add command line support for logging to a location other than /tmp/qemu.log.
With logging enabled (command line option -d), the log is written tothe hard-coded path /tmp/qemu.log. This patch adds support for writing...
Merge remote branch 'rth/axp-next' into alpha-merge
Fix compilation warning due to missing header for sigaction (followup)
This patch removes all references to signal.h when qemu-common.h is includedas they become redundant.
Signed-off-by: Alexandre Raymond <cerbere@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
target-alpha: Rationalize internal processor registers.
Delete all the code that tried to emulate the real IPRs of someunnamed CPU. Replace those with just 3 slots that we can use tocommunicate trap information between the helper functions thatsignal exceptions and the OS trap handler....
target-alpha: Tidy exception constants.
There's no need to attempt to match EXCP_* values with PALcode entrypoint offsets. Instead, compress all the values to make for moreefficient switch statements within QEMU.
We will be doing TLB fill within QEMU proper, not within the PALcode,...