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.
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>...
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>
mipsn32-linux-user: Configure the architecture properly
N32 is a 64-bit cpu with a 32-bit address space. We haveexisting cpp defines for this situation, but weren't using them.
This does mean that the linux-user/mipsn32 directory must bemerged with the linux-user/mips64 directory, and differences...
mips-linux-user: Save and restore fpu and dsp from sigcontext
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
mips-linux-user: Fix n32 and n64 syscalls
mips-linux-user: Share o32 code for n32 and n64 signals
Signed-off-by: Richard Henderson <rth@twiddle.net>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
mips-linux-user: Delete n32 and n64 signal stubs
Deleting these first makes the next patch much easier to read.This doesn't cause any sort of compilation failure because wehave not yet enabled n32/n64 compilation. This is dead code.
Signed-off-by: Richard Henderson <rth@twiddle.net>...
target-mips: Translate breaks and traps into the appropriate signal
GCC and GAS are capable of generating traps or breaks to check fordivision by zero. Additionally, GAS is capable of generating trapsor breaks to check for overflow on certain division and multiplication...
qemu-log: default to stderr for logging output
Switch the default for qemu_log logging output from "/tmp/qemu.log" to stderr. This is an incompatible change in some sense, but loggingis mostly used for debugging purposes so it shouldn't affect production...
cpu: Move running field to CPUState
Pass CPUState to cpu_exec_{start,end}() functions.
Signed-off-by: Andreas Färber <afaerber@suse.de>
cpu: Move host_tid field to CPUState
Change gdbstub's cpu_index() argument to CPUState now that CPUArchStateis no longer used.
qemu-log: Rename the public-facing cpu_set_log function to qemu_set_log
Rename the public-facing function cpu_set_log to qemu_set_log. Thisrequires us to rename the internal-only qemu_set_log() todo_qemu_set_log().
qemu-log: Rename cpu_str_to_log_mask to qemu_str_to_log_mask
Rename cpu_str_to_log_mask() to qemu_str_to_log_mask(), sincethe qemu_log functionality is no longer restricted to TCG CPUdebug logging.
qemu-log: Abstract out "print usage message about valid log categories"
Abstract out the "print a human readable list of all thevalid log categories" functionality which is currently duplicatedin three separate places. (We leave the monitor.c help_cmd()...
qemu-log: Unify {cpu_set,set_cpu}_log_filename as qemu_set_log_filename
The qemu_log() functionality is no longer specific to TCG CPU debug logs.Rename cpu_set_log_filename() to qemu_set_log_filename() and drop thepointless wrapper set_cpu_log_filename()....
TCG: Move translation block variables to new context inside tcg_ctx: tb_ctx
It's worth to clean-up translation blocks variables and move theminto one context as was suggested by Swirl.Also if we use this context directly inside tcg_ctx, then itspeeds up code generation a bit....
Merge branch 'for-linux-user' of https://git.gitorious.org/qemu-m68k/qemu-m68k into staging
linux-user: Restore cast to target type in get_user()
Commit 658f2dc97 accidentally dropped the cast to the target type ofthe value loaded by get_user(). The most visible effect of this wouldbe that the sequence "uint64_t v; get_user_u32(v, addr)" would sign...
cpu: do not use object_delete
CPUs are never added to the composition tree, so delete is achievedsimply by removing the last references to them.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
linux-user: bsd-user: Don't reset X86CPU twice
Since commit 65dee38052597b6285eb208125369f01b29ba6c1 (target-i386:move cpu_reset and reset callback to cpu.c) the x86 CPU is reset throughcpu_init() but was still reset immediately after in linux-user and...
linux-user: correct msgrcv()
All parameters must be swapped before the call of do_msgrcv().
Allow faked (debian fakeroot daemon) to work properly.
WITHOUT this patch:
$ faked-sysv --foreground --debugusing 1723744788 as msg keymsg_key=17237447881723744788:431...
linux-user: correct print_timeval() swap tv_sec and tv_usec
Signed-off-by: Laurent Vivier <Laurent@Vivier.EU>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
linux-user: correct setsockopt()
SO_SNDTIMEO and SO_RCVTIMEO take a struct timeval, not an int
To test this, you can use :
QEMU_STRACE= ping localhost 2>&1 |grep TIMEO568 setsockopt(3,SOL_SOCKET,SO_SNDTIMEO,{1,0},8) = 0568 setsockopt(3,SOL_SOCKET,SO_RCVTIMEO,{1,0},8) = 0...
linux-user: correct reboot()
According to man reboot(2), the 4th argument is only used withLINUX_REBOOT_CMD_RESTART2. In other cases, trying to convertthe value can generate EFAULT.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
alpha-linux-user: Correct select
Alpha, like s390x, passes all select arguments in registers.
Signed-off-by: Laurent Vivier <laurent@vivier.eu>Signed-off-by: Richard Henderson <rth@twiddle.net>
alpha-linux-user: Translate fcntl l_type
The values of F_RDLCK, F_WRLCK, F_UNLCK, F_EXLCK, F_SHLCKdiffer between alpha and other linux architectures.
This patch allows to run "dpkg" (database lock).
Merge branch 'ppc-for-upstream' of git://repo.or.cz/qemu/agraf
Merge branch 's390-reorg' of git://repo.or.cz/qemu/rth
alpha-linux-user: Fix sigaction
Unconditional bswap replaced by _get_user/_put_user.
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
linux-user: Rewrite _get_user/_put_user with __builtin_choose_expr
The previous formuation with multiple assignments to __typeof(*hptr) fallsdown when hptr is qualified const. E.g. with const struct S *p, p->f isalso qualified const.
With this formulation, there's no assignment to any local variable....
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...
PPC: linux-user: Calculate context pointer explicitly
Peter Maydell recommended the change to be more proper. The result was testedand shows coming up with the same proper value.
Signed-off-by: Samuel Seay <LightningTH@GMail.com>[agraf: change subject]...
PPC: fix segfault in signal handling code
Removed h2g() macro around the ka->_sa_handler due to the _sa_handler being aguest memory address.
Changed the __put_user to put_user as it was attempting to put a value at thestack address but the new address is a guest memory address, __put_user is...
target-s390: Reorg exception handling
Make the user path more like the system path. Prepare for more kindsof runtime exceptions. Rename ILC to ILEN to make it clear that wewant to pass around a full instruction length, rather than a "code" that happens to be stored one bit left in a larger field....
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.
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: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type
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>
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...