From patchwork Sat Sep 29 16:11:25 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Barcelo X-Patchwork-Id: 188036 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)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id A0E152C00E1 for ; Sun, 30 Sep 2012 02:12:16 +1000 (EST) Received: from localhost ([::1]:33252 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THzeI-00035K-MD for incoming@patchwork.ozlabs.org; Sat, 29 Sep 2012 12:12:14 -0400 Received: from eggs.gnu.org ([208.118.235.92]:59824) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THzds-000278-5a for qemu-devel@nongnu.org; Sat, 29 Sep 2012 12:11:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1THzdq-0008Ve-RL for qemu-devel@nongnu.org; Sat, 29 Sep 2012 12:11:48 -0400 Received: from mail-wi0-f175.google.com ([209.85.212.175]:43323) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1THzdq-0008VS-IR for qemu-devel@nongnu.org; Sat, 29 Sep 2012 12:11:46 -0400 Received: by mail-wi0-f175.google.com with SMTP id hq4so647956wib.10 for ; Sat, 29 Sep 2012 09:11:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=uPY9aV9v19i43MeK3HYOl/kRQMFR8a5fV3m5djalStY=; b=EhErL1LHtATo1Te44zvg9xvtsJi7SqmgWLwxwGycOPDMEN7AuJLqMmzQRInoPy9DNT 1GMN7aL9jsrB7ZxhHtwaxqcGwLlBc05/02TwcQZD2a58zVVvKVowmzLscpL5VfrZYWgG zcKbJ/E3GTntSrMVpoNLBfGiF0kdWCVbffOF5gaz/uhbuBXHHe2XxsLcP/rHk3FaDhm9 VdSQddsAykPwvozR67Ge/mSx5cExNMUuXMy0O3hQVEsRX5a+NTOdDEfLdjQBQPo3JoXj Hfiuqn91lULS5u3MGnyQDaOE0CGLpwiH5lDOy+56zMqu4DzfGZYvkXpo1uRSGYXBLnnV gqKQ== Received: by 10.216.204.19 with SMTP id g19mr4762323weo.189.1348935105823; Sat, 29 Sep 2012 09:11:45 -0700 (PDT) Received: from localhost.localdomain (62.57.4.176.dyn.user.ono.com. [62.57.4.176]) by mx.google.com with ESMTPS id q4sm5798998wix.9.2012.09.29.09.11.44 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 29 Sep 2012 09:11:45 -0700 (PDT) From: Alex Barcelo To: Date: Sat, 29 Sep 2012 18:11:25 +0200 Message-Id: <1348935086-11336-2-git-send-email-abarcelo@ac.upc.edu> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1348935086-11336-1-git-send-email-abarcelo@ac.upc.edu> References: <1348935086-11336-1-git-send-email-abarcelo@ac.upc.edu> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.212.175 Cc: Riku Voipio , Alex Barcelo Subject: [Qemu-devel] [PATCH 1/2] signal: added a wrapper for sigprocmask function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org A transparent wrapper for sigprocmask function. Signed-off-by: line. --- linux-user/qemu.h | 1 + linux-user/signal.c | 8 ++++++++ linux-user/syscall.c | 20 ++++++++++---------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/linux-user/qemu.h b/linux-user/qemu.h index fc4cc00..e2dd6a6 100644 --- a/linux-user/qemu.h +++ b/linux-user/qemu.h @@ -237,6 +237,7 @@ int host_to_target_signal(int sig); 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); #ifdef TARGET_I386 /* vm86.c */ diff --git a/linux-user/signal.c b/linux-user/signal.c index 7869147..b8b8268 100644 --- a/linux-user/signal.c +++ b/linux-user/signal.c @@ -5463,6 +5463,14 @@ long do_rt_sigreturn(CPUArchState *env) #endif +/* Wrapper for sigprocmask function + * Emulates a sigprocmask in a safe way for the guest + */ +int do_sigprocmask(int how, const sigset_t *set, sigset_t *oldset) +{ + return sigprocmask(how, set, oldset); +} + void process_pending_signals(CPUArchState *cpu_env) { int sig; diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 471d060..1117bbe 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -4260,7 +4260,7 @@ static void *clone_func(void *arg) if (info->parent_tidptr) put_user_u32(info->tid, info->parent_tidptr); /* Enable signals. */ - sigprocmask(SIG_SETMASK, &info->sigmask, NULL); + do_sigprocmask(SIG_SETMASK, &info->sigmask, NULL); /* Signal to the parent that we're ready. */ pthread_mutex_lock(&info->mutex); pthread_cond_broadcast(&info->cond); @@ -4351,12 +4351,12 @@ static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp, /* It is not safe to deliver signals until the child has finished initializing, so temporarily block all signals. */ sigfillset(&sigmask); - sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); + do_sigprocmask(SIG_BLOCK, &sigmask, &info.sigmask); ret = pthread_create(&info.thread, &attr, clone_func, &info); /* TODO: Free new CPU state if thread creation failed. */ - sigprocmask(SIG_SETMASK, &info.sigmask, NULL); + do_sigprocmask(SIG_SETMASK, &info.sigmask, NULL); pthread_attr_destroy(&attr); if (ret == 0) { /* Wait for the child to initialize. */ @@ -5875,7 +5875,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { sigset_t cur_set; abi_ulong target_set; - sigprocmask(0, NULL, &cur_set); + do_sigprocmask(0, NULL, &cur_set); host_to_target_old_sigset(&target_set, &cur_set); ret = target_set; } @@ -5886,10 +5886,10 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, { sigset_t set, oset, cur_set; abi_ulong target_set = arg1; - sigprocmask(0, NULL, &cur_set); + do_sigprocmask(0, NULL, &cur_set); target_to_host_old_sigset(&set, &target_set); sigorset(&set, &set, &cur_set); - sigprocmask(SIG_SETMASK, &set, &oset); + do_sigprocmask(SIG_SETMASK, &set, &oset); host_to_target_old_sigset(&target_set, &oset); ret = target_set; } @@ -5920,7 +5920,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, mask = arg2; target_to_host_old_sigset(&set, &mask); - ret = get_errno(sigprocmask(how, &set, &oldset)); + ret = get_errno(do_sigprocmask(how, &set, &oldset)); if (!is_error(ret)) { host_to_target_old_sigset(&mask, &oldset); ret = mask; @@ -5954,7 +5954,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, how = 0; set_ptr = NULL; } - ret = get_errno(sigprocmask(how, set_ptr, &oldset)); + ret = get_errno(do_sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; @@ -5994,7 +5994,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, how = 0; set_ptr = NULL; } - ret = get_errno(sigprocmask(how, set_ptr, &oldset)); + ret = get_errno(do_sigprocmask(how, set_ptr, &oldset)); if (!is_error(ret) && arg3) { if (!(p = lock_user(VERIFY_WRITE, arg3, sizeof(target_sigset_t), 0))) goto efault; @@ -7870,7 +7870,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, } mask = arg2; target_to_host_old_sigset(&set, &mask); - sigprocmask(how, &set, &oldset); + do_sigprocmask(how, &set, &oldset); host_to_target_old_sigset(&mask, &oldset); ret = mask; }