Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5265AC10F14 for ; Tue, 23 Apr 2019 07:55:24 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 17F8C20645 for ; Tue, 23 Apr 2019 07:55:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tDzD+vA5" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 17F8C20645 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org 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:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1FAPsfKPkNNO34817zQx6/HbrPgc9UIRwh6CWoI+sQY=; b=tDzD+vA5fUxPGf RQ+mPY60j4n4n7YAVMc8FpnfeqDG8TXF9Hav0fJnKVcYuo2YhEfU0XukDYdB4dUrSVhY2Yw5yW9Uu DLu22odSHe59+6+slfY82IUg3w2Z61PYD9fbcmcm9N6V54JQSPS8gE8hMgDTIfumnIF+qkax6EFlf l0TsEJtEEBzTqsRrWooXcoHGhy4l2xA4ftWUziCXuzamE4RCIrYjDR8DYP3O7XeGEGRvgkSyYMhTb L2MRsC5Ul4CGD2+g8c0wrfCbc37NtWWMkb/QvQ4rT+1goaQjLeGedchusd7EOzRdlYS1PWG63wREn F3FSDSvDI7yC5PSMIwLQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIqGs-0005lg-W4; Tue, 23 Apr 2019 07:55:18 +0000 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70] helo=foss.arm.com) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hIqGq-0005l5-9h for linux-arm-kernel@lists.infradead.org; Tue, 23 Apr 2019 07:55:17 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 57598374; Tue, 23 Apr 2019 00:55:14 -0700 (PDT) Received: from [10.1.197.45] (e112298-lin.cambridge.arm.com [10.1.197.45]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 82F423F706; Tue, 23 Apr 2019 00:55:12 -0700 (PDT) Subject: Re: [PATCH] arm64: fix kernel stack overflow in kdump capture kernel To: "liwei (GF)" , catalin.marinas@arm.com, will.deacon@arm.com References: <20190418140251.31218-1-liwei391@huawei.com> <401bab0b-88f6-02ea-c49d-08947a337244@arm.com> From: Julien Thierry Message-ID: <88eb9b9f-b573-029a-c55d-ede5f538d4b8@arm.com> Date: Tue, 23 Apr 2019 08:55:10 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190423_005516_368235_DA438EC1 X-CRM114-Status: GOOD ( 21.05 ) 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: mark.rutland@arm.com, daniel.thompson@linaro.org, marc.zyngier@arm.com, christoffer.dall@arm.com, james.morse@arm.com, joel@joelfernandes.org, linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 19/04/2019 09:56, liwei (GF) wrote: > Hi Julien, > > On 2019/4/18 22:26, Julien Thierry wrote: >> Hi Wei, >> >> On 18/04/2019 15:02, Wei Li wrote: >>> When enabling ARM64_PSEUDO_NMI feature in kdump capture kernel, it will >>> report a kernel stack overflow exception: >>> >>> [ 0.000000] CPU features: detected: IRQ priority masking >>> [ 0.000000] alternatives: patching kernel code >>> [ 0.000000] Insufficient stack space to handle exception! >>> [ 0.000000] ESR: 0x96000044 -- DABT (current EL) >>> [ 0.000000] FAR: 0x0000000000000040 >>> [ 0.000000] Task stack: [0xffff0000097f0000..0xffff0000097f4000] >>> [ 0.000000] IRQ stack: [0x0000000000000000..0x0000000000004000] >>> [ 0.000000] Overflow stack: [0xffff80002b7cf290..0xffff80002b7d0290] >>> [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 4.19.34-lw+ #3 >> >> Can you reproduce this on a recent kernel? >> > OK, i will try to reproduce this on 5.1.0-rc*. > >>> preempt_disable(); >>> trace_hardirqs_off(); >>> @@ -451,7 +451,7 @@ void __init smp_prepare_boot_cpu(void) >>> >>> /* Conditionally switch to GIC PMR for interrupt masking */ >>> if (system_uses_irq_prio_masking()) >>> - init_gic_priority_masking(); >>> + init_gic_priority_masking(false); >> >> The assumption is that PSR.A should be set at this point (the kernel is >> not more ready to take async exceptions than it is ready to take >> interrupts) and we shouldn't be unmasking PSR.I. > > I think the assumption here is not right, since PSR.A has been unmasked > in setup_arch() before smp_prepare_boot_cpu(). > Yes, you're right. Sorry, I got confused, the secondary CPUs do the init_gic_priority_masking() with PSR.A set and I had not realized how problematic it was to not have it set for the boot CPU. So, I think your patch is doing the right thing, but to keep it simple, I'd suggest not adding that boolean to init_gic_priority_masking(): - init_gic_priority_masking() only sets PMR to GIC_PRIO_IRQOFF, we don't alter the value of DAIF bits (we can keep the check that the I bit is set as we expect this on all CPUs). - In init IRQ, we can unmask PSR.I when system_uses_irq_prio_masking() returns true (maybe we can check this is only done on the boot CPU). I can prepare the patch and send it with the other fixes for PSEUDO_NMI I'm preparing. Thanks, -- Julien Thierry _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel