summaryrefslogtreecommitdiff
path: root/linux-user
AgeCommit message (Collapse)Author
2016-06-08Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160608' ↵Peter Maydell
into staging linux-user pull request for June 2016 # gpg: Signature made Wed 08 Jun 2016 14:27:14 BST # gpg: using RSA key 0xB44890DEDE3C9BC0 # gpg: Good signature from "Riku Voipio <riku.voipio@iki.fi>" # gpg: aka "Riku Voipio <riku.voipio@linaro.org>" * remotes/riku/tags/pull-linux-user-20160608: (44 commits) linux-user: In fork_end(), remove correct CPUs from CPU list linux-user: Special-case ERESTARTSYS in target_strerror() linux-user: Make target_strerror() return 'const char *' linux-user: Correct signedness of target_flock l_start and l_len fields linux-user: Use safe_syscall wrapper for ioctl linux-user: Use safe_syscall wrapper for accept and accept4 syscalls linux-user: Use safe_syscall wrapper for semop linux-user: Use safe_syscall wrapper for epoll_wait syscalls linux-user: Use safe_syscall wrapper for poll and ppoll syscalls linux-user: Use safe_syscall wrapper for sleep syscalls linux-user: Use safe_syscall wrapper for rt_sigtimedwait syscall linux-user: Use safe_syscall wrapper for flock linux-user: Use safe_syscall wrapper for mq_timedsend and mq_timedreceive linux-user: Use safe_syscall wrapper for msgsnd and msgrcv linux-user: Use safe_syscall wrapper for send* and recv* syscalls linux-user: Use safe_syscall wrapper for connect syscall linux-user: Use safe_syscall wrapper for readv and writev syscalls linux-user: Fix error conversion in 64-bit fadvise syscall linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guests linux-user: Fix handling of arm_fadvise64_64 syscall ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Conflicts: configure scripts/qemu-binfmt-conf.sh
2016-06-08Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into stagingPeter Maydell
* max-ram-below-4g improvement (Gerd) * escc fix (xiaoqiang) * ESP fix (Prasad) * scsi-disk tweaks/fix (me) * Makefile dependency fixes (me) * PKGVERSION improvement (Fam) * -vnc man improvement (Robert) # gpg: Signature made Tue 07 Jun 2016 18:06:22 BST # gpg: using RSA key 0xBFFBD25F78C7AE83 # gpg: Good signature from "Paolo Bonzini <bonzini@gnu.org>" # gpg: aka "Paolo Bonzini <pbonzini@redhat.com>" * remotes/bonzini/tags/for-upstream: vnc: list the 'to' parameter of '-vnc' in the qemu man page scsi-disk: add missing break Makefile: Derive "PKGVERSION" from "git describe" by default Makefile: add dependency on scripts/hxtool Makefile: add dependency on scripts/make_device_config.sh Makefile: add dependency on scripts/create_config Makefile: Add a "FORCE" target scsi: megasas: null terminate bios version buffer scsi: mark TYPE_SCSI_DISK_BASE as abstract scsi: esp: check TI buffer index before read/write hw/char: QOM'ify escc.c (fix) pc: allow raising low memory via max-ram-below-4g option tests: Rename tests/Makefile to tests/Makefile.include Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2016-06-08linux-user: In fork_end(), remove correct CPUs from CPU listPeter Maydell
In fork_end(), we must fix the list of current CPUs to match the fact that the child of the fork has only one thread. Unfortunately we were removing the wrong CPUs from the list, which meant that if the child subsequently did an exclusive operation it would deadlock in start_exclusive() waiting for a sibling CPU which didn't exist. In particular this could cause hangs doing git submodule init operations, as reported in https://bugs.launchpad.net/qemu/+bug/955379 comment #47. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Special-case ERESTARTSYS in target_strerror()Peter Maydell
Since TARGET_ERESTARTSYS and TARGET_ESIGRETURN are internal-to-QEMU error numbers, handle them specially in target_strerror(), to avoid confusing strace output like: 9521 rt_sigreturn(14,8,274886297808,8,0,268435456) = -1 errno=513 (Unknown error 513) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Make target_strerror() return 'const char *'Peter Maydell
Make target_strerror() return 'const char *' rather than just 'char *'; this will allow us to return constant strings from it for some special cases. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
2016-06-08linux-user: Correct signedness of target_flock l_start and l_len fieldsPeter Maydell
The l_start and l_len fields in the various target_flock structures are supposed to be '__kernel_off_t' or '__kernel_loff_t', which means they should be signed, not unsigned. Correcting the structure definitions means that __get_user() and __put_user() will correctly sign extend them if the guest is using 32 bit offsets and the host is using 64 bit offsets. This fixes failures in the LTP 'fcntl14' tests where it checks that negative seek offsets work correctly. We reindent the structures to drop hard tabs since we're touching 40% of the fields anyway. RV: long long -> abi_llong as suggested by Laurent Vivier <laurent@vivier.eu> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for ioctlPeter Maydell
Use the safe_syscall wrapper to implement the ioctl syscall. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for accept and accept4 syscallsPeter Maydell
Use the safe_syscall wrapper for the accept and accept4 syscalls. accept4 has been in the kernel since 2.6.28 so we can assume it is always present. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for semopPeter Maydell
Use the safe_syscall wrapper for the semop syscall or IPC operation. (We implement via the semtimedop syscall to make it easier to implement the guest semtimedop syscall later.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for epoll_wait syscallsPeter Maydell
Use the safe_syscall wrapper for epoll_wait and epoll_pwait syscalls. Since we now directly use the host epoll_pwait syscall for both epoll_wait and epoll_pwait, we don't need the configure machinery to check whether glibc supports epoll_pwait(). (The kernel has supported the syscall since 2.6.19 so we can assume it's always there.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for poll and ppoll syscallsPeter Maydell
Use the safe_syscall wrapper for the poll and ppoll syscalls. Since not all host architectures will have a poll syscall, we have to rewrite the TARGET_NR_poll handling to use ppoll instead (we can assume everywhere has ppoll by now). We take the opportunity to switch to the code structure already used in the implementation of epoll_wait and epoll_pwait, which uses a switch() to avoid interleaving #if and if (), and to stop using a variable with a leading '_' which is in the implementation's namespace. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for sleep syscallsPeter Maydell
Use the safe_syscall wrapper for the clock_nanosleep and nanosleep syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for rt_sigtimedwait syscallPeter Maydell
Use the safe_syscall wrapper for the rt_sigtimedwait syscall. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for flockPeter Maydell
Use the safe_syscall wrapper for the flock syscall. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for mq_timedsend and mq_timedreceivePeter Maydell
Use the safe_syscall wrapper for mq_timedsend and mq_timedreceive syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for msgsnd and msgrcvPeter Maydell
Use the safe_syscall wrapper for msgsnd and msgrcv syscalls. This is made slightly awkward by some host architectures providing only a single 'ipc' syscall rather than separate syscalls per operation; we provide safe_msgsnd() and safe_msgrcv() as wrappers around safe_ipc() to handle this if needed. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for send* and recv* syscallsPeter Maydell
Use the safe_syscall wrapper for the send, sendto, sendmsg, recv, recvfrom and recvmsg syscalls. RV: adjusted to apply Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for connect syscallPeter Maydell
Use the safe_syscall wrapper for the connect syscall. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Use safe_syscall wrapper for readv and writev syscallsPeter Maydell
Use the safe_syscall wrapper for readv and writev syscalls. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Fix error conversion in 64-bit fadvise syscallPeter Maydell
Fix a missing host-to-target errno conversion in the 64-bit fadvise syscall emulation. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Fix NR_fadvise64 and NR_fadvise64_64 for 32-bit guestsPeter Maydell
Fix errors in the implementation of NR_fadvise64 and NR_fadvise64_64 for 32-bit guests, which pass their off_t values in register pairs. We can't use the 64-bit code path for this, so split out the 32-bit cases, so that we can correctly handle the "only offset is 64-bit" and "both offset and length are 64-bit" syscall flavours, and "uses aligned register pairs" and "does not" flavours of target. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Fix handling of arm_fadvise64_64 syscallPeter Maydell
32-bit ARM has an odd variant of the fadvise syscall which has rearranged arguments, which we try to implement. Unfortunately we got the rearrangement wrong. This is a six-argument syscall whose arguments are: * fd * advise parameter * offset high half * offset low half * len high half * len low half Stop trying to share code with the standard fadvise syscalls, and just implement the syscall with the correct argument order. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: provide frame information in x86-64 safe_syscallPeter Maydell
Use cfi directives in the x86-64 safe_syscall to allow gdb to get backtraces right from within it. (In particular this will be quite a common situation if the user interrupts QEMU while it's in a blocked safe-syscall: at the point of the syscall insn RBP is in use for something else, and so gdb can't find the frame then without assistance.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Richard Henderson <rth@twiddle.net> Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-08linux-user: Avoid possible misalignment in target_to_host_siginfo()Peter Maydell
Reimplement target_to_host_siginfo() to use __get_user(), which handles possibly misaligned source guest structures correctly. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Use DIV_ROUND_UPLaurent Vivier
Replace (((n) + (d) - 1) /(d)) by DIV_ROUND_UP(n,d). This patch is the result of coccinelle script scripts/coccinelle/round.cocci CC: Riku Voipio <riku.voipio@iki.fi> Signed-off-by: Laurent Vivier <lvivier@redhat.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
2016-06-07linux-user: Use both si_code and si_signo when converting siginfo_tPeter Maydell
The siginfo_t struct includes a union. The correct way to identify which fields of the union are relevant is complicated, because we have to use a combination of the si_code and si_signo to figure out which of the union's members are valid. (Within the host kernel it is always possible to tell, but the kernel carefully avoids giving userspace the high 16 bits of si_code, so we don't have the information to do this the easy way...) We therefore make our best guess, bearing in mind that a guest can spoof most of the si_codes via rt_sigqueueinfo() if it likes. Once we have made our guess, we record it in the top 16 bits of the si_code, so that tswap_siginfo() later can use it. tswap_siginfo() then strips these top bits out before writing si_code to the guest (sign-extending the lower bits). This fixes a bug where fields were sometimes wrong; in particular the LTP kill10 test went into an infinite loop because its signal handler got a si_pid value of 0 rather than the pid of the sending process. As part of this change, we switch to using __put_user() in the tswap_siginfo code which writes out the byteswapped values to the target memory, in case the target memory pointer is not sufficiently aligned for the host CPU's requirements. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Restart fork() if signals pendingTimothy E Baldwin
If there is a signal pending during fork() the signal handler will erroneously be called in both the parent and child, so handle any pending signals first. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-20-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Use safe_syscall for kill, tkill and tgkill syscallsPeter Maydell
Use the safe_syscall wrapper for the kill, tkill and tgkill syscalls. Without this, if a thread sent a SIGKILL to itself it could kill the thread before we had a chance to process a signal that arrived just before the SIGKILL, and that signal would get lost. We drop all the ifdeffery for tkill and tgkill, because every guest architecture we support implements them, and they've been in Linux since 2003 so we can assume the host headers define the __NR_tkill and __NR_tgkill constants. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Restart exit() if signal pendingTimothy E Baldwin
Without this a signal could vanish on thread exit. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-26-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: pause() should not pause if signal pendingTimothy E Baldwin
Fix races between signal handling and the pause syscall by reimplementing it using block_signals() and sigsuspend(). (Using safe_syscall(pause) would also work, except that the pause syscall doesn't exist on all architectures.) Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-28-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: tweaked commit message] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Block signals during sigaction() handlingTimothy E Baldwin
Block signals while emulating sigaction. This is a non-interruptible syscall, and using block_signals() avoids races where the host signal handler is invoked and tries to examine the signal handler data structures while we are updating them. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-29-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: expanded commit message] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Queue synchronous signals separatelyTimothy E Baldwin
If a synchronous signal and an asynchronous signal arrive near simultaneously, and the signal number of the asynchronous signal is lower than that of the synchronous signal the the handler for the asynchronous would be called first, and then the handler for the synchronous signal would be called within or after the first handler with an incorrect context. This is fixed by queuing synchronous signals separately. Note that this does risk delaying a asynchronous signal until the synchronous signal handler returns rather than handling the signal on another thread, but this seems unlikely to cause problems for real guest programs and is unavoidable unless we could guarantee to roll back and reexecute whatever guest instruction caused the synchronous signal (which would be a bit odd if we've already logged its execution, for instance, and would require careful analysis of all guest CPUs to check it was possible in all cases). Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-24-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: added a comment] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Remove real-time signal queuingTimothy E Baldwin
As host signals are now blocked whenever guest signals are blocked, the queue of realtime signals is now in Linux. The QEMU queue is now redundant and can be removed. (We already did not queue non-RT signals, and none of the calls to queue_signal() except the one in host_signal_handler() pass an RT signal number.) Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-23-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell <peter.maydell@linaro.org> [PMM: minor commit message tweak] Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Remove redundant default action check in queue_signal()Timothy E Baldwin
Both queue_signal() and process_pending_signals() did check for default actions of signals, this is redundant and also causes fatal and stopping signals to incorrectly cause guest system calls to be interrupted. The code in queue_signal() is removed. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-21-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Fix race between multiple signalsPeter Maydell
If multiple host signals are received in quick succession they would be queued in TaskState then delivered to the guest in spite of signals being supposed to be blocked by the guest signal handler's sa_mask. Fix this by decoupling the guest signal mask from the host signal mask, so we can have protected sections where all host signals are blocked. In particular we block signals from when host_signal_handler() queues a signal from the guest until process_pending_signals() has unqueued it. We also block signals while we are manipulating the guest signal mask in emulation of sigprocmask and similar syscalls. Blocking host signals also ensures the correct behaviour with respect to multiple threads and the overrun count of timer related signals. Alas blocking and queuing in qemu is still needed because of virtual processor exceptions, SIGSEGV and SIGBUS. Blocking signals inside process_pending_signals() protects against concurrency problems that would otherwise happen if host_signal_handler() ran and accessed the signal data structures while process_pending_signals() was manipulating them. Since we now track the guest signal mask separately from that of the host, the sigsuspend system calls must track the signal mask passed to them, because when we process signals as we leave the sigsuspend the guest signal mask in force is that passed to sigsuspend. Signed-off-by: Timothy Edward Baldwin <T.E.Baldwin99@members.leeds.ac.uk> Message-id: 1441497448-32489-19-git-send-email-T.E.Baldwin99@members.leeds.ac.uk [PMM: make signal_pending a simple flag rather than a word with two flag bits; ensure we don't call block_signals() twice in sigreturn codepaths; document and assert() the guarantee that using do_sigprocmask() to get the current mask never fails; use the qemu atomics.h functions rather than raw volatile variable access; add extra commentary and documentation; block SIGSEGV/SIGBUS in block_signals() and in process_pending_signals() because they can't occur synchronously here; check the right do_sigprocmask() call for errors in ssetmask syscall; expand commit message; fixed sigsuspend() hanging] Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Use safe_syscall for sigsuspend syscallsPeter Maydell
Use the safe_syscall wrapper for sigsuspend syscalls. This means that we will definitely deliver a signal that arrives before we do the sigsuspend call, rather than blocking first and delivering afterwards. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Define macro for size of host kernel sigset_tPeter Maydell
Some host syscalls take an argument specifying the size of a host kernel's sigset_t (which isn't necessarily the same as that of the host libc's type of that name). Instead of hardcoding _NSIG / 8 where we do this, define and use a SIGSET_T_SIZE macro. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Factor out uses of do_sigprocmask() from sigreturn codePeter Maydell
All the architecture specific handlers for sigreturn include calls to do_sigprocmask(SIGSETMASK, &set, NULL) to set the signal mask from the uc_sigmask in the context being restored. Factor these out into calls to a set_sigmask() function. The next patch will want to add code which is not run when setting the signal mask via do_sigreturn, and this change allows us to separate the two cases. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Fix stray tab-indentPeter Maydell
Fix a stray tab-indented linux in linux-user/signal.c. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Move handle_pending_signal() to avoid need for declarationPeter Maydell
Move the handle_pending_signal() function above process_pending_signals() to avoid the need for a forward declaration. (Whitespace only change.) Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: Factor out handle_signal code from process_pending_signals()Peter Maydell
Factor out the code to handle a single signal from the process_pending_signals() function. The use of goto for flow control is OK currently, but would get significantly uglier if extended to allow running the handle_signal code multiple times. Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07Makefile: Derive "PKGVERSION" from "git describe" by defaultFam Zheng
Currently, if not specified in "./configure", QEMU_PKGVERSION will be empty. Write a rule in Makefile to generate a value from "git describe" combined with a possible git tree cleanness suffix, and write into a new header. $ cat qemu-version.h #define QEMU_PKGVERSION "-v2.6.0-557-gd6550e9-dirty" Include the header in .c files where the macro is referenced. It's not necessary to include it in all files, otherwise each time the content of the file changes, all sources have to be recompiled. Signed-off-by: Fam Zheng <famz@redhat.com> Message-Id: <1464774261-648-3-git-send-email-famz@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2016-06-07linux-user: check if NETLINK_ROUTE is availableLaurent Vivier
Some IFLA_* symbols can be missing in the host linux/if_link.h, but as they are enums and not "#defines", check in "configure" if last known (IFLA_PROTO_DOWN) is available and if not, disable management of NETLINK_ROUTE protocol. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: add netlink auditLaurent Vivier
This is, for instance, needed to log in a container. Without this, the user cannot be identified and the console login fails with "Login incorrect". Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: support netlink protocol NETLINK_KOBJECT_UEVENTLaurent Vivier
This is the protocol used by udevd to manage kernel events. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-06-07linux-user: add rtnetlink(7) supportLaurent Vivier
rtnetlink is needed to use iproute package (ip addr, ip route) and dhcp client. Examples: Without this patch: # ip link Cannot open netlink socket: Address family not supported by protocol # ip addr Cannot open netlink socket: Address family not supported by protocol # ip route Cannot open netlink socket: Address family not supported by protocol # dhclient eth0 Cannot open netlink socket: Address family not supported by protocol Cannot open netlink socket: Address family not supported by protocol With this patch: # ip link 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT qlen 1000 link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff # ip addr show eth0 51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000 link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.122.197/24 brd 192.168.122.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::216:3eff:fe89:6bd7/64 scope link valid_lft forever preferred_lft forever # ip route default via 192.168.122.1 dev eth0 192.168.122.0/24 dev eth0 proto kernel scope link src 192.168.122.197 # ip addr flush eth0 # ip addr add 192.168.122.10 dev eth0 # ip addr show eth0 51: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP qlen 1000 link/ether 00:16:3e:89:6b:d7 brd ff:ff:ff:ff:ff:ff inet 192.168.122.10/32 scope global eth0 valid_lft forever preferred_lft forever # ip route add 192.168.122.0/24 via 192.168.122.10 # ip route 192.168.122.0/24 via 192.168.122.10 dev eth0 Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-05-27linux-user,target-ppc: fix use of MSR_LELaurent Vivier
setup_frame()/setup_rt_frame()/restore_user_regs() are using MSR_LE as the similar kernel functions do: as a bitmask. But in QEMU, MSR_LE is a bit position, so change this accordingly. The previous code was doing nothing as MSR_LE is 0, and "env->msr &= ~MSR_LE" doesn't change the value of msr. And yes, a user process can change its endianness, see linux kernel commit: fab5db9 [PATCH] powerpc: Implement support for setting little-endian mode via prctl and prctl(2): PR_SET_ENDIAN, PR_GET_ENDIAN Reviewed-by: Thomas Huth <huth@tuxfamily.org> Signed-off-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-05-27linux-user/signal.c: Use s390 target space address instead of host spaceChen Gang
The return address is in target space, so the restorer address needs to be target space, too. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu>
2016-05-27linux-user/signal.c: Use target address instead of host address for ↵Chen Gang
microblaze restorer The return address is in target space, so the restorer address needs to be target space, too. Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org> Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>
2016-05-27linux-user/signal.c: Generate opcode data for restorer in setup_rt_frameChen Gang
Original implementation uses do_rt_sigreturn directly in host space, when a guest program is in unwind procedure in guest space, it will get an incorrect restore address, then causes unwind failure. Also cleanup the original incorrect indentation. Reviewed-by: Laurent Vivier <laurent@vivier.eu> Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com> Signed-off-by: Riku Voipio <riku.voipio@linaro.org>