From patchwork Mon Nov 2 11:44:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11873705 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D80E3C00A89 for ; Mon, 2 Nov 2020 11:47:36 +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 7C70F206A4 for ; Mon, 2 Nov 2020 11:47:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="r/LheQlf"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="hJ9/Ezv1" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7C70F206A4 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+linux-arm-kernel=archiver.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=APlqDUFrGwnD3r1Ma+9qJEODm5kMWDL+VXpdbuRSIDA=; b=r/LheQlfDyM9Db+wy3HFCf7feF HHft3DaBty4quHKj8j3gj3dDrvFg8aMvKxYn7pqPS4G4i9h8ZW5aenzv87Gy4ZTff5iB68s2/I5lH eHN4rf09OxxZOIZG0LQ5bRcfVbbhnDuIGu6BQXZMsw2yIQE7/JxnQzP0C+DCA4YMOv3eGnuSwk0fs uCltrOHKeAgQqN6YfxWyx4MD6OteQz/MD0sn62c7iYC1gF2KLWh88apsfjZz9V1DYGJoey4GbNekE tAvzNznywMqi9GBp1D4s9fXsy02cDOewq5mhnMW02JLYf/8owK+VHIBnBn/CM3DRpp9cpxk/5h2f0 BUi2Lx9w==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZYIU-0007VI-6d; Mon, 02 Nov 2020 11:46:52 +0000 Received: from mail-pg1-x543.google.com ([2607:f8b0:4864:20::543]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZYI5-0007JV-Sm for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 11:46:27 +0000 Received: by mail-pg1-x543.google.com with SMTP id o3so10547215pgr.11 for ; Mon, 02 Nov 2020 03:46:25 -0800 (PST) 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=63fCD7b9c39BMwHAue5Fl+YEtHFG3eKfVilw8x2/rAA=; b=hJ9/Ezv1ZgdvCLAG1rgjJ/9mpQ+SKh3LvAYZ/WUKYXIalESoV9Oql4vEQPCT2oMRus Drdj9tN3YSjMyBl+gq1AeNPOpvihBVmc1GU7Jm/9saZgCQNc7QuyUJilIvyNHRHrw9VW fY1y9FZJNr/taNUexlK7F8FnmRslj7+n7UVcb6vdTIfHXDkMGs9Vv+EQPz03XeTpwM4T y0sxHRkvp7vk08etU9dCuWcROXesLKCqMHWaZ93iaANXXu+HO+gONdCfJ23JAcZbp6zr 1PC8Lnkk0Pilok7g7Kx4MQXncXBIwSgsu/qS0WXMl5HrPqZek7EGWxjeoaUiBFo3oGqX Q5Jw== 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=63fCD7b9c39BMwHAue5Fl+YEtHFG3eKfVilw8x2/rAA=; b=SoVR/pQmI6yo1+Rj6uwIMeGdWL4BTiFiPGPpfBbhCmOWlJTxvIb8xvnzLzeLxfRCpK 3LxiqY7hcz0kdLXW+X5WUleRawSKxvcZh4CvSmJQ4HZc+bo2t7PA0lUKsdaC9afGyXaf jv5oEyWg28IU4fVQ5HjwFc/1MeRWk7g4/SnbktMLGAz2pZR00AkPPlCvhgMKtlNSwfQT 7KUFe1Pli0a4702MEjmiQfaBqoxOwtIzqOXMxHGVrH9hClt4EEQTxl+vVbeBHI3f1u2p dZp30X4t70xTFpGJzscPp9fGHqTk73oAN1SgKdxsvwHv9ipLqXFxiFxdBk+AWFJ7QN+W FHSg== X-Gm-Message-State: AOAM531BaJo5MwImrEZmjRt042xhCinEyzy/HWxCHMQBmOl0aokzT8vC +MEXiYKEP8QYOVw5jGWskZZ2Wg== X-Google-Smtp-Source: ABdhPJxo+jJRsFTKov77OJRU77007ycelGKbPaV5dYEs45Z4UJIU+NvAvFXsfZkDaHO0m3EtjWrM2A== X-Received: by 2002:a63:3d8c:: with SMTP id k134mr12755914pga.22.1604317583680; Mon, 02 Nov 2020 03:46:23 -0800 (PST) Received: from localhost.localdomain ([122.173.169.225]) by smtp.gmail.com with ESMTPSA id y5sm14276184pfq.79.2020.11.02.03.46.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2020 03:46:22 -0800 (PST) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, daniel.thompson@linaro.org Subject: [PATCH v7 5/7] arm64: ipi_nmi: Add support for NMI backtrace Date: Mon, 2 Nov 2020 17:14:45 +0530 Message-Id: <1604317487-14543-6-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1604317487-14543-1-git-send-email-sumit.garg@linaro.org> References: <1604317487-14543-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201102_064626_166129_79BC2620 X-CRM114-Status: GOOD ( 18.71 ) 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 , tsbogend@alpha.franken.de, linux-kernel@vger.kernel.org, jason@lakedaemon.net, ito-yuichi@fujitsu.com, mpe@ellerman.id.au, x86@kernel.org, linux@armlinux.org.uk, dianders@chromium.org, mingo@redhat.com, bp@alien8.de, julien.thierry.kdev@gmail.com, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, msys.mizuma@gmail.com, davem@davemloft.net, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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 | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index b2b0c64..ef018a8 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -6,6 +6,12 @@ #include +#ifdef CONFIG_SMP +extern bool 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 a945dcf..597dcf7 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(int cpu)