Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/riku/tags/pull-linux-user-20160…
Browse files Browse the repository at this point in the history
…608' 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 <[email protected]>"
# gpg:                 aka "Riku Voipio <[email protected]>"

* 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 <[email protected]>

Conflicts:
	configure
	scripts/qemu-binfmt-conf.sh
  • Loading branch information
pm215 committed Jun 8, 2016
2 parents 6f50f25 + 014628a commit b66e10e
Show file tree
Hide file tree
Showing 11 changed files with 1,700 additions and 520 deletions.
38 changes: 19 additions & 19 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -3800,8 +3800,8 @@ if compile_prog "" "" ; then
epoll=yes
fi

# epoll_create1 and epoll_pwait are later additions
# so we must check separately for their presence
# epoll_create1 is a later addition
# so we must check separately for its presence
epoll_create1=no
cat > $TMPC << EOF
#include <sys/epoll.h>
Expand All @@ -3823,20 +3823,6 @@ if compile_prog "" "" ; then
epoll_create1=yes
fi

epoll_pwait=no
cat > $TMPC << EOF
#include <sys/epoll.h>
int main(void)
{
epoll_pwait(0, 0, 0, 0, 0);
return 0;
}
EOF
if compile_prog "" "" ; then
epoll_pwait=yes
fi

# check for sendfile support
sendfile=no
cat > $TMPC << EOF
Expand Down Expand Up @@ -4528,6 +4514,19 @@ if compile_prog "" "" ; then
have_fsxattr=yes
fi

##########################################
# check if rtnetlink.h exists and is useful
have_rtnetlink=no
cat > $TMPC << EOF
#include <linux/rtnetlink.h>
int main(void) {
return IFLA_PROTO_DOWN;
}
EOF
if compile_prog "" "" ; then
have_rtnetlink=yes
fi

#################################################
# Sparc implicitly links with --relax, which is
# incompatible with -r, so --no-relax should be
Expand Down Expand Up @@ -5135,9 +5134,6 @@ fi
if test "$epoll_create1" = "yes" ; then
echo "CONFIG_EPOLL_CREATE1=y" >> $config_host_mak
fi
if test "$epoll_pwait" = "yes" ; then
echo "CONFIG_EPOLL_PWAIT=y" >> $config_host_mak
fi
if test "$sendfile" = "yes" ; then
echo "CONFIG_SENDFILE=y" >> $config_host_mak
fi
Expand Down Expand Up @@ -5482,6 +5478,10 @@ if test "$rdma" = "yes" ; then
echo "CONFIG_RDMA=y" >> $config_host_mak
fi

if test "$have_rtnetlink" = "yes" ; then
echo "CONFIG_RTNETLINK=y" >> $config_host_mak
fi

# Hold two types of flag:
# CONFIG_THREAD_SETNAME_BYTHREAD - we've got a way of setting the name on
# a thread we have a handle to
Expand Down
13 changes: 0 additions & 13 deletions gdbstub.c
Original file line number Diff line number Diff line change
Expand Up @@ -1493,19 +1493,6 @@ void gdb_exit(CPUArchState *env, int code)
}

#ifdef CONFIG_USER_ONLY
int
gdb_queuesig (void)
{
GDBState *s;

s = gdbserver_state;

if (gdbserver_fd < 0 || s->fd < 0)
return 0;
else
return 1;
}

