Received: by 10.223.185.111 with SMTP id b44csp540851wrg; Fri, 9 Mar 2018 09:06:35 -0800 (PST) X-Google-Smtp-Source: AG47ELsLJLZixyHSWSU3aAP/UKtyHh6BlpYi1L4W/e0PZKGfR5kOmWOZ3hTFTuNffECLPEW4Vq4O X-Received: by 10.98.155.194 with SMTP id e63mr30487469pfk.95.1520615195663; Fri, 09 Mar 2018 09:06:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520615195; cv=none; d=google.com; s=arc-20160816; b=JFYcyVOr0Ss0dIz18bg5HpLc9JUewBpztBmQnscg1GkyAc0ll1PiSEK6VSaBbUs5sJ wddxBj+nbtYn5wsbldUWyFme55tI+UXS3sm7L2nSUTKNIOh93YqvILaZpedaLdhzlG0d yEnHuy523pNCh+dLZRS0EFxS8JcZPxqCda9dK7WYCNj6Ns4JQV1hkzc/+vDsdgjhuzDE C6t+m5wR4ONughsolnsSsBn4zgsPsFnQsSA0mCnpKafnpMWGx0/PzZVsZD4XSexWntOp U4ebGjzdmLUY14brGMPciW8qg97lUlQJSgzY1Jg/3VVBHLj1FX49keBc5hwFDKejHlca h0lg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:organization:from:references:cc:to:subject :arc-authentication-results; bh=usGhvHPXgIjqOMsGfy0C46gXjZssztqO28AFxetd1lg=; b=s5S6Gg4D4WCzHjAGWdxgVul9VWgsv+mEJH32O48ZpYwWtlBNlMLolzHcJ0NJLD3m9h fBsA3s8PsKoDvvqtwVZHrVQMy0aKNjei3g3jDh8RhxpalCE6dreKVxNEijuylUO4je9l yLLCkw8CnXxAetYARu4Wem78qpU+lgM5Ge4Iy33XRLABVf3lUtG9RPEcfBzesmfIW+44 d/c6PBNGkqrWSTtAqTHieJCVVsDkc1Hsqbq8yU+1zKxHT+2jreB7E9DfTSanP6pmibsW TOb849d21AOVLtIdzJvRhDQEdeCm+r/bmAPs4c1N1emL2ksIMv3K62kRdMznB9ejZvqP G3eg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f3-v6si1217164plm.169.2018.03.09.09.06.21; Fri, 09 Mar 2018 09:06:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932238AbeCIRFO (ORCPT + 99 others); Fri, 9 Mar 2018 12:05:14 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:55312 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751192AbeCIRFN (ORCPT ); Fri, 9 Mar 2018 12:05:13 -0500 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 D4F6A1529; Fri, 9 Mar 2018 09:05:12 -0800 (PST) Received: from [10.1.207.62] (usa-sjc-imap-foss1.foss.arm.com [10.72.51.249]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 043703F487; Fri, 9 Mar 2018 09:05:10 -0800 (PST) Subject: Re: [PATCH] arm64: kdump: fix interrupt handling done during machine_crash_shutdown To: Grzegorz Jaszczyk Cc: Mark Rutland , catalin.marinas@arm.com, will.deacon@arm.com, james.morse@arm.com, "AKASHI, Takahiro" , Hoeun Ryu , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Nadav Haklai , Marcin Wojtas References: <1519837260-30662-1-git-send-email-jaz@semihalf.com> <20180228171647.6t4dabntujcb5kon@lakrids.cambridge.arm.com> <9a709b76-1b45-8250-9d8e-adbad59a43cc@arm.com> From: Marc Zyngier Organization: ARM Ltd Message-ID: <6805008a-b1cd-b8f7-66cc-1e61beef98a5@arm.com> Date: Fri, 9 Mar 2018 17:05:09 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 09/03/18 10:33, Grzegorz Jaszczyk wrote: >> Not using EOImode==1 is definitely an oddity (at least on the host), but >> that doesn't mean it shouldn't work. >> >> The reason the thing is hanging is that although we correctly deactivate >> the interrupt, nothing performs the priority drop. Your write to EOI >> helps in the sense that it guarantees that both priority drop and >> deactivate are done with the same operation, but that's not something >> we'd want to expose. >> >> My preferred approach would be to nuke the active priority registers at >> boot time, as the CPUs come up. I'll try to write something this week. > > I've made a PoC which performs priority drop at boot time as you > suggested and it works with both GICv2 and GICv3 but I see some > problem: > It seems that the only way to drop the priority is to perform write to > EOI register (the GIC_RPR is RO). According to GIC documentation a > write to EOI register must correspond to the most recent valid read > from IAR. The problem is that the interrupt was already acked in the > 'original' kernel, so reading GICC_IAR in crashdump kernel returns > spurious interrupt and it seems that there is no way to figure out > appropriate irqnr for EOI write. Nevertheless I've observed that > choosing random irqnr for EOI write works fine (maybe because all > interrupts in Linux uses the same priority?). > > Here is the PoC (not ready for submission only for further > discussion): https://pastebin.com/gLYNuRiZ > > Looking forward to your feedback. Well, the feedback is that this patch is really horrible, and choosing a random IRQ is at best hilarious. It also doesn't account for multiple priorities being active... In short, this is just fundamentally broken. I gave you a clue about the active priority registers. Why didn't you try that? Anyway, here's something that should fix it. M. From 6ace9d56c96203c4d11a23cbec6a6c216164bb88 Mon Sep 17 00:00:00 2001 From: Marc Zyngier Date: Fri, 9 Mar 2018 14:53:19 +0000 Subject: [PATCH] irqchip/gic-v2: Reset APRn registers at boot time Booting a crash kernel while in an interrupt handler is likely to leave the Active Priority Registers with some state that is not relevant to the new kernel, and is likely to lead to erratic behaviours such as interrupts not firing as their priority is already active. As a sanity measure, wipe the APRs clean on startup. Signed-off-by: Marc Zyngier --- drivers/irqchip/irq-gic.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-gic.c b/drivers/irqchip/irq-gic.c index 121af5cf688f..79801c24800b 100644 --- a/drivers/irqchip/irq-gic.c +++ b/drivers/irqchip/irq-gic.c @@ -453,15 +453,26 @@ static u8 gic_get_cpumask(struct gic_chip_data *gic) return mask; } +static bool gic_check_gicv2(void __iomem *base) +{ + u32 val = readl_relaxed(base + GIC_CPU_IDENT); + return (val & 0xff0fff) == 0x02043B; +} + static void gic_cpu_if_up(struct gic_chip_data *gic) { void __iomem *cpu_base = gic_data_cpu_base(gic); u32 bypass = 0; u32 mode = 0; + int i; if (gic == &gic_data[0] && static_key_true(&supports_deactivate)) mode = GIC_CPU_CTRL_EOImodeNS; + if (gic_check_gicv2(cpu_base)) + for (i = 0; i < 4; i++) + writel_relaxed(0, cpu_base + GIC_CPU_ACTIVEPRIO + i * 4); + /* * Preserve bypass disable bits to be written back later */ @@ -1264,12 +1275,6 @@ static int __init gicv2_force_probe_cfg(char *buf) } early_param("irqchip.gicv2_force_probe", gicv2_force_probe_cfg); -static bool gic_check_gicv2(void __iomem *base) -{ - u32 val = readl_relaxed(base + GIC_CPU_IDENT); - return (val & 0xff0fff) == 0x02043B; -} - static bool gic_check_eoimode(struct device_node *node, void __iomem **base) { struct resource cpuif_res; -- 2.14.2 -- Jazz is not dead. It just smells funny...