Merge remote-tracking branch 'afaerber/qom-cpu' into staging
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
linux-user: Remove redundant null check and replace free by g_free
Report from smatch:
linux-user/syscall.c:3632 do_ioctl_dm(220) info: redundant null check on big_buf calling free()
'big_buf' was allocated by g_malloc0, therefore free was alsoreplaced by g_free....
linux-user: Use memcpy in get_user/put_user.
When host and target have differing alignment rules, using a castand direct memory operation can result in SIGBUS. Use memcpy instead,which the compiler will happily optimize when alignment is satisfied.
Signed-off-by: Richard Henderson <rth@twiddle.net>...
Drop cpu_list_id macro
Since the only user of the extended cpu_list_id() formatwas the x86 ?model/?dump/?cpuid output, we can drop itcompletely.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Reviewed-by: Eduardo Habkost <ehabkost@redhat.com>...
linux-user: Remove #if 0'd cpu_get_real_ticks() definition
Remove the cpu_get_real_ticks() definition from linux-user/main.c.This has been disabled via #if 0 and unused since commit 1dce7c3c22in 2006; the definitions we actually use are in qemu-timer.h....
linux-user: Clarify "Unable to reserve guest address space" error
Now that we default to reserving nearly 4GB of RAM for the guestaddress space when running a 32 bit linux-user guest on 64 bithosts, users are much more likely to run into it. Reword the...
linux-user: fix emulation of getdents
In case when TARGET_ABI_BITS 32 && HOST_LONG_BITS 64, the lastbyte of the target dirent structure (aka d_type byte) was never copiedfrom the host dirent structure, thus breaking everything that relieson valid d_type value, e.g. glob(3)....
linux-user: arg_table need not have global scope
Declare arg_table to be "static const", and adjust the two usersto also be const.
Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure
Also, use g_malloc to avoid NULL-deref upon OOM.
Signed-off-by: Jim Meyering <meyering@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
linux-user: ARM: Ignore immediate value for svc in thumb mode
When running in thumb mode, Linux doesn't evaluate the immediate valueof the svc instruction, but instead just always assumes the syscall numberto be in r7.
This fixes executing go_bootstrap while building go for me....
linux-user: pass sockaddr from host to target
Signed-off-by: Jing Huang <jing.huang.pku@gmail.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
linux-user: make do_setsockopt support SOL_RAW ICMP_FILTER socket option
linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
flatload: fix bss clearing
The current bss clear logic assumes the target mmap address and hostaddress are the same. Use g2h to translate from the target addressspace to the host so we can call memset on it.
Signed-off-by: Mike Frysinger <vapier@gentoo.org>...
linux-user: Factor out guest space probing into a function
Signed-off-by: Meador Inge <meadori@codesourcery.com>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
linux-user: Use init_guest_space when -R and -B are specified
Roll the code used to initialize the guest memory space when -Ror -B is used into 'init_guest_space' and then call 'init_guest_space'from the driver. This way the reserved guest memory space can...
linux-user: Fix SNDCTL_DSP_MAP{IN, OUT}BUF ioctl definitions
Fix the SNDCTL_DSP_MAP{IN,OUT}BUF ioctl definitions so that theyrefer to a suitably defined target struct layout rather than hardcodingthe ioctl number. This fixes complaints from the syscall_init()...
linux-user: Move target_to_host_errno_table[] setup out of ioctl loop
The code to initialise the target_to_host_errno_table[] array wasaccidentally inside the loop through checking and initialising allthe supported ioctls. This was harmless but meant that we reinitialised the...
linux-user: Fix incorrect TARGET_BLKBSZGET, TARGET_BLKBSZSET
The definitions for the ioctl numbers TARGET_BLKBSZGET andTARGET_BLKBSZSET had the wrong size parameters (they are definedwith size_t, not int, even though the ioctl implementations themselves...
unicore32-softmmu: Make UniCore32 cpuid & exceptions correct and runable
This patch initializes the cpuid to exactly correct value becauselinux kernel will check it.In addition, the exception types are specified in proper situations.Then it could make exceptions generated correctly and timely....
sparc: fix expression with uninitialized initial value
err was uninitialized, it's not OK to use |=. Spotted by Clangcompiler.
Fix by implementing the earlier statement which initializes the variable.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
alpha-linux-user: Fix the getpriority syscall
Alpha uses unbiased priority values in the syscall, with the a3return value signaling error conditions. Therefore, properlyinterpret the libc getpriority as needed for the guest ratherthan passing the host value through unchanged....
alpha-linux-user: Handle TARGET_SSI_IEEE_RAISE_EXCEPTION properly
We weren't aggregating the exceptions, nor raising signals properly.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Richard Henderson <rth@twiddle.net>
linux-user: Sync fcntl.h bits with the kernel
For each target, only define the bits that appear inarch/target/include/asm/fcntl.h. Mirror the kernel'sasm-generic layout by handling anything undefined afterward.
Signed-off-by: Richard Henderson <rth@twiddle.net>
linux-user: Handle O_SYNC, O_NOATIME, O_CLOEXEC, O_PATH
linux-user: Allocate the right amount of space for non-fixed file maps
If we let the kernel handle the implementation of mmap_find_vma,via an anon mmap, we must use the size as indicated by the userand not the size truncated to the filesize.
This happens often in ld.so, where we initially mmap the file to...
linux-user: Translate pipe2 flags; add to strace
alpha-linux-user: Fix a3 error return with v0 error bypass.
We were failing to initialize a3 for syscalls that bypass thenegative return value error check.
alpha-linux-user: Properly handle the non-rt sigprocmask syscall.
Name the syscall properly for QEMU, kernel source notwithstanding.Fix syntax errors in the code thus enabled within do_syscall.
alpha-linux-user: Fix signal handling
Proper signal numbers were not defined, and EXCP_INTERRUPTwas unhandled, leading to all sorts of subtle confusion.
Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list thepermitted values', add support for 'help' as a synonym, by abstractingthe check out into a helper function.
This change means that in some cases where we were being lazy in...
Replace 'struct siginfo' with 'siginfo_t'.
glibc 2.16 will remove the undocumented definition of 'struct siginfo'from <bits/siginfo.h>.
This change is already present in glibc 2.15.90, so qemu compilationof certain targets (eg. cris-user) breaks.
This struct was always typedef'd to be the same as 'siginfo_t' which...
target-or32: Add linux syscall, signal and termbits
Add OpenRISC linux syscall, signal and termbits.
Signed-off-by: Jia Liu <proljc@gmail.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
target-or32: Add linux user support
Add QEMU OpenRISC linux user support.
Merge branch 'target-arm.for-upstream' of git://git.linaro.org/people/pmaydell/qemu-arm
qemu-log: cleanup
Don't use global variables directly but via accessor functions. Rename globals.
Convert macros to functions, add GCC format attributes.
target-arm: Remove ARM_CPUID_* macros
All the uses of ARM_CPUID() to vary behaviour have now beenremoved, so we can delete the ARM_CPUID_* macros now.The one exception is the TI915T/925T, because of its odd behaviourwhere the MIDR value can be changed at runtime....
build: move *-user/ objects to nested Makefile.objs
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
linux-user: Use cpu_reset() after cpu_init() / cpu_copy()
Eliminates cpu_state_reset() usage.
Signed-off-by: Andreas Färber <afaerber@suse.de>
linux-user: Fix stale tbs after mmap
If we execute linux-user code that does the following:
we end up executing a stale cached tb that contains translated code...
linux-user: fix emulation of /proc/self/maps
Improve the emulation of /proc/self/maps by reading the underlyinghost maps file and passing lines through with addresses adjustedto be guest addresses. This is necessary to avoid false triggersof the glibc check that a format string containing '%n' is not in...
linux-user: Clean up interim solution for exit syscall
After all target CPUs have been QOM'ified, we no longer need an #ifdefto switch between object_delete() and g_free() in NPTL thread exit.
Signed-off-by: Andreas Färber <afaerber@suse.de>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Fix exit syscall with QOM CPU
For QOM'ified CPUs we cannot g_free() CPUArchState, we mustobject_delete() the object it is embedded into.
Fixes LP#982321 (invalid free() while executing pacman with qemu-arm).
Reported-by: Serge Schneider <serge@xecdesign.com>...
Userspace ARM BE8 support
Add support for ARM BE8 userspace binaries.i.e. big-endian data and little-endian code.In principle LE8 mode is also possible, but AFAIK has never actuallybeen implemented/used.
System emulation doesn't have any useable big-endian board models,...
arm-linux-user: fix elfload.c's AT_HWCAP to reflect cpu features.
The cpu capabilities passed by the elf loader in AT_HWCAP wherea constant.Make AT_HWCAP reflect the emulated cpu features in order to givecorrect clues to eglibc.
Riku Voipio: fixed to apply to current head...
linux-user: implement device mapper ioctls
This patch implements all ioctls currently implemented by device mapper,enabling us to run dmsetup and kpartx inside of linux-user.
Signed-off-by: Alexander Graf <agraf@suse.de>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: add struct old_dev_t compat
The compat LOOP_SET_STATUS ioctl uses struct old_dev_t in its passedstruct. That variable type is vastly different between differentarchitectures. Implement wrapping around it so we can use it.
This fixes running arm kpartx on an x86_64 host for me....
linux-user: fix BLK ioctl arguments
Some BLK ioctls passed sizeof(x) into a macro that already did sizeof() onthe passed in argument, rendering the size information inside the ioctl bethe size of the host default integer type.
Signed-off-by: Alexander Graf <agraf@suse.de>...
linux-user: add BLKSSZGET ioctl wrapper
This patch adds an ioctl definition for BLKSSZGET.
linux-user: Add ioctl for BLKBSZGET
This patch adds the ioctl wrapper definition for BLKBSZGET.
linux-user: fix fallocate
Fallocate gets off_t parameters passed in, so we should also read them outaccordingly.
Signed-off-by: Alexander Graf <agraf@suse.de>
v1 -> v2:
- unbreak 64-bit guests
Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: resolve reserved_va vma downwards
After consulting with Paul Brook, we concluded that it's best to searchthe VMA space downwards, so that we don't even get the chance to conflictwith the brk range.
This patch resolves a bunch of allocation conflicts when using -R....
linux-user: reserve 4GB of vmem for 32-on-64
When running 32-on-64 bit guests, we should always reserve as muchvirtual memory as we possibly can for the guest process, so it cannever overlap with QEMU address space.
Fortunately we already have the infrastructure for that. All that's...
linux-user/syscall.c: Fix indentation in prctl handling
Clean up the odd indentation of this switch statement beforewe double its size by adding new cases to it.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Add support for prctl PR_GET_NAME and PR_SET_NAME
Add support for the prctl options PR_GET_NAME and PR_SET_NAME,which take or return a name in a 16 byte buffer pointed to by arg2.
linux-user/arm/syscall_nr.h: Add syscall number for ppoll
The list of ARM syscall numbers was missing the entry for ppoll,which meant we were accidentally not providing it. (This wasn'tcausing any practical issues beyond warnings about unimplementedsyscalls, because glibc will fall back to another code path if the...
linux-user: improve fake /proc/self/stat making `ps` not segfault.
With the current fake /proc/self/stat implementation `ps` issegfaulting because it expects to read PID and argv0 as first andsecond field respectively, with the latter being enclosed between...
linux-user: target_argv is placed on ts->bprm->argv and can't be freed()
TaskState contains linux_bprm struct which encapsulates argv amongother things.argv might be used around the code and is expected to contain validdata. Before this patch, ts->bprm->argv was NULL due to it being...
Bad zero comparison for sas_ss_flags on powerpc
All architectures work the same way, and all check for sas_ss_flags ==0. The powerpc lines are wrong, and do the check the other way round(it's a qemu internal check, which is done wrong only for thisarchitecture, it's more a typo than a bug). It's NOT ppc specific,...
Rename CPUState -> CPUArchState
Scripted conversion: for file in .[hc] hw/.[hc] hw/kvm/*.[hc] linux-user/*.[hc] linux-user/m68k/*.[hc] bsd-user/*.[hc] darwin-user/*.[hc] tcg/*/*.[hc] target-*/cpu.h; do sed -i "s/CPUState/CPUArchState/g" $file done...
Rename cpu_reset() to cpu_state_reset()
Frees the identifier cpu_reset for QOM CPUs (manual rename).
Don't hide the parameter type behind explicit casts, use staticfunctions with strongly typed argument to indirect.
Signed-off-by: Andreas Färber <afaerber@suse.de>...
linux-user: Don't overuse CPUState
In target-specific code use CPU*State.
While at it, fix indentation on those lines.
qom: Add QOM support to user emulators
Link the Object base class and the module infrastructure for classregistration. Introduce $(universal-obj-y) for objects that are morecommon than $(common-obj-y), so that those only get built once.
Call QOM module init for type registration....
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.
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
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).
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()...