int
gdb_handlesig(CPUState *cpu, int sig)
{
Expand Down
1 change: 0 additions & 1 deletion include/exec/gdbstub.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ int use_gdb_syscalls(void);
void gdb_set_stop_cpu(CPUState *cpu);
void gdb_exit(CPUArchState *, int);
#ifdef CONFIG_USER_ONLY
int gdb_queuesig (void);
int gdb_handlesig(CPUState *, int);
void gdb_signalled(CPUArchState *, int);
void gdbserver_fork(CPUState *);
Expand Down
10 changes: 10 additions & 0 deletions linux-user/host/x86_64/safe-syscall.inc.S
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,16 @@
* -1-and-errno-set convention is done by the calling wrapper.
*/
safe_syscall_base:
.cfi_startproc
/* This saves a frame pointer and aligns the stack for the syscall.
* (It's unclear if the syscall ABI has the same stack alignment
* requirements as the userspace function call ABI, but better safe than
* sorry. Appendix A2 of http://www.x86-64.org/documentation/abi.pdf
* does not list any ABI differences regarding stack alignment.)
*/
push %rbp
.cfi_adjust_cfa_offset 8
.cfi_rel_offset rbp, 0

/* The syscall calling convention isn't the same as the
* C one:
Expand Down Expand Up @@ -70,12 +73,19 @@ safe_syscall_start:
safe_syscall_end:
/* code path for having successfully executed the syscall */
pop %rbp
.cfi_remember_state
.cfi_def_cfa_offset 8
.cfi_restore rbp
ret

return_ERESTARTSYS:
/* code path when we didn't execute the syscall */
.cfi_restore_state
mov $-TARGET_ERESTARTSYS, %rax
pop %rbp
.cfi_def_cfa_offset 8
.cfi_restore rbp
ret
.cfi_endproc

.size safe_syscall_base, .-safe_syscall_base
9 changes: 1 addition & 8 deletions linux-user/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ void fork_end(int child)
Discard information about the parent threads. */
CPU_FOREACH_SAFE(cpu, next_cpu) {
if (cpu != thread_cpu) {
QTAILQ_REMOVE(&cpus, thread_cpu, node);
QTAILQ_REMOVE(&cpus, cpu, node);
}
}
pending_cpus = 0;
Expand Down Expand Up @@ -3795,14 +3795,7 @@ void stop_all_tasks(void)
/* Assumes contents are already zeroed. */
void init_task_state(TaskState *ts)
{
int i;

ts->used = 1;
ts->first_free = ts->sigqueue_table;
for (i = 0; i < MAX_SIGQUEUE_SIZE - 1; i++) {
ts->sigqueue_table[i].next = &ts->sigqueue_table[i + 1];
}
ts->sigqueue_table[i].next = NULL;
}

CPUArchState *cpu_copy(CPUArchState *env)
Expand Down
64 changes: 51 additions & 13 deletions linux-user/qemu.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,9 @@ struct vm86_saved_state {

#define MAX_SIGQUEUE_SIZE 1024

struct sigqueue {
struct sigqueue *next;
target_siginfo_t info;
};

struct emulated_sigtable {
int pending; /* true if signal is pending */
struct sigqueue *first;
struct sigqueue info; /* in order to always have memory for the
first signal, we put it here */
target_siginfo_t info;
};

/* NOTE: we force a big alignment so that the stack stored after is
Expand Down Expand Up @@ -123,14 +116,32 @@ typedef struct TaskState {
#endif
uint32_t stack_base;
int used; /* non zero if used */
bool sigsegv_blocked; /* SIGSEGV blocked by guest */
struct image_info *info;
struct linux_binprm *bprm;

struct emulated_sigtable sync_signal;
struct emulated_sigtable sigtab[TARGET_NSIG];
struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */
struct sigqueue *first_free; /* first free siginfo queue entry */
int signal_pending; /* non zero if a signal may be pending */
/* This thread's signal mask, as requested by the guest program.
* The actual signal mask of this thread may differ:
* + we don't let SIGSEGV and SIGBUS be blocked while running guest code
* + sometimes we block all signals to avoid races
*/
sigset_t signal_mask;
/* The signal mask imposed by a guest sigsuspend syscall, if we are
* currently in the middle of such a syscall
*/
sigset_t sigsuspend_mask;
/* Nonzero if we're leaving a sigsuspend and sigsuspend_mask is valid. */
int in_sigsuspend;

/* Nonzero if process_pending_signals() needs to do something (either
* handle a pending signal or unblock signals).
* This flag is written from a signal handler so should be accessed via
* the atomic_read() and atomic_write() functions. (It is not accessed
* from multiple threads.)
*/
int signal_pending;

} __attribute__((aligned(16))) TaskState;

extern char *exec_path;
Expand Down Expand Up @@ -184,7 +195,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
extern THREAD CPUState *thread_cpu;
void cpu_loop(CPUArchState *env);
char *target_strerror(int err);
const char *target_strerror(int err);
int get_osversion(void);
void init_qemu_uname_release(void);
void fork_start(void);
Expand Down Expand Up @@ -235,6 +246,12 @@ unsigned long init_guest_space(unsigned long host_start,
* It's also OK to implement these with safe_syscall, though it will be
* a little less efficient if a signal is delivered at the 'wrong' moment.
*
* Some non-interruptible syscalls need to be handled using block_signals()
* to block signals for the duration of the syscall. This mainly applies
* to code which needs to modify the data structures used by the
* host_signal_handler() function and the functions it calls, including
* all syscalls which change the thread's signal mask.
*
* (2) Interruptible syscalls
*
* These are guest syscalls that can be interrupted by signals and
Expand Down Expand Up @@ -266,6 +283,8 @@ unsigned long init_guest_space(unsigned long host_start,
* you make in the implementation returns either -TARGET_ERESTARTSYS or
* EINTR though.)
*
* block_signals() cannot be used for interruptible syscalls.
*
*
* How and why the safe_syscall implementation works:
*
Expand Down Expand Up @@ -352,6 +371,25 @@ long do_sigreturn(CPUArchState *env);
long do_rt_sigreturn(CPUArchState *env);
abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
/**
* block_signals: block all signals while handling this guest syscall
*
* Block all signals, and arrange that the signal mask is returned to
* its correct value for the guest before we resume execution of guest code.
* If this function returns non-zero, then the caller should immediately
* return -TARGET_ERESTARTSYS to the main loop, which will take the pending
* signal and restart execution of the syscall.
* If block_signals() returns zero, then the caller can continue with
* emulation of the system call knowing that no signals can be taken
* (and therefore that no race conditions will result).
* This should only be called once, because if it is called a second time
* it will always return non-zero. (Think of it like a mutex that can't
* be recursively locked.)
* Signals will be unblocked again by process_pending_signals().
*
* Return value: non-zero if there was a pending signal, zero if not.
*/
int block_signals(void); /* Returns non zero if signal pending */

#ifdef TARGET_I386
/* vm86.c */
Expand Down
Loading

0 comments on commit b66e10e

Please sign in to comment.