From patchwork Wed Oct 14 11:12:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11837519 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 547CA921 for ; Wed, 14 Oct 2020 11:13:42 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (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 0BAEF207C3 for ; Wed, 14 Oct 2020 11:13:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="rHDD3KL/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IeK3ROME" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 0BAEF207C3 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:MIME-Version:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:References:In-Reply-To:Message-Id:Date:Subject:To: From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=pweXofWMirW25AfNGr2oq7Xno+ge/a9cxUDvtBE3ogY=; b=rHDD3KL/7vwvWffowvrizcpZQz zfrlv2o3li+sAWQX7gRkts8zZ8zop51ptaKFRjimx0VCI+QaqE2T6nF43LkC7yTcaGA/spMmBp1x4 1PC692gnXohwD8y32np2FvdIgTPuK2GJha1xg+0uwZjC+j8uE+IBMQxJ3+HcRXNMvVfGuozS6wf6I fDkiABFn4Ee2URcnhDihKLren6QkQfHaSyXoLpANtkAe2JcAeg7rzHimQRDBty9n5C4VecXPb42CX F028B3m48k0zN239aw6pBuZHW/la066TwiJy4Eby2dPY0hv5nrDCfuZtk5P3CFyOFka8VEMVYD6Tw BYLnYBhQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSeim-0005es-Tp; Wed, 14 Oct 2020 11:13:28 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kSeig-0005cQ-R5 for linux-arm-kernel@lists.infradead.org; Wed, 14 Oct 2020 11:13:25 +0000 Received: by mail-pl1-x642.google.com with SMTP id w21so1586795plq.3 for ; Wed, 14 Oct 2020 04:13:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pARdoa1Mzik3sFMoHiQMoHrcZnI06KYeFtpW0tbTfww=; b=IeK3ROMEUBzEPfFI89bhNOg9C4y+EbMx+iOpDcSO2ElT9727J1tgmW4RGkoN9rzQCi atrhNXA/wIu0f3I1aUjUzfWJOXjgL6ECP1sjx5Ab/Zg6rz4eLuNJ5K5zG4S+aUjq3Oib cxdYRcNEiBhmj8iTu2QGxIrvq/cWsxizqSDQaCe/jTslqIZZuju7rjE6gQl422bWlEjL 9VCljp63Olb+jJp9giRDzKoseDjX99Tb6AE4eMevIMw+ALO/CA+sUTfNuLNhJEGb8c0J oYI0Zt3nfikvx5QJ/4IuAxaIq8L6SWRqFGI6bPnICR1dB4i6tEKQYBgZXVGY2JmDCaQt J1IA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pARdoa1Mzik3sFMoHiQMoHrcZnI06KYeFtpW0tbTfww=; b=tK+xWVPxXKM5DECHaiiE7vvltqb0+hUlTEXrry5kXeLKyY96lHOoC5Eoyku2cGGCZZ W2kQAmt96hWcL4uZWOKS/1DmybcpCadi29FkbK1OeyCrnzgWVxcIk8pJqpr90AtMICSU HXjMSp3XvdRxr+S6+7XX6bwZhkgZhgYKN1Hogr+aReO5Hs8CllpVX3KtkGEdPdPVZDF2 CKNfrU2gvPAQ+EJ4TrT2S8p9CkPjaWYzitQcOARfdtzpysUybpMC+4CYYoW68E14pOfv rdjij+0Eefw2sOGdXQtmiirVVFVLVwzuMfW76wpNK9MTY+mfzp0OF9EbSkp4nc3tmi0o BoYg== X-Gm-Message-State: AOAM530Mtjk2X25Rq+OYafighO8nJ7m0tSSix0e94s6QpRlRowgA5OZd nh2Md2q2Uzzpuh6l8UnqauPjKA== X-Google-Smtp-Source: ABdhPJxGgmScGvPFqKQIvL1Gl6IbDWm4Zk16CAUqS+hExrozMFM5iv/+6ThqFh0h4Q+YpuS9RR+sFA== X-Received: by 2002:a17:90a:de90:: with SMTP id n16mr2940279pjv.215.1602674000885; Wed, 14 Oct 2020 04:13:20 -0700 (PDT) Received: from localhost.localdomain ([117.252.65.235]) by smtp.gmail.com with ESMTPSA id f21sm3060102pfk.169.2020.10.14.04.13.13 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Oct 2020 04:13:20 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v5 5/5] arm64: ipi_nmi: Add support for NMI backtrace Date: Wed, 14 Oct 2020 16:42:11 +0530 Message-Id: <1602673931-28782-6-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1602673931-28782-1-git-send-email-sumit.garg@linaro.org> References: <1602673931-28782-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201014_071322_960956_A66CD111 X-CRM114-Status: GOOD ( 16.89 ) X-Spam-Score: -0.2 (/) X-Spam-Report: SpamAssassin version 3.4.4 on merlin.infradead.org summary: Content analysis details: (-0.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:642 listed in] [list.dnswl.org] 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, Sumit Garg , daniel.thompson@linaro.org, jason@lakedaemon.net, kgdb-bugreport@lists.sourceforge.net, ito-yuichi@fujitsu.com, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jason.wessel@windriver.com, tglx@linutronix.de, msys.mizuma@gmail.com, julien.thierry.kdev@gmail.com MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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 --- arch/arm64/include/asm/irq.h | 6 ++++++ arch/arm64/kernel/ipi_nmi.c | 12 +++++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index b2b0c64..e840bf1 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -6,6 +6,12 @@ #include +#ifdef CONFIG_SMP +extern void arch_trigger_cpumask_backtrace(const cpumask_t *mask, + bool exclude_self); +#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace +#endif + struct pt_regs; static inline int nr_legacy_irqs(void) diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index e0a9e03..e1dc19d 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -25,12 +26,21 @@ void arch_send_call_nmi_func_ipi_mask(cpumask_t *mask) __ipi_send_mask(ipi_desc, mask); } +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +{ + nmi_trigger_cpumask_backtrace(mask, exclude_self, + arch_send_call_nmi_func_ipi_mask); +} + static irqreturn_t ipi_nmi_handler(int irq, void *data) { unsigned int cpu = smp_processor_id(); - ipi_kgdb_nmicallback(cpu, get_irq_regs()); + if (nmi_cpu_backtrace(get_irq_regs())) + goto out; + ipi_kgdb_nmicallback(cpu, get_irq_regs()); +out: return IRQ_HANDLED; }