As host signals are now blocked whenever guest signals are blocked, the queue of realtime signals in now in Linux. The Qemu queue is now redundant and removed.
Signed-off-by: Timothy Edward Baldwin <t.e.baldwi...@members.leeds.ac.uk> Conflicts: linux-user/qemu.h --- linux-user/main.c | 7 ------ linux-user/qemu.h | 11 +-------- linux-user/signal.c | 70 ++++++++++------------------------------------------- 3 files changed, 14 insertions(+), 74 deletions(-) diff --git a/linux-user/main.c b/linux-user/main.c index 349abe2..d86751a 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3474,14 +3474,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) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index f2235eb3..5f43692 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -82,16 +82,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 @@ -131,8 +124,6 @@ typedef struct TaskState { struct linux_binprm *bprm; struct emulated_sigtable sigtab[TARGET_NSIG]; - struct sigqueue sigqueue_table[MAX_SIGQUEUE_SIZE]; /* siginfo queue */ - struct sigqueue *first_free; /* first free siginfo queue entry */ sigset_t signal_mask; /* non zero if host signals blocked, bit 1 set if signal pending */ diff --git a/linux-user/signal.c b/linux-user/signal.c index f57dbf5..aa08c72 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -432,27 +432,6 @@ void signal_init(void) } } -/* signal queue handling */ - -static inline struct sigqueue *alloc_sigqueue(CPUArchState *env) -{ - CPUState *cpu = ENV_GET_CPU(env); - TaskState *ts = cpu->opaque; - struct sigqueue *q = ts->first_free; - if (!q) - return NULL; - ts->first_free = q->next; - return q; -} - -static inline void free_sigqueue(CPUArchState *env, struct sigqueue *q) -{ - CPUState *cpu = ENV_GET_CPU(env); - TaskState *ts = cpu->opaque; - - q->next = ts->first_free; - ts->first_free = q; -} /* abort execution with signal */ static void QEMU_NORETURN force_sig(int target_sig) @@ -513,7 +492,6 @@ int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) CPUState *cpu = ENV_GET_CPU(env); TaskState *ts = cpu->opaque; struct emulated_sigtable *k; - struct sigqueue *q, **pq; #if defined(DEBUG_SIGNAL) fprintf(stderr, "queue_signal: sig=%d\n", @@ -521,32 +499,16 @@ int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info) #endif k = &ts->sigtab[sig - 1]; - pq = &k->first; - if (sig < TARGET_SIGRTMIN) { - /* if non real time signal, we queue exactly one signal */ - if (!k->pending) - q = &k->info; - else - return 0; - } else { - if (!k->pending) { - /* first signal */ - q = &k->info; - } else { - q = alloc_sigqueue(env); - if (!q) - return -EAGAIN; - while (*pq != NULL) - pq = &(*pq)->next; - } - } - *pq = q; - q->info = *info; - q->next = NULL; - k->pending = 1; - /* signal that a new signal is pending */ - ts->signal_pending = 1; - return 1; /* indicates that the signal was queued */ + /* we queue exactly one signal */ + if (k->pending) { + return 0; + } + + k->info = *info; + k->pending = 1; + /* signal that a new signal is pending */ + ts->signal_pending = 1; + return 1; /* indicates that the signal was queued */ } #if defined(__x86_64__) @@ -5617,7 +5579,6 @@ void process_pending_signals(CPUArchState *cpu_env) target_sigset_t target_old_set; struct emulated_sigtable *k; struct target_sigaction *sa; - struct sigqueue *q; TaskState *ts = cpu->opaque; restart: @@ -5653,10 +5614,7 @@ restart: fprintf(stderr, "qemu: process signal %d\n", sig); #endif /* dequeue signal */ - q = k->first; - k->first = q->next; - if (!k->first) - k->pending = 0; + k->pending = 0; sig = gdb_handlesig(cpu, sig); if (!sig) { @@ -5715,18 +5673,16 @@ restart: /* prepare the stack frame of the virtual CPU */ #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) /* These targets do not have traditional signals. */ - setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); + setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); #else if (sa->sa_flags & TARGET_SA_SIGINFO) - setup_rt_frame(sig, sa, &q->info, &target_old_set, cpu_env); + setup_rt_frame(sig, sa, &k->info, &target_old_set, cpu_env); else setup_frame(sig, sa, &target_old_set, cpu_env); #endif if (sa->sa_flags & TARGET_SA_RESETHAND) sa->_sa_handler = TARGET_SIG_DFL; } - if (q != &k->info) - free_sigqueue(cpu_env, q); goto next_signal; } -- 2.1.4