From patchwork Fri Sep 11 13:28:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11770595 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 8B1C7618 for ; Fri, 11 Sep 2020 13:34:37 +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 52C0022272 for ; Fri, 11 Sep 2020 13:34:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="mr6CMyu/"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EuQDuBTv" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52C0022272 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=VzmgI2X2dHhT1s+ve1qJ/nj3BNm3CvcszpKyTRZBrwk=; b=mr6CMyu/uZvx98txUJ7V2ToxZw 9AuZGTKZg+ZHej1DZ1D8o77rsWznOZTZtVzRis6RseIG8k7++CWxllIiGSIqgOiwVqIXRVuXBfJ8l WC/PzVIVesvLr2rzJyYgXp7M3xT/LokT4gkiudSZuoseyT3J70wuGCjsBSArduDsid5KT8L5K8n+k gwPpkJEv4HgStk6BqtTvXN7W2WHGGjaPErQNxV+d4672WlbkRMDDBzYBZT8UHRYjxAHeHjQTHvoqJ kWyJJQXqmRuXe133BsDJhuhTe7fDlt83pYroasbZAVzk+Vdg5RJowpOM1r3RsvnOgc6KPUURPqZzT hdq840QQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGjBg-0000VY-VM; Fri, 11 Sep 2020 13:34:01 +0000 Received: from mail-pj1-x1043.google.com ([2607:f8b0:4864:20::1043]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGj7Z-0006kJ-KC for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 13:29:46 +0000 Received: by mail-pj1-x1043.google.com with SMTP id b17so1713539pji.1 for ; Fri, 11 Sep 2020 06:29:44 -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=UMF4bf/xlX5iMhhFdvv4POZJxLXNJMbFMY0/ylfkgBU=; b=EuQDuBTvOvwLK210071x8IREFokQkgZaord4oFCyWIF92/r5O+/EHGVhTZB7Xa3ZYA O6Y2+67Gs5ian2S/VK+fTAa2hAr+hTP0YsK989soxdqSat1sWOjtSlXx5AUdQdheN/r7 l+FNLv+QNEE9hzRIazVRwnfqsbKvqZLqCiwKBW/iegqkTtCcFFxV4oK/Aay+X8OFVNwt ea7F6VWqHxZ4ol/1WXrJ5YTrlZSyygzFH08zKGn8NikhCkP2wRHgnIytnzENhf+9t8q5 EeOBCzZuDaOq0opR7A5YOpMF84iYa5OGzmk8Wn8tzIGeF3MAZphGwwlyFNNa9ikyVoXk rKMg== 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=UMF4bf/xlX5iMhhFdvv4POZJxLXNJMbFMY0/ylfkgBU=; b=PrZt3IqGQSF08pl8ygT29KiMfihI8n5PR4LRHMXZLhydCB85NJFlAkcNPRrAXn1tZn MgBFJVEfTAZ1XKZTdIo5DAtM6Xa5amCFkCmg9kO3H+brg4+WjgOKsMoo42Kvsx35eN1M 7oGXuy4VA9LiUei1whKpHvew56aSzgHVBwnty6VHeDIbw6caiNjprByIqgApRAB3vlcP J4xYakxGPjMpJrgqEZ5JS8WBG/XH8Zh32Iktg/gXZ6MSsZH7rITecnTguR/w8pWWSUb5 KQYH7Au/6NYJVR0bBjqsBsjxoQzZ1L6goCL1WEMkAPK3Gn92vdek0JzMdnDE/6ntp+2H r4Fw== X-Gm-Message-State: AOAM53341VC/jWZ7h57lyW6FA4SAE0yMI/ONV+rkHZydUM9nqEpQZTwp WuqqmsCWi53ttwpnJmxzeTmtoA== X-Google-Smtp-Source: ABdhPJxB8cUOtjFdM+vSMsIEhsYFJvwax+iseMhfwh9gbEQK9y8yNt7VouZeSvdSOUYF8uN7QozcNQ== X-Received: by 2002:a17:90a:f992:: with SMTP id cq18mr2296365pjb.136.1599830983031; Fri, 11 Sep 2020 06:29:43 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.48]) by smtp.gmail.com with ESMTPSA id e10sm557988pgb.45.2020.09.11.06.29.35 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 06:29:42 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v4 5/5] arm64: ipi_nmi: Add support for NMI backtrace Date: Fri, 11 Sep 2020 18:58:44 +0530 Message-Id: <1599830924-13990-6-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599830924-13990-1-git-send-email-sumit.garg@linaro.org> References: <1599830924-13990-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200911_092945_736752_36D9EFEB X-CRM114-Status: GOOD ( 16.58 ) 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:1043 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 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, dianders@chromium.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jason.wessel@windriver.com, tglx@linutronix.de, 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 627bc11..d3aa430 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; }