From patchwork Wed Jun 8 13:29:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 632279 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rPqlZ2tH0z9sdb for ; Wed, 8 Jun 2016 23:58:18 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b=bEPWPXsD; dkim-atps=neutral Received: from localhost ([::1]:57155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdzs-0004p5-7h for incoming@patchwork.ozlabs.org; Wed, 08 Jun 2016 09:58:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36978) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZO-0004He-U1 for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:31:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bAdZG-0005k1-EO for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:52 -0400 Received: from mail-lf0-x22a.google.com ([2a00:1450:4010:c07::22a]:33634) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bAdZF-0005jq-Sj for qemu-devel@nongnu.org; Wed, 08 Jun 2016 09:30:46 -0400 Received: by mail-lf0-x22a.google.com with SMTP id s64so5900945lfe.0 for ; Wed, 08 Jun 2016 06:30:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cQeHaXQCbVFIovFIr+KyVIsmBft17mCZ7O5dOY/4rBI=; b=bEPWPXsDhIW/dzFUqQ/Hqo5pEhGkVhONUEmB79/KvcLx7tuFSbXqTuCgZhiBtBTUaf mOzpIXNjVJKizztTwJni+OYiyc45mKIIKymSIsGqHO0/QBwxjuG020wulu6l6SnfYDm/ HEgby7tOErLGbvKQz+whcuNAmpFjUvIsYch4U= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cQeHaXQCbVFIovFIr+KyVIsmBft17mCZ7O5dOY/4rBI=; b=d+AUK34qDHws6pYuKhaFLiQXNOO2/nYBJU+kIrINTfGBLrh3WBX72fsian8qbaMC8E n05o/zxVOlJF15RVwzVnWbyGb1twTsoMR65daV3opv/CI/p6XVN3AZbvSNtbLWLnadfS WaqhHqWmRxVdzL1I+3LZW4Bvl2kv73r9HPTdWYnBJ1DVlT8bY6ZJEk2oG3rkmWzi5KF2 cqhPBaqMPy6Dvcwj+J7fsj2YFp79xO6bXhh6fGNAtAcm+hp12U+/Z+0l4wVeLFc7Qsx6 1MCrLT2Tap2Coq2oS9wmMIwG6kyb98qUOHLz7hl7ZG4LoFjyqw3P6DJqr3dnuYkdlHto USFQ== X-Gm-Message-State: ALyK8tK2fL+aah2Bud30pEOaoaj/anDBNCVqA0ug2ydahXxHCGj4LvIx12wB/DJ7gPr8n3Wf X-Received: by 10.25.125.70 with SMTP id y67mr3024474lfc.75.1465392645014; Wed, 08 Jun 2016 06:30:45 -0700 (PDT) Received: from beaming.home (91-157-170-157.elisa-laajakaista.fi. [91.157.170.157]) by smtp.gmail.com with ESMTPSA id 2sm139854lja.37.2016.06.08.06.30.44 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 08 Jun 2016 06:30:44 -0700 (PDT) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Wed, 8 Jun 2016 16:29:56 +0300 Message-Id: <907f5fddaa673ac3f6dc955df6eac2870e3603f4.1465392530.git.riku.voipio@linaro.org> X-Mailer: git-send-email 2.1.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2a00:1450:4010:c07::22a Subject: [Qemu-devel] [PULL 15/44] linux-user: Remove real-time signal queuing X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Timothy E Baldwin Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Timothy 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 Message-id: 1441497448-32489-23-git-send-email-T.E.Baldwin99@members.leeds.ac.uk Reviewed-by: Peter Maydell [PMM: minor commit message tweak] Signed-off-by: Peter Maydell Signed-off-by: Riku Voipio --- 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 b2bc6ab..b6da0ba 100644 --- a/linux-user/main.c +++ b/linux-user/main.c @@ -3794,14 +3794,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 5138289..b201f90 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -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 @@ -127,8 +120,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 */ /* 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 diff --git a/linux-user/signal.c b/linux-user/signal.c index 2c6790d..5db1c0b 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -441,27 +441,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) @@ -524,37 +503,20 @@ 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; trace_user_queue_signal(env, sig); 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 */ - atomic_set(&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 */ + atomic_set(&ts->signal_pending, 1); + return 1; /* indicates that the signal was queued */ } #ifndef HAVE_SAFE_SYSCALL @@ -5783,16 +5745,12 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig) sigset_t set; target_sigset_t target_old_set; struct target_sigaction *sa; - struct sigqueue *q; TaskState *ts = cpu->opaque; struct emulated_sigtable *k = &ts->sigtab[sig - 1]; trace_user_handle_signal(cpu_env, sig); /* 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) { @@ -5857,10 +5815,10 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig) #if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) \ || defined(TARGET_OPENRISC) || defined(TARGET_TILEGX) /* 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 @@ -5868,8 +5826,6 @@ static void handle_pending_signal(CPUArchState *cpu_env, int sig) sa->_sa_handler = TARGET_SIG_DFL; } } - if (q != &k->info) - free_sigqueue(cpu_env, q); } void process_pending_signals(CPUArchState *cpu_env)