From patchwork Mon Dec 17 20:26:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Roman Bolshakov X-Patchwork-Id: 10734289 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4C1FD6C5 for ; Mon, 17 Dec 2018 20:44:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D8E22A13F for ; Mon, 17 Dec 2018 20:44:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2CCDF2A26A; Mon, 17 Dec 2018 20:44:23 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 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 mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B9DC02A13F for ; Mon, 17 Dec 2018 20:44:22 +0000 (UTC) Received: from localhost ([::1]:49452 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYzkU-0002oI-1a for patchwork-qemu-devel@patchwork.kernel.org; Mon, 17 Dec 2018 15:44:22 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gYzhi-000066-MX for qemu-devel@nongnu.org; Mon, 17 Dec 2018 15:41:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gYzTj-0005Oo-VS for qemu-devel@nongnu.org; Mon, 17 Dec 2018 15:27:04 -0500 Received: from mta-01.yadro.com ([89.207.88.251]:45328) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gYzTj-0005Nh-NY for qemu-devel@nongnu.org; Mon, 17 Dec 2018 15:27:03 -0500 Received: from localhost (unknown [127.0.0.1]) by mta-01.yadro.com (Postfix) with ESMTP id 860134193F for ; Mon, 17 Dec 2018 20:27:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=yadro.com; h= content-type:content-type:content-transfer-encoding:mime-version :references:in-reply-to:x-mailer:message-id:date:date:subject :subject:from:from:received:received:received; s=mta-01; t= 1545078421; x=1546892822; bh=6AWDkfgSow1jy/x/NVlX5+KLFCuI+251+U6 GSGwadc4=; b=tufMtSlDM382y59wVu+/Mq2CWS/w+SJ1eB+t5ffpfg1A4fJkIPm eCXpRQagzRe2VY5omV4mvj8JNm8BAEzV4pp5Vp73cXZ3TbgMBJGatHnTANxPwQDe GwuiRh7wi2f4GGmjcvUhnM7YNbkZg6MZjwa+iiux9WTom0CyonaOfASg= X-Virus-Scanned: amavisd-new at yadro.com Received: from mta-01.yadro.com ([127.0.0.1]) by localhost (mta-01.yadro.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id a3n8KS8GPGQO for ; Mon, 17 Dec 2018 23:27:01 +0300 (MSK) Received: from T-EXCH-02.corp.yadro.com (t-exch-02.corp.yadro.com [172.17.10.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mta-01.yadro.com (Postfix) with ESMTPS id AEC8C4193A for ; Mon, 17 Dec 2018 23:27:01 +0300 (MSK) Received: from localhost (172.17.1.6) by T-EXCH-02.corp.yadro.com (172.17.10.102) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.669.32; Mon, 17 Dec 2018 23:27:01 +0300 From: Roman Bolshakov To: Date: Mon, 17 Dec 2018 23:26:02 +0300 Message-ID: <20181217202602.31113-3-r.bolshakov@yadro.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181217202602.31113-1-r.bolshakov@yadro.com> References: <20181217202602.31113-1-r.bolshakov@yadro.com> MIME-Version: 1.0 X-Originating-IP: [172.17.1.6] X-ClientProxiedBy: T-EXCH-01.corp.yadro.com (172.17.10.101) To T-EXCH-02.corp.yadro.com (172.17.10.102) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 89.207.88.251 Subject: [Qemu-devel] [RFC 2/2] qemu-thread: Don't block SEGV, ILL and FPE 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: Roman Bolshakov Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP If any of these signals happen on macOS, they are not delivered to other threads and signalfd_compat receives nothing. Indeed, POSIX reference and sigprocmask(2) note that an attempt to block the signals results in undefined behaviour. SEGV and FPE can't also be received by signalfd(2) on Linux. An ability to retrieve SIGBUS via signalfd(2) is used by QEMU for memory preallocation therefore we can't unblock it without consequences. But it's important to leave a remark that the signal is lost on macOS. Signed-off-by: Roman Bolshakov Reviewed-by: Daniel P. Berrangé --- util/qemu-thread-posix.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/util/qemu-thread-posix.c b/util/qemu-thread-posix.c index c6934bd22c..1bf5e65dea 100644 --- a/util/qemu-thread-posix.c +++ b/util/qemu-thread-posix.c @@ -524,6 +524,11 @@ void qemu_thread_create(QemuThread *thread, const char *name, /* Leave signal handling to the iothread. */ sigfillset(&set); + /* Blocking the signals can result in undefined behaviour. */ + sigdelset(&set, SIGSEGV); + sigdelset(&set, SIGFPE); + sigdelset(&set, SIGILL); + /* TODO avoid SIGBUS loss on macOS */ pthread_sigmask(SIG_SETMASK, &set, &oldset); qemu_thread_args = g_new0(QemuThreadArgs, 1);