Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753185AbdGUHjL (ORCPT ); Fri, 21 Jul 2017 03:39:11 -0400 Received: from [140.206.112.106] ([140.206.112.106]:12601 "EHLO mail2012.asrmicro.com" rhost-flags-FAIL-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752009AbdGUHjJ (ORCPT ); Fri, 21 Jul 2017 03:39:09 -0400 From: =?gb2312?B?WmhvdSBRaWFvKNbcx8gp?= To: "catalin.marinas@arm.com" , "will.deacon@arm.com" , "mark.rutland@arm.com" , "suzuki.poulose@arm.com" , "mingo@kernel.org" , "marc.zyngier@arm.com" , "andre.przywara@arm.com" , "linux-arm-kernel@lists.infradead.org" , "linux-kernel@vger.kernel.org" Subject: RE: [PATCH V2] arm64: traps: disable irq in die() Thread-Topic: [PATCH V2] arm64: traps: disable irq in die() Thread-Index: AQHS9wOMK/uqHG+g506WCSWhdH3hlaJd+erw Date: Fri, 21 Jul 2017 07:38:42 +0000 Message-ID: References: <1499419774-14563-1-git-send-email-qiaozhou@asrmicro.com> In-Reply-To: <1499419774-14563-1-git-send-email-qiaozhou@asrmicro.com> Accept-Language: en-US, zh-CN Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.1.50.34] Content-Type: text/plain; charset="gb2312" MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id v6L7dHDA023506 Content-Length: 1982 Lines: 61 Hi Maintainers, Could you please help to take a look and give some comments? Thanks in advance. Best Regards Qiao -----Original Message----- From: Zhou Qiao Sent: Friday, July 07, 2017 5:30 PM To: catalin.marinas@arm.com; will.deacon@arm.com; mark.rutland@arm.com; suzuki.poulose@arm.com; mingo@kernel.org; marc.zyngier@arm.com; andre.przywara@arm.com; linux-arm-kernel@lists.infradead.org; linux-kernel@vger.kernel.org Cc: Zhou Qiao Subject: [PATCH V2] arm64: traps: disable irq in die() 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 | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/traps.c b/arch/arm64/kernel/traps.c index 0805b44..2e2ff88 100644 --- a/arch/arm64/kernel/traps.c +++ b/arch/arm64/kernel/traps.c @@ -274,10 +274,12 @@ static DEFINE_RAW_SPINLOCK(die_lock); void die(const char *str, struct pt_regs *regs, int err) { int ret; + unsigned long flags; + + raw_spin_lock_irqsave(&die_lock, flags); oops_enter(); - raw_spin_lock_irq(&die_lock); console_verbose(); bust_spinlocks(1); ret = __die(str, err, regs); @@ -287,13 +289,15 @@ 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); oops_exit(); if (in_interrupt()) panic("Fatal exception in interrupt"); if (panic_on_oops) panic("Fatal exception"); + + raw_spin_unlock_irqrestore(&die_lock, flags); + if (ret != NOTIFY_STOP) do_exit(SIGSEGV); } -- 2.7.4