Received: by 2002:a05:7412:da14:b0:e2:908c:2ebd with SMTP id fe20csp266137rdb; Fri, 6 Oct 2023 02:56:13 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmJOiTI/CR8zm4xUWtjp1V5jXFm8s2ydi5t2443FU/rmyU8nfQ7SC1JGttIaSLX/feZMtW X-Received: by 2002:a05:6870:c152:b0:1bf:607:e0f2 with SMTP id g18-20020a056870c15200b001bf0607e0f2mr8657691oad.29.1696586173171; Fri, 06 Oct 2023 02:56:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696586173; cv=none; d=google.com; s=arc-20160816; b=bBtiAXWoN+woQy4ssySvvSY0F0oJex3vqvDLFUNsv6LNl32/3cJP8qnxf78xhPP6SB Wcf0NtQ8P3XLM0bmVUS72SmixP3CMWtC+WO6ItuGOXzLpGw0p742FZnB2uvJil5706ta EWGzou4CJsV65zWHM//nDSHsyUvOGQclbM0UwHtX6xt2xM3rURgtkkNECD8Vt6N/uMDm TPdkBN5QoEPkYqz535lDhS86B9PvNfTY1uPIQxJhDCFrjDFGV45BXdPlp1CL8nfLemVa q0tFdlbNQEkdUks4SJH326WvU4EglfB8sSUUS7UixbNanMdqg+0FzrtNPk/60s5oE1sJ qdeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:in-reply-to :subject:cc:to:from:message-id:date:dkim-signature; bh=uiqOe8bO3vimd9E9hB9VhkoyXb7TNwrh3FYbqzFTWN4=; fh=EBVYPTm3Usg+GuiTX0VKF61uiKB6h+IFLLjfyItWAIQ=; b=gbdGhh4botQrQRuDuj1epQgsuhTLQ+246qnwPs0M1J6g+4LuBGu2JZENc90M+jjeh2 x+kSQ/uYdwkHgT9/vr8fkF5OzKUdMEdjdMy0xlc0oXC3jyieqaLS09XH0PUR2G5BqmsM Z5cIu1374qYoMWvIh5AznGNxmf8zbHbzzIxTBn+Z6wXs4ODcmz4wpem5HfbZxNtxTmSl rZnyu9TcgQ9FweAexkyyyKp/TnFWAcdZ4DRZtNmNkppy+C6DavQxv/FsbFOiQAMgi4JQ QJetdhhkOWhnn9Ba1AU4ZMXp7MowDF3Bfm1CWHh/iD8Bk6gmPypvrUrwBihQM4vgKG9M K7Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0b02o1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g3-20020a056a000b8300b00690c92a8defsi1213607pfj.206.2023.10.06.02.56.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 06 Oct 2023 02:56:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=l0b02o1Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id BA794818D520; Fri, 6 Oct 2023 02:56:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231548AbjJFJz5 (ORCPT + 99 others); Fri, 6 Oct 2023 05:55:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231478AbjJFJz4 (ORCPT ); Fri, 6 Oct 2023 05:55:56 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D6F29F for ; Fri, 6 Oct 2023 02:55:54 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9220C433C7; Fri, 6 Oct 2023 09:55:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696586153; bh=MSPT5qCyt9p9n6mF95tmGSpTSK04dAtYDhwOdjcnjY0=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=l0b02o1QiGt/FjcBvGj0i65cE3CC+ku/YW7MLg9y2DXZ/FwpEv1GqCeX/Ot4T4X96 F//MwEYim6Kig5fTMtW6AM5oYGYkuF3MNlfWyYmUlGGw74jci3KYy+FmlU+cnG4fyJ 0sfDEnQ3QkqcntO+vSVPQrQsNvmWyfR5TjiAyjnRwLIpvq5NBrzwoYEgga6vkj6DKU b3AHVl05/iSAYsPiwsVvg/PkMZxVH0fQy+opMWIqZW0gUvwAYZSTA/Sv+4M/IqdJ8O 6cWh6o9MxHJGXlsC9JfwhutdHxfkMcbESofPYVMfQh8I6UXolPmReBhRmYGeJdK0oB +TvjAn2CE4yuA== Received: from sofa.misterjones.org ([185.219.108.64] helo=goblin-girl.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1qohYk-001fhS-Sp; Fri, 06 Oct 2023 10:55:50 +0100 Date: Fri, 06 Oct 2023 10:55:49 +0100 Message-ID: <865y3knkgq.wl-maz@kernel.org> From: Marc Zyngier To: Mark Rutland Cc: Douglas Anderson , Catalin Marinas , Will Deacon , Stephen Boyd , Valentin Schneider , Chen-Yu Tsai , AngeloGioacchino Del Regno , D Scott Phillips , Josh Poimboeuf , Matthias Brugger , Misono Tomohiro , Peter Zijlstra , Sumit Garg , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH 1/2] arm64: smp: Fix pseudo NMI issues w/ broken Mediatek FW In-Reply-To: References: <20231002094526.1.Ie8f760213053e3d11592f892b30912dbac6b8b48@changeid> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/29.1 (aarch64-unknown-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=US-ASCII X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: mark.rutland@arm.com, dianders@chromium.org, catalin.marinas@arm.com, will@kernel.org, swboyd@chromium.org, vschneid@redhat.com, wenst@chromium.org, angelogioacchino.delregno@collabora.com, scott@os.amperecomputing.com, jpoimboe@kernel.org, matthias.bgg@gmail.com, misono.tomohiro@fujitsu.com, peterz@infradead.org, sumit.garg@linaro.org, tglx@linutronix.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-mediatek@lists.infradead.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Fri, 06 Oct 2023 02:56:10 -0700 (PDT) X-Spam-Level: ** On Mon, 02 Oct 2023 18:24:11 +0100, Mark Rutland wrote: > > On Mon, Oct 02, 2023 at 09:45:29AM -0700, Douglas Anderson wrote: > > Some mediatek devices have the property > > "mediatek,broken-save-restore-fw" in their GIC. This means that, > > although the hardware supports pseudo-NMI, the firmware has a bug > > that blocks enabling it. When we're in this state, > > system_uses_irq_prio_masking() will return true but we'll fail to > > actually enable the IRQ in the GIC. > > > > Let's make the code handle this. We'll detect that we failed to > > request an IPI as NMI and fallback to requesting it normally. Though > > we expect that either all of our requests will fail or all will > > succeed, it's just as cheap to keep a per-IPI bitmap and that keeps us > > robust. > > > > Fixes: 331a1b3a836c ("arm64: smp: Add arch support for backtrace using pseudo-NMI") > > Reported-by: Chen-Yu Tsai > > Closes: https://issuetracker.google.com/issues/197061987#comment68 > > Signed-off-by: Douglas Anderson > > --- > > > > arch/arm64/kernel/smp.c | 19 ++++++++++++------- > > 1 file changed, 12 insertions(+), 7 deletions(-) > > I'm not too keen on falling back here when we have no idea why the request failed. > > I'd prefer if we could check the `supports_pseudo_nmis` static key directly to > account for the case of broken FW, e.g. as below. > > Mark. > > ---->8---- > From 72fdec05c64a74f21871b44c7c760bbe07cac044 Mon Sep 17 00:00:00 2001 > From: Mark Rutland > Date: Mon, 2 Oct 2023 18:00:36 +0100 > Subject: [PATCH] arm64: smp: avoid NMI IPIs with broken MediaTek FW > > Some MediaTek devices have broken firmware which corrupts some GICR > registers behind the back of the OS, and pseudo-NMIs cannot be used on > these devices. For more details see commit: > > 44bd78dd2b8897f5 ("irqchip/gic-v3: Disable pseudo NMIs on Mediatek devices w/ firmware issues") > > We did not take this problem into account in commit: > > 331a1b3a836c0f38 ("arm64: smp: Add arch support for backtrace using pseudo-NMI") > > Since that commit arm64's SMP code will try to setup some IPIs as > pseudo-NMIs, even on systems with broken FW. The GICv3 code will > (rightly) reject attempts to request interrupts as pseudo-NMIs, > resulting in boot-time failures. > > Avoid the problem by taking the broken FW into account when deciding to > request IPIs as pseudo-NMIs. The GICv3 driver maintains a static_key > named "supports_pseudo_nmis" which is false on systems with broken FW, > and we can consult this within ipi_should_be_nmi(). > > Fixes: 331a1b3a836c0f38 ("arm64: smp: Add arch support for backtrace using pseudo-NMI") > Reported-by: Chen-Yu Tsai > Closes: https://issuetracker.google.com/issues/197061987#comment68 > Signed-off-by: Mark Rutland > Cc: Douglas Anderson > Cc: Marc Zyngier > --- > arch/arm64/kernel/smp.c | 5 ++++- > drivers/irqchip/irq-gic-v3.c | 2 +- > 2 files changed, 5 insertions(+), 2 deletions(-) > > diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c > index 814d9aa93b21b..061c69160f90f 100644 > --- a/arch/arm64/kernel/smp.c > +++ b/arch/arm64/kernel/smp.c > @@ -964,7 +964,10 @@ static void smp_cross_call(const struct cpumask *target, unsigned int ipinr) > > static bool ipi_should_be_nmi(enum ipi_msg_type ipi) > { > - if (!system_uses_irq_prio_masking()) > + DECLARE_STATIC_KEY_FALSE(supports_pseudo_nmis); > + > + if (!system_uses_irq_prio_masking() || > + !static_branch_likely(&supports_pseudo_nmis)) > return false; > > switch (ipi) { > diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c > index 787ccc880b22d..737da1b9aabf2 100644 > --- a/drivers/irqchip/irq-gic-v3.c > +++ b/drivers/irqchip/irq-gic-v3.c > @@ -106,7 +106,7 @@ static DEFINE_STATIC_KEY_TRUE(supports_deactivate_key); > * - Figure 4-7 Secure read of the priority field for a Non-secure Group 1 > * interrupt. > */ > -static DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis); > +DEFINE_STATIC_KEY_FALSE(supports_pseudo_nmis); > > DEFINE_STATIC_KEY_FALSE(gic_nonsecure_priorities); > EXPORT_SYMBOL(gic_nonsecure_priorities); This last hunk is going to result in more spam from the robots about global objects without a previous declaration. Not that I care the least, but worth mentioning. Other than that: Reviewed-by: Marc Zyngier Please take it via the arm64 tree with patch #1 Thanks, M. -- Without deviation from the norm, progress is not possible.