summaryrefslogtreecommitdiff
path: root/linux-user
AgeCommit message (Collapse)AuthorFilesLines
2016-10-31linux-user/elfload: ensure mmap_lock() held while setting upAlex Bennée1-0/+4
Future patches will enforce the holding of mmap_lock() when we are manipulating internal memory structures. Technically it doesn't matter in the case of elfload as we haven't started executing yet. However it is easier to grab the lock when required than special case the translate-all API. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Message-Id: <20161027151030.20863-8-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-10-31translate-all: add DEBUG_LOCKING assertsAlex Bennée1-0/+5
This adds asserts to check the locking on the various translation engines structures. There are two sets of structures that are protected by locks. The first the l1map and PageDesc structures used to track which translation blocks are associated with which physical addresses. In user-mode this is covered by the mmap_lock. The second case are TB context related structures which are protected by tb_lock which is also user-mode only. Currently the asserts do nothing in SoftMMU mode but this will change for MTTCG. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Message-Id: <20161027151030.20863-4-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-10-26target-alpha: Emulate LL/SC using cmpxchg helpersRichard Henderson1-49/+0
Emulating LL/SC with cmpxchg is not correct, since it can suffer from the ABA problem. However, portable parallel code is written assuming only cmpxchg which means that in practice this is a viable alternative. Signed-off-by: Richard Henderson <rth@twiddle.net>
2016-10-26linux-user: remove handling of aarch64's EXCP_STREXEmilio G. Cota1-125/+0
The exception is not emitted anymore. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Richard Henderson <rth@twiddle.net> Message-Id: <1467054136-10430-30-git-send-email-cota@braap.org>
2016-10-26linux-user: remove handling of ARM's EXCP_STREXEmilio G. Cota1-93/+0
The exception is not emitted anymore. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Richard Henderson <rth@twidle.net> Message-Id: <1467054136-10430-29-git-send-email-cota@braap.org>
2016-10-26linux-user: enable parallel code generation on cloneAlex Bennée1-0/+8
The variable parallel_cpus controls the generation of thread aware atomic code. We only need to set it once we clone our first thread. At this point any existing translations need to be thrown away. Reviewed-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2016-10-26tcg: Add EXCP_ATOMICRichard Henderson1-0/+45
When we cannot emulate an atomic operation within a parallel context, this exception allows us to stop the world and try again in a serial context. Reviewed-by: Emilio G. Cota <cota@braap.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Richard Henderson <rth@twiddle.net>
2016-10-24target-arm: Implement new HLT trap for semihostingPeter Maydell1-0/+3
Version 2.0 of the semihosting specification introduces new trap instructions for AArch32: HLT 0xF000 for A32 and HLT 0x3C for T32. Implement these (in the same way we implement the existing HLT semihosting trap for A64). The old traps via SVC and BKPT are unaffected. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Message-id: 1476792973-18508-1-git-send-email-peter.maydell@linaro.org
2016-10-24Put the copyright information on a separate lineThomas Huth1-1/+1
The output string QEMU with "--version" is very long, it does not fit into a normal line of a terminal window anymore. By putting the copyright information on a separate line instead, the output looks much nicer. Signed-off-by: Thomas Huth <thuth@redhat.com> Message-Id: <1475661284-30153-1-git-send-email-thuth@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-10-21linux-user: added support for pwritev() system call.Dejan Jovicevic1-0/+15
This system call performs the same task as the writev() system call, with the exception of having the fourth argument, offset, which specifes the file offset at which the input operation is to be performed. Because of this, the pwritev() implementation is based on the writev() implementation in linux-user mode. But, since pwritev() is implemented in the kernel as a 5-argument syscall, 5 arguments are needed to be handled as input and passed to the host syscall. The pos_l and pos_h argument of the safe_pwritev() are of type unsigned long, which can be of different sizes on different platforms. The input arguments are converted to the appropriate host size when passed to safe_pwritev(). Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: added support for preadv() system call.Dejan Jovicevic1-0/+15
This system call performs the same task as the readv() system call, with the exception of having the fourth argument, offset, which specifes the file offset at which the input operation is to be performed. Because of this, the preadv() implementation is based on the readv() implementation in linux-user mode. But, since preadv() is implemented in the kernel as a 5-argument syscall, 5 arguments are needed to be handled as input and passed to the host syscall. The pos_l and pos_h argument of the safe_preadv() are of type unsigned long, which can be of different sizes on different platforms. The input arguments are converted to the appropriate host size when passed to safe_preadv(). Signed-off-by: Dejan Jovicevic <dejan.jovicevic@rt-rk.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix fadvise64() syscall support for Mips32Aleksandar Markovic1-1/+1
By looking at the file arch/mips/kernel/scall32-o32.S in Linux kernel, it can be deduced that, for Mips32 platform, syscall corresponding to number _NR_fadvise64 as defined in kernel file arch/mips/include/uapi/asm/unistd.h translates to kernel function sys_fadvise64_64, and that argument layout for this system call is as follows: 0 32 0 32 +----------------+----------------+ (arg1) | fd | __pad | (arg2) +----------------+----------------+ (arg3) | buffer | (arg4) +----------------+----------------+ (arg5) | len | (arg6) +----------------+----------------+ (arg7) | advise | not used | (arg8) +----------------+----------------+ The same argument layout can be deduced from glibc code, and relevant commit messages in linux kernel and glibc. The fix is to change TARGET_NR_fadvise64 to TARGET_NR_fadvise64_64 in Mips32 syscall numbers table. Array mips_syscall_args[] in linux-user/main.c also already have "fadvise64_64" (and not "fadvise64") in corresponding place for the syscall number in question, so no change for linux-user/main.c. This patch also fixes the failure LTP test posix_fadvise03, if executed on Qemu-emulated Mips32 platform (user mode). Signed-off-by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com> Signed-off-by: Miroslav Tisma <miroslav.tisma@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Redirect termbits.h for Mips64 to termbits.h for Mips32Aleksandar Markovic1-244/+1
linux-user/mips64/termbits.h and linux-user/mips/termbits.h originate from the same files in Linux kernel. There is no plan to split original headers in Linux kernel into Mips32 and Mips64 versions any time soon. Therefore, it is better not to have separate Mips32 and Mips64 variants in Qemu. This patch makes these two files effectively the same, allowing the mainenance by changing only a single file. (This is already done in the same fashion for some other headers in same directories.) Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Update ioctls definitions for Mips32Aleksandar Markovic1-0/+12
Update linux-user/mips/termbits.h with ioctl definitions from kernel file arch/mips/include/uapi/asm/ioctls.h. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Update mips_syscall_args[] array in main.cAleksandar Markovic1-2/+22
Array mips_syscall_args[] determines number of arguments for each syscall on Mips32. It wasn't updated with newer syscalls. Also, preadv and pwritev have 5 arguments, not 6. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Add support for syncfs() syscallAleksandar Markovic2-1/+6
This patch implements Qemu user mode syncfs() syscall support. Syscall syncfs() syncs the filesystem containing file determined by the open file descriptor passed as the argument to syncfs(). The implementation consists of a straightforward invocation of host's syncfs(). Configure and strace support is included as well. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Add support for clock_adjtime() syscallAleksandar Markovic3-0/+97
This patch implements Qemu user mode clock_adjtime() syscall support. The implementation is based on invocation of host's clock_adjtime(). Signed-off-by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix definition of target_sigevent for 32-bit guestsPeter Maydell1-6/+10
The sigevent structure includes a union with some fields which are pointers. For the QEMU target_sigevent structure we must represent these as abi_ulongs, not host function pointers. This error was causing the compiler to believe it should 8-align the _sigev_un union on a 64-bit host, which meant that the code in target_to_host_sigevent() was looking at the wrong offset to find the _tid field, and timer_create() would spuriously fail with EINVAL. This fixes the final loose end noted in LP:1042388. While we're editing the structure, switch the 'int32_t' fields to 'abi_int'; this will only matter for guests with non-standard integer alignment like m68k. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: use libc wrapper instead of direct mremap syscallFelix Janda1-10/+4
This commit essentially reverts commit 3af72a4d98dca033492102603734cbc63cd2694a, which has replaced five-argument calls to mremap() by direct mremap syscalls for compatibility with glibc older than version 2.4. The direct syscall was buggy for 64bit targets on 32bit hosts because of the default integer type promotions. Since glibc-2.4 is now a decade old, we can remove this workaround. Signed-off-by: Felix Janda <felix.janda@posteo.de> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Don't use alloca() for epoll_wait's epoll event arrayPeter Maydell1-4/+13
The epoll event array which epoll_wait() allocates has a size determined by the guest which could potentially be quite large. Use g_try_new() rather than alloca() so that we can fail more cleanly if the guest hands us an oversize value. (ENOMEM is not a documented return value for epoll_wait() but in practice some kernel configurations can return it -- see for instance sys_oabi_epoll_wait() on ARM.) This rearrangement includes fixing a bug where we were incorrectly passing a negative length to unlock_user() in the error-exit codepath. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: add RTA_PRIORITY in netlinkLaurent Vivier1-0/+1
Used by fedora21 on ppc64 in the network initialization Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: add kcmp() syscallLaurent Vivier1-0/+10
Signed-off-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: sparc64: Use correct target SHMLBA in shmat()Peter Maydell1-0/+7
In commit 40df8c0c0722 support was added for target-specific handling of SHMLBA. Unfortunately the sparc64-specific part of the change got lost somewhere between the patch being posted to the list and going into master: http://patchwork.ozlabs.org/patch/646980/ http://patchwork.ozlabs.org/patch/673339/ Add the accidentally-dropped code. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Remove a duplicate item from strace.listAleksandar Markovic1-3/+0
There is a duplicate item in strace.list. It is benign, but it shouldn't be there, since it may lead to confusion and even bugs in the future. It is the only duplicate in strace.list. This patch removes it. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix syslog() syscall supportAleksandar Markovic4-7/+142
There are currently several problems related to syslog() support. For example, if the second argument "bufp" of target syslog() syscall is NULL, the current implementation always returns error code EFAULT. However, NULL is a perfectly valid value for the second argument for many use cases of this syscall. This is, for example, visible from this excerpt of man page for syslog(2): > EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is > NULL, or len is less than zero; or for type 8, the level is > outside the range 1 to 8). Moreover, the argument "bufp" is ignored for all cases of values of the first argument, except 2, 3 and 4. This means that for such cases (the first argument is not 2, 3 or 4), there is no need to pass "buf" between host and target, and it can be set to NULL while calling host's syslog(), without loss of emulation accuracy. Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the correct returned error code is EINVAL, not EFAULT. All these details are reflected in this patch. "#ifdef TARGET_NR_syslog" is also proprerly inserted when needed. Support for Qemu's "-strace" switch for syslog() syscall is included too. LTP tests syslog11 and syslog12 pass with this patch (while fail without it), on any platform. Changes to original patch by Riku Voipio: fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335 Should fix also the build error in: https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix socketcall() syscall supportAleksandar Markovic3-95/+105
Since not all Linux host platforms support socketcall() (most notably Intel), do_socketcall() function in Qemu's syscalls.c is implemented to mirror the corespondant implementation of socketcall() in Linux kernel, and to utilise individual socket operations that are supported on all Linux platforms. (see kernel source file net/socket.c, definition of socketcall). However, error codes produced by Qemu implementation are wrong for the cases of invalid values of the first argument. Also, naming of constants is not consistent with kernel one, and not consistant with Qemu convention of prefixing such constants with "TARGET_". This patch in that light brings do_socketcall() closer to its kernel counterpart, and in that way fixes the errors and yields more consisrtent Qemu code. There were also three missing cases (among 20) for strace support for socketcall(). The array that contains pointers for appropriate printing functions is updated with 3 elements, however pointers to functions are left NULL, and its implementation is left for future. Also, this patch fixes failure of LTP test socketcall02, if executed on some Qemu emulated sywstems (uer mode). Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix msgrcv() and msgsnd() syscalls supportAleksandar Markovic1-0/+3
If syscalls msgrcv() and msgsnd() fail, they return E2BIG, EACCES, EAGAIN, EFAULT, EIDRM, EINTR, EINVAL, ENOMEM, or ENOMSG. By examining negative scenarios of these syscalls for Mips, it was established that ENOMSG does not have the same value accross all platforms, but it is nevertheless not included for conversion in the correspondant conversion table defined in linux-user/syscall.c. This is certainly a bug, since it leads to the incorrect emulation of msgrcv() and msgsnd() for scenarios involving ENOMSG. This patch fixes this by extending the conversion table to include ENOMSG. Also, LTP test msgrcv04 will be fixed for some platforms. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Fix mq_open() syscall supportAleksandar Markovic1-7/+9
Conversion of file creation flags (O_CREAT, ...) from target to host was missing. Also, this patch implements better error handling. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-21linux-user: Add support for adjtimex() syscallAleksandar Markovic4-2/+162
This patch implements Qemu user mode adjtimex() syscall support. Syscall adjtimex() reads and optionally sets parameters for a clock adjustment algorithm used in network synchonization or similar scenarios. Its declaration is: int adjtimex(struct timex *buf); The correspondent source code in the Linux kernel is at kernel/time.c, line 206. The Qemu implementation is based on invocation of host's adjtimex(), and its key part is in the "TARGET_NR_adjtimex" case segment of the the main switch statement of the function do_syscall(), in linux-user/syscalls.c. All necessary conversions of the data structures from target to host and from host to target are covered. Two new functions, target_to_host_timex() and host_to_target_timex(), are provided for the purpose of such conversions. For that purpose, the support for related structure "timex" had tp be added to the file linux-user/syscall_defs.h, based on its definition in Linux kernel. Also, the relevant support for "-strace" Qemu option is included in files linux-user/strace.c and linux-user/strace.list. This patch also fixes failures of LTP tests adjtimex01 and adjtimex02, if executed in Qemu user mode. Signed-off-by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-10-12trace: provide mechanism for registering trace eventsDaniel P. Berrange1-0/+1
Remove the notion of there being a single global array of trace events, by introducing a method for registering groups of events. The module_call_init() needs to be invoked at the start of any program that wants to make use of the trace support. Currently this covers system emulators qemu-nbd, qemu-img and qemu-io. [Squashed the following fix from Daniel P. Berrange <berrange@redhat.com>: linux-user/bsd-user: initialize trace events subsystem The bsd-user/linux-user programs make use of the CPU emulation code and this now requires that the trace events subsystem is enabled, otherwise it'll crash trying to allocate an empty trace events bitmap for the CPU object. --Stefan] Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Lluís Vilanova <vilanova@ac.upc.edu> Signed-off-by: Daniel P. Berrange <berrange@redhat.com> Message-id: 1475588159-30598-14-git-send-email-berrange@redhat.com Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-10-10Merge remote-tracking branch 'remotes/mjt/tags/trivial-patches-fetch' into ↵Peter Maydell1-1/+1
staging trivial patches for 2016-10-08 # gpg: Signature made Sat 08 Oct 2016 09:56:38 BST # gpg: using RSA key 0x701B4F6B1A693E59 # gpg: Good signature from "Michael Tokarev <mjt@tls.msk.ru>" # gpg: aka "Michael Tokarev <mjt@corpit.ru>" # gpg: aka "Michael Tokarev <mjt@debian.org>" # Primary key fingerprint: 6EE1 95D1 886E 8FFB 810D 4324 457C E0A0 8044 65C5 # Subkey fingerprint: 7B73 BAD6 8BE7 A2C2 8931 4B22 701B 4F6B 1A69 3E59 * remotes/mjt/tags/trivial-patches-fetch: (26 commits) net/filter-mirror: Fix mirror initial check typo virtio: rename the bar index field name in VirtIOPCIProxy linux-user: include <poll.h> instead of <sys/poll.h> char: fix missing return in error path for chardev TLS init CODING_STYLE: Fix a typo ("have" vs. "has") bitmap: refine and move BITMAP_{FIRST/LAST}_WORD_MASK build-sys: fix find-in-path m68k: change default system clock for m5208evb exec: remove unused compacted argument usb: ehci: fix memory leak in ehci_process_itd qapi: make the json schema files more regular. maint: Add module_block.h to .gitignore MAINTAINERS: Some updates related to the SH4 machines MAINTAINERS: Add some more MIPS related files MAINTAINERS: Add usermode related config files MAINTAINERS: Add some more pattern to recognize all win32 related files MAINTAINERS: Add some more rocker related files MAINTAINERS: Add header files to CRIS section MAINTAINERS: Add some more files to the virtio section MAINTAINERS: Add some SPARC machine related files ... # Conflicts: # MAINTAINERS
2016-10-08linux-user: include <poll.h> instead of <sys/poll.h>Felix Janda1-1/+1
This removes the last usage of <sys/poll.h> in the code base. Signed-off-by: Felix Janda <felix.janda@posteo.de> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-10-04linux-user/syscall: extend lock around cpu-listAlex Bennée1-1/+6
There is a potential race if several threads exit at once. To serialise the exits extend the lock above the initial checking of the CPU list. Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20160930213106.20186-11-alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-29Merge remote-tracking branch 'remotes/stefanha/tags/tracing-pull-request' ↵Peter Maydell1-1/+0
into staging # gpg: Signature made Wed 28 Sep 2016 22:30:45 BST # gpg: using RSA key 0x9CA4ABB381AB73C8 # gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>" # gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>" # Primary key fingerprint: 8695 A8BF D3F9 7CDA AC35 775A 9CA4 ABB3 81AB 73C8 * remotes/stefanha/tags/tracing-pull-request: trace: Document the execution mode of guest events trace: Add event "guest_cpu_reset" trace: Add event "guest_cpu_enter" trace: Properly initialize dynamic event states in hot-plugged vCPUs trace: move hw/virtio/virtio-balloon.c trace points into correct file trace: move hw/mem/pc-dimm.c trace points into correct file trace: move util/qemu-coroutine*.c trace points into correct file trace: move util/buffer.c trace points into correct file Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-09-28trace: Properly initialize dynamic event states in hot-plugged vCPUsLluís Vilanova1-1/+0
Every time a vCPU is hot-plugged, it will "inherit" its tracing state from the global state array. That is, if *any* existing vCPU has an event enabled, new vCPUs will have too. Signed-off-by: Lluís Vilanova <vilanova@ac.upc.edu> Message-id: 147428970768.15111.7664565956870423529.stgit@fimbulvetr.bsc.es Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2016-09-27cpus-common: move exclusive work infrastructure from linux-userPaolo Bonzini1-87/+0
This will serve as the base for async_safe_run_on_cpu. Because start_exclusive uses CPU_FOREACH, merge exclusive_lock with qemu_cpu_list_lock: together with a call to exclusive_idle (via cpu_exec_start/end) in cpu_list_add, this protects exclusive work against concurrent CPU addition and removal. Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-27cpus-common: move CPU work item management to common codeSergey Fedorov1-0/+25
Make CPU work core functions common between system and user-mode emulation. User-mode does not use run_on_cpu, so do not implement it. Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <1470158864-17651-10-git-send-email-alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-27cpus-common: move CPU list management to common codePaolo Bonzini1-13/+4
Add a mutex for the CPU list to system emulation, as it will be used to manage safe work. Abstract manipulation of the CPU list in new functions cpu_list_add and cpu_list_remove. Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-27linux-user: Add qemu_cpu_is_self() and qemu_cpu_kick()Sergey Fedorov1-0/+10
Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <1470158864-17651-9-git-send-email-alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-27linux-user: Use QemuMutex and QemuCondSergey Fedorov1-23/+32
Convert pthread_mutex_t and pthread_cond_t to QemuMutex and QemuCond. This will allow to make some locks and conditional variables common between user and system mode emulation. Signed-off-by: Sergey Fedorov <serge.fdrv@gmail.com> Signed-off-by: Sergey Fedorov <sergey.fedorov@linaro.org> Reviewed-by: Alex Bennée <alex.bennee@linaro.org> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <1470158864-17651-7-git-send-email-alex.bennee@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-09-23Merge remote-tracking branch 'remotes/lalrae/tags/mips-20160923' into stagingPeter Maydell6-2/+147
MIPS patches 2016-09-23 Changes: * 24KEc CPU definition * SYNC instructions make use of tcg memory barrier ops * various MIPS linux-user bug fixes # gpg: Signature made Fri 23 Sep 2016 08:09:08 BST # gpg: using RSA key 0x52118E3C0B29DA6B # gpg: Good signature from "Leon Alrae <leon.alrae@imgtec.com>" # Primary key fingerprint: 8DD3 2F98 5495 9D66 35D4 4FC0 5211 8E3C 0B29 DA6B * remotes/lalrae/tags/mips-20160923: linux-user: Add missing Mips syscalls items in strace.list linux-user: Add missing TARGET_EDQUOT error code for Mips linux-user: Fix certain argument alignment cases for Mips64 linux-user: Fix structure target_semid64_ds definition for Mips linux-user: Fix structure target_flock definition for Mips linux-user: Fix TARGET_F_GETOWN definition for Mips linux-user: Fix TARGET_SIOCATMARK definition for Mips target-mips: generate fences target-mips: add 24KEc CPU definition Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-09-23linux-user: Add missing Mips syscalls items in strace.listAleksandar Markovic1-0/+114
Without this patch, a number of Mips syscalls will be logged in the following way (in this example, this is an invocation of accept4()): 86906 Unknown syscall 4334 This patch provides standard Qemu's strace output for such cases, like this: 95861 accept4(3,1996486000,1996486016,128,0,0) = 5 Such output may be further improved by providing strace-related functions that handle only particular syscalls, but this is beyond the scope of this patch. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Add missing TARGET_EDQUOT error code for MipsAleksandar Markovic3-0/+5
EDQUOT is defined for Mips platform in Linux kernel in such a way that it has different value than on most other platforms. However, correspondent TARGET_EDQUOT for Mips is missing in Qemu code. Moreover, TARGET_EDQUOT is missing from the table for conversion of error codes from host to target. This patch fixes these problems. Without this patch, syscalls add_key(), keyctl(), link(), mkdir(), mknod(), open(), rename(), request_key(), setxattr(), symlink(), and write() will not be able to return the right error code in some scenarios on Mips platform. (Some of these syscalls are not yet supported in Qemu, but once they are supported, they will need correct EDQUOT handling.) Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Fix certain argument alignment cases for Mips64Aleksandar Markovic1-1/+1
The function that is changed in this patch is supposed to indicate that there was certain argument rearrangement related to 64-bit arguments on 32-bit platforms. The background on such rearrangements can be found, for example, in the man page for syscall(2). However, for 64-bit Mips architectures there is no such rearrangement, and this patch reflects it. Signed-off-by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Fix structure target_semid64_ds definition for MipsAleksandar Markovic1-0/+16
This patch corrects target_semid64_ds structure definition for Mips. See, for example definition of semid64_ds for Mips in Linux kernel: arch/mips/include/uapi/asm/sembuf.h#L13. This patch will also fix certain semaphore-related LTP tests for Mips, if they are executed in Qemu user mode for any Mips platform. Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Fix structure target_flock definition for MipsAleksandar Markovic1-0/+6
Structure flock is defined for Mips in a way different from any other platform. For reference, see Linux kernel source code files: arch/mips/include/uapi/asm/fcntl.h, line 63 (for Mips) include/uapi/asm-generic/fcntl.h, line 195 (for all other platforms) This patch fix this problem, by amending structure target_flock, for Mips only. Besides, this patch fixes LTP tests fcntl11, fcntl17, fcntl19, fcntl20, and fcntl21, which are currently failing, if executed in Qemu user mode for Mips platforms. Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Fix TARGET_F_GETOWN definition for MipsAleksandar Markovic1-1/+1
For some reason, Qemu's TARGET_F_GETOWN constant for Mips does not match the correct value of correspondent F_GETOWN. This patch fixes this problem. For reference, see Mips' F_GETOWN definition in Linux kernel at arch/mips/include/uapi/asm/fcntl.h#L44. This patch also fixes some fcntl()-related LTP tests for Qemu user mode for Mips. Signed-off-by: Miodrag Dinic <miodrag.dinic@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: Fix TARGET_SIOCATMARK definition for MipsAleksandar Markovic1-0/+4
This patch fixes wrong definition of TARGET_SIOCATMARK for mips, alpha, and sh4. The current definition is: #define SIOCATMARK 0x8905 while the correct definition is: #define SIOCATMARK TARGET_IOR('s', 7, int) See Linux kernel source file arch/mips/include/uapi/asm/sockios.h#L19 for reference. This patch also a fixes LTP test failure for test sockioctl01, for mips, alpha, and sh4. Signed-off-by: Aleksandar Rikalo <aleksandar.rikalo@imgtec.com> Signed-off-by: Aleksandar Markovic <aleksandar.markovic@imgtec.com> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Reviewed-by: Leon Alrae <leon.alrae@imgtec.com> Acked-by: Riku Voipio <riku.voipio@linaro.org> Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
2016-09-23linux-user: ppc64: fix ARCH_206 bit in AT_HWCAPMichael Walle1-2/+6
Only the POWER[789] CPUs should have the ARCH_206 bit set. This is what the linux kernel does. I guess this was also the intention of commit 0e019746. We have to make sure all *206 bits are set. Before this patch, the flags check in the GET_FEATURES2 macro returned true if _any_ bit was set. This worked well as long as there was only one bit set in the 'flag' parameter. But as explained before, we have to make sure all bits in the 'flag' parameter are set. Signed-off-by: Michael Walle <michael@walle.cc> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
2016-09-23ppc: Fix signal delivery in ppc-user and ppc64-userBenjamin Herrenschmidt3-38/+90
There were a number of bugs in the implementation: - The structure alignment was wrong for 64-bit. - Also 64-bit only does RT signals. - On 64-bit, we need to put a pointer to the (aligned) vector registers in the frame and use it for restoring - We had endian bugs when saving/restoring vector registers - My recent fixes for exception NIP broke sigreturn in user mode causing us to resume one instruction too far. - Add VSR second halves Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>