From patchwork Wed Apr 19 22:55:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13217685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 2BABAC77B73 for ; Thu, 20 Apr 2023 00:01:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=TKvfCArXVpPNXnlWKUMaDPJ5+n8HA7N1WOAA7BMLiw4=; b=34NeoO/M02c6do X/miMKBdo286VR/Xq5aiFA0sqnwi/rRZWbOd81G0fP5vr+9xLUJqDj74Lg/aU+X6TjwadxWHQiPts pxgRThBGJTjF9LEluMoUP5TbEysz/rIA+avhM9/Hfv6l+yE5A7JGcb3XBG+AmU9CE/xi8oMNA5SrJ tDZSh/7fy1lZMYjipcgM3tog9MPZ84toFE6zmYE6bM94TKXb6BYNP8w+c/qUVkYQ5kERmihBfgWAB G2xR+q61uvqo1Ae3dcJzO5j3+OKY+FnV+j77sTpshWD7lx3JFztjcKaWZbD/S1N6wcTbxQEEl/PDs q2JCLbaWkdFIWb6MCCAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppHj5-006gdN-31; Thu, 20 Apr 2023 00:00:39 +0000 Received: from mail-pj1-x102a.google.com ([2607:f8b0:4864:20::102a]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGji-006Yxd-0O for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 22:57:15 +0000 Received: by mail-pj1-x102a.google.com with SMTP id 98e67ed59e1d1-247526f0eceso213909a91.2 for ; Wed, 19 Apr 2023 15:57:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681945032; x=1684537032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=dpO6xBr8GRTIiZAwOhR7DhqHQGx50IOyRoOo/b42ur0=; b=kscE08GAAWK411hIe/AlrpkEs4LuqorOLSZXU62OFqZbcuwAzAR8cxaFEQzLrqNjma eIM4oARZaGkVYYFo7UShuM6mT3sodkflb5QAh7j0/+pCO1fujDsTYb6Cdq4h4L7LheLe LvW+QGq9VdNSHMlXNHrY28CT0AZxYFUZ4elQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945032; x=1684537032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dpO6xBr8GRTIiZAwOhR7DhqHQGx50IOyRoOo/b42ur0=; b=jyiMxR92y9+lK6erl0Es8cDTXSOBE3Oq3IheWMkMXH2fxSeKi0WHI3ldDmLDk9e9yy 2mslTTAYwAkh1pSP7Z6aIlLqvnCyOcRrBismYyDJ23Q199jqinySyUDWYR/lNqVvvkyu ei8Ot9wyITv1IRtqCPHJD1XChkfej4QxsMlapcb2LL+gRncaThlBY2qW+6BqHBIQTpN1 NRLuAg2jaccC/HWoXvdQQkXoizKbUbxLGSvOCOuwQNzCmuHcmDjxmBlriTfus2l1xxUT 23olsRm2HoDAD797LjqtzykKarjE92ql3lbbsHCoJuqVv+gvNSE5qzISI48lLkMxYshI bEHA== X-Gm-Message-State: AAQBX9fPFp11Evam3eR9Ez3DqeDQrnUr3Wxpf1b/TftXPUk/Ux9BZ+Pa QZV7bNNLrehSpSSU6dZAAUKvVQ== X-Google-Smtp-Source: AKy350aK5ae5EGORUG+NerzBv8kCtz8aZ4AMVRXzvnaMvPW39Dl9faoU7w/z73Q50CZOVchx5jXuaw== X-Received: by 2002:a17:90a:c297:b0:240:3dc7:4939 with SMTP id f23-20020a17090ac29700b002403dc74939mr4439076pjt.27.1681945032562; Wed, 19 Apr 2023 15:57:12 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8b1:fa03:670e:b784]) by smtp.gmail.com with ESMTPSA id h15-20020a17090aea8f00b00246ea338c96sm1847101pjz.53.2023.04.19.15.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:57:11 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier , Mark Rutland Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai , Masayoshi Mizuma , Peter Zijlstra , Ard Biesheuvel , "Rafael J . Wysocki" , linux-arm-kernel@lists.infradead.org, Stephen Boyd , Lecopzer Chen , Thomas Gleixner , linux-perf-users@vger.kernel.org, Masayoshi Mizuma , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v8 05/10] arm64: ipi_nmi: Add support for NMI backtrace Date: Wed, 19 Apr 2023 15:55:59 -0700 Message-ID: <20230419155341.v8.5.I65981105e1f62550b0316625dd1e599deaf9e1aa@changeid> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> References: <20230419225604.21204-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_155714_162246_6C957DAB X-CRM114-Status: GOOD ( 15.96 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Sumit Garg Enable NMI backtrace support on arm64 using IPI turned as an NMI leveraging pseudo NMIs support. It is now possible for users to get a backtrace of a CPU stuck in hard-lockup using magic SYSRQ. Signed-off-by: Sumit Garg Tested-by: Masayoshi Mizuma Tested-by: Chen-Yu Tsai Signed-off-by: Douglas Anderson --- Changes in v8: - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP arch/arm64/include/asm/irq.h | 4 ++++ arch/arm64/kernel/ipi_nmi.c | 18 ++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index fac08e18bcd5..dc35b9d23a81 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -6,6 +6,10 @@ #include +extern bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, + bool exclude_self); +#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace + struct pt_regs; int set_handle_irq(void (*handle_irq)(struct pt_regs *)); diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 712411eed949..c592e92b8cbf 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -31,11 +32,24 @@ void arm64_send_nmi(cpumask_t *mask) __ipi_send_mask(ipi_nmi_desc, mask); } +bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +{ + if (!ipi_nmi_desc) + return false; + + nmi_trigger_cpumask_backtrace(mask, exclude_self, arm64_send_nmi); + + return true; +} + static irqreturn_t ipi_nmi_handler(int irq, void *data) { - /* nop, NMI handlers for special features can be added here. */ + irqreturn_t ret = IRQ_NONE; + + if (nmi_cpu_backtrace(get_irq_regs())) + ret = IRQ_HANDLED; - return IRQ_NONE; + return ret; } void dynamic_ipi_setup(void)