From patchwork Wed Jun 28 09:04:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?WmhvdSBRaWFvKOWRqOS+qCk=?= X-Patchwork-Id: 9813809 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E4D3060365 for ; Wed, 28 Jun 2017 09:21:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47A4E27F88 for ; Wed, 28 Jun 2017 09:21:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C4192838B; Wed, 28 Jun 2017 09:21:09 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B3A9A27F88 for ; Wed, 28 Jun 2017 09:21:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=JtcDkBcDruth2I2QM6Wi4pGwkCva3aj6XigfkjTz76o=; b=SlYAVRlF7EWPvD R2oyA39mpECUtWdYofjdFx5Hsaw+iYTxQY/KUxozVHZEEayKVBmf8i4jG+FLjGB9a2CXCYTCoXP5c wuRrZVpQltKZHKDdf9EI/aL+XkNdePt91710ZqmuqZ52A9rCnduA8NaFSugdq8dli2Vm/tJBzki0C ORUitdd6CqBtxHfDBkB3JGeewrR2nbw466gqzoNf7Qcj3lz92+GK6p35iB5WceTJ1YRWmIO8nFioF ZWjHNL5jpDIfe+ksRWsHabnMFXptz7iF0gqYRZMarzhasrchaIHIAgEjdcOrT9zqzDp06MUItAtnH ulisX/4VxEzr01/XFRIg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dQ99m-000699-BY; Wed, 28 Jun 2017 09:21:06 +0000 Received: from [140.206.112.106] (helo=mail2012.asrmicro.com) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dQ99i-00067R-T7 for linux-arm-kernel@lists.infradead.org; Wed, 28 Jun 2017 09:21:05 +0000 Received: from localhost (10.1.50.16) by mail2012.asrmicro.com (10.1.24.123) with Microsoft SMTP Server (TLS) id 15.0.847.32; Wed, 28 Jun 2017 17:04:14 +0800 From: Qiao Zhou To: , , , , , , , , , Subject: [PATCH] arm64: traps: disable irq in die() Date: Wed, 28 Jun 2017 17:04:12 +0800 Message-ID: <1498640652-23338-2-git-send-email-qiaozhou@asrmicro.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1498640652-23338-1-git-send-email-qiaozhou@asrmicro.com> References: <1498640652-23338-1-git-send-email-qiaozhou@asrmicro.com> MIME-Version: 1.0 X-Originating-IP: [10.1.50.16] X-ClientProxiedBy: mail2012.asrmicro.com (10.1.24.123) To mail2012.asrmicro.com (10.1.24.123) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170628_022103_136318_376E8D98 X-CRM114-Status: UNSURE ( 8.22 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Qiao Zhou Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP In current die(), the irq is disabled for __die() handle, not including the possible panic() handling. Since the log in __die() can take several hundreds ms, new irq might come and interrupt current die(). If the process calling die() holds some critical resource, and some other process scheduled later also needs it, then it would deadlock. The first panic will not be executed. So here disable irq for the whole flow of die(). Signed-off-by: Qiao Zhou --- arch/arm64/kernel/traps.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 0805b44..b12bf0f 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -274,10 +274,13 @@ static DEFINE_RAW_SPINLOCK(die_lock); void die(const char *str, struct pt_regs *regs, int err) { int ret; + unsigned long flags; + + local_irq_save(flags); oops_enter(); - raw_spin_lock_irq(&die_lock); + raw_spin_lock(&die_lock); console_verbose(); bust_spinlocks(1); ret = __die(str, err, regs); @@ -287,13 +290,16 @@ void die(const char *str, struct pt_regs *regs, int err) bust_spinlocks(0); add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); - raw_spin_unlock_irq(&die_lock); + raw_spin_unlock(&die_lock); oops_exit(); if (in_interrupt()) panic("Fatal exception in interrupt"); if (panic_on_oops) panic("Fatal exception"); + + local_irq_restore(flags); + if (ret != NOTIFY_STOP) do_exit(SIGSEGV); }