linux-user: fix mips 32-on-64 prealloc case
MIPS only supports 31 bits of virtual address space for user space, so let'smake sure we stay within that limit with our preallocated memory block.
This fixes the MIPS user space targets when executed without command line...
linux-user/syscall.c: remove forward declarations
instead use the correct headers that define these functions.
Requested-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: John Spencer <maillist-qemu@barfooze.de>Reviewed-by: Amos Kong <kongjianjun@gmail.com>...
Merge remote-tracking branch 'bonzini/header-dirs' into staging
fpu: move public header file to include/fpu
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
janitor: add guards to headers
exec: move include files to include/exec/
build: kill libdis, move disassemblers to disas/
linux-user/syscall.c: remove wrong forward decl of setgroups()
this declaration is wrong:the correct prototype on linux is:int setgroups(size_t size, const gid_t *list);
since by default musl libc exposes this symbol in unistd.hadditionally to grp.h, the wrong declaration causes a build error....
Merge remote-tracking branch 'afaerber/qom-cpu' into staging
linux-user: Merge pread/pwrite into pread64/pwrite64
The Linux syscalls underlying pread() and pwrite() take a 64 bitoffset on all architectures, even if some of them name the syscall"pread/pwrite" rather than "pread64/pwrite64" for historical reasons....
user: Move *-user/qemu-types.h to main directory
The bsd-user/qemu-types.h and linux-user/qemu-types.h files are almostthe same, but linux-user has the additional definitions of tswapal().
This moves the linux-user file to the main directory, so the same file...
user: Rename qemu-types.h to qemu-user-types.h
The header file is specific for *-user, but I plan to introduce a moregeneric qemu-types.h file, so I'm renaming it.
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>Signed-off-by: Andreas Färber <afaerber@suse.de>
target-mips: Add ASE DSP resources access check
Add MIPS ASE DSP resources access check.
Signed-off-by: Jia Liu <proljc@gmail.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Merge branch 'linux-user-for-upstream' of git://git.linaro.org/people/rikuvoipio/qemu
microblaze: Support setting of TLS ptr
Signed-off-by: Edgar E. Iglesias <edgar.iglesias@gmail.com>
microblaze: Update PC before simulating syscall
Fixes a clone() emulation bug were the new thread startsat the point of the syscall and thus clones in a loop.
target-sparc: Don't compute full flags value so often
Avoid speculatively computing flags before every potentially trappingoperation and instead do the flags computation when a trap actuallyoccurs. This gives approximately 30% speedup in emulation.
Signed-off-by: Richard Henderson <rth@twiddle.net>...
linux-user: register align p{read, write}64
pread64 and pwrite64 pass 64bit parameters which for some architectures needto be aligned to special argument pairs, creating a gap argument.
Handle this special case the same way we handle it in other places of the code....
linux-user: ppc: mark as long long aligned
The SysV PPC32 ABI dictates that long long (64bit) parameters are pass in odd/evenregister pairs. Because unlike ARM and MIPS we start at an odd register number,we can reuse the same aligning code that ARM and MIPS use....
linux-user: If loading fails, print error as string, not number
If the attempt to load the guest executable fails, print theerror message as a string, not a number. This requires us tofix a couple of places in loader_exec() where we were returning-1 instead of a valid negative errno....
linux-user: Fix siginfo handling
Compare signal numbers in the proper domain.Convert all of the fields for SIGIO and SIGCHLD.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
alpha-linux-user: Fix sigaltstack structure definition
linux-user: Implement gethostname
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
linux-user: Perform more checks on iovec lists
Validate count between 0 and IOV_MAX. Limit total length ofoperation in the same way the kernel does.
linux-user: fix statfs
The statfs syscall should always memset(0) its full struct extent beforewriting to it. Newer versions of the syscall use one of the reserved fieldsfor flags, which would otherwise get stale values from uncleaned memory.
This fixes libarchive for me, which got confused about the return value of...
linux-user: fix multi-threaded /proc/self/maps
When reading our faked /proc/self/maps from a secondary thread,we get an invalid stack entry. This is because ts->stack_base is notinitialized in non-primary threads.
However, ts->info is, and the stack layout information we're looking...
Merge branch 'trivial-patches' of git://github.com/stefanha/qemu
cleanup useless return sentence
This patch cleans up return sentences in the end of void functions.
Reported-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Amos Kong <akong@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@gmail.com>
linux-user: remove two unchecked uses of strdup
Remove two uses of strdup (use g_path_get_basename instead),and add a comment that this strncpy use is ok.
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Jim Meyering <meyering@redhat.com>...
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.
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
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: 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>