From patchwork Fri Sep 11 13:28:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11770583 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 BEF2D112E for ; Fri, 11 Sep 2020 13:32:01 +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 56F3F22272 for ; Fri, 11 Sep 2020 13:32:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="cRnrV/nd"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="IPiXzooy" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 56F3F22272 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=KYonOVSimve/QwhAz9oiKp1jNiHqLV3zEqgUDlb2wSE=; b=cRnrV/ndYaThqAHcglZPiUgM3Q h5OjjJpetbmONvwpL9XN/fPTWdfScrg9gxe+IferVLsnwcrl4ue7JP4FUJjUguxZDD5K4QjZtnh/0 Gl5a/dVWepgwwXanowutsVRUaCsykf66VJiXU36/BPuoCusrAIwHooyA89Yb4BsHiNrW3HZC7PbB9 j/xeDxCKKzMl6f+EZD5YHOoauRi8CMh61FbYqFeI2c/xO/JrYhzwLJqUFCPc+EJaM0RbsHl0VqeQ2 jFkgGSjTIpLhZCe3mLKijmKoI+WMl5tKZ07CE6K417jh0rdzoxXrEpKHNS9000KG6ZWW6xOiiLpou /Em/3tRw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGj9E-0007b3-8H; Fri, 11 Sep 2020 13:31:28 +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 1kGj77-0006Sc-Ci for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 13:29:18 +0000 Received: by mail-pj1-x1043.google.com with SMTP id n3so2651481pjq.1 for ; Fri, 11 Sep 2020 06:29:17 -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=V7c2tVI1sHEIHH1AjuWkw+8Vv4jkByqBwniC8b3+X7E=; b=IPiXzooyc34XdY1D6OA308FNNt0ps3oUF0Df+DJViiEfKqHZVjejg3Ul3W/k9it8IG ZPjc34I3fmGpsJqjMubs6bOIJ+18H5ABsl65dH1Cv1/RcCHX+APupzonwUq2HbhPyVwO LwDTFeNGwv5p2zxycWhDc6202u3+/eR4/G4tPRfGltc0bK1kSgfRjV+U/X4Rufw4l735 9+Zzcc+BnyhsOg5mpksee8x7Rv+KQRi32iKb//u+GY7kk+pB+uLyaLoH0ma8BfKjzPWY IxF6DhPh+EglOOw1BTq5Z1DhbyaunfohQkQDTMioOOHUnXpjq2ifNLioiorbOzQwo7Rn IbEQ== 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=V7c2tVI1sHEIHH1AjuWkw+8Vv4jkByqBwniC8b3+X7E=; b=uQYjx80r2NBFXi7LY1du0JS+pvjU6TMMfHf+sru46g0caeeqBXv6dop/ZEBoeOJD5v Q+sngC5keVB/Mk7k2uiVUFA1lIQ2eHjaTnZ/T+H3D/t0hpZZ1bHqIdOuWz64BwTckJ1m gU9IiPeZyfSzjv7FQ4qiHSkOcvRfuVWgc/RD3Cremn3Y6/lxyBspqR+ZHWMN9QIz/XUR r3lECF9aB3GWQaCqCiM5s04MCCWUQ0hz1N9D944WubWk3ioTscIV4ZCyJd6BEyflkvVW SfS27Iv00Cx2CGHMdKSITvL4MXVseZja+0JQBQB8I7UkzmGcB+D5FpEcPUgzHHWijgjD 67rw== X-Gm-Message-State: AOAM532oynbVijW6p33Z2yx+cFUVP8b+0N3O155++tXCOLN/6ciqZILV frK6kIpAmHK0sjI0BBWLazdzPQ== X-Google-Smtp-Source: ABdhPJy5G1MDK6kqBvQVO9OUwpmI/w6cEPnvwQ+s+rirVNKyqdVtvb8FhGeb80XLNvA9lxYHwbi3wg== X-Received: by 2002:a17:90b:100f:: with SMTP id gm15mr2186766pjb.235.1599830955357; Fri, 11 Sep 2020 06:29:15 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.48]) by smtp.gmail.com with ESMTPSA id e10sm557988pgb.45.2020.09.11.06.29.08 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 06:29:14 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v4 1/5] arm64: Add framework to turn IPI as NMI Date: Fri, 11 Sep 2020 18:58:40 +0530 Message-Id: <1599830924-13990-2-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_092917_510561_21EAE9F3 X-CRM114-Status: GOOD ( 22.45 ) 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 Introduce framework to turn an IPI as NMI using pseudo NMIs. In case a particular platform doesn't support pseudo NMIs, then request IPI as a regular IRQ. The main motivation for this feature is to have an IPI that can be leveraged to invoke NMI functions on other CPUs. And current prospective users are NMI backtrace and KGDB CPUs round-up whose support is added via future patches. Signed-off-by: Sumit Garg --- arch/arm64/include/asm/nmi.h | 16 +++++++++ arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/ipi_nmi.c | 80 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 97 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/include/asm/nmi.h create mode 100644 arch/arm64/kernel/ipi_nmi.c diff --git a/arch/arm64/include/asm/nmi.h b/arch/arm64/include/asm/nmi.h new file mode 100644 index 0000000..3433c55 --- /dev/null +++ b/arch/arm64/include/asm/nmi.h @@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_NMI_H +#define __ASM_NMI_H + +#ifndef __ASSEMBLER__ + +#include + +extern void arch_send_call_nmi_func_ipi_mask(cpumask_t *mask); + +void set_smp_ipi_nmi(int ipi); +void ipi_nmi_setup(int cpu); +void ipi_nmi_teardown(int cpu); + +#endif /* !__ASSEMBLER__ */ +#endif diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index a561cbb..022c26b 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -19,7 +19,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ return_address.o cpuinfo.o cpu_errata.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ - syscall.o + syscall.o ipi_nmi.o targets += efi-entry.o diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c new file mode 100644 index 0000000..355ef92 --- /dev/null +++ b/arch/arm64/kernel/ipi_nmi.c @@ -0,0 +1,80 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * NMI support for IPIs + * + * Copyright (C) 2020 Linaro Limited + * Author: Sumit Garg + */ + +#include +#include +#include + +#include + +static struct irq_desc *ipi_desc __read_mostly; +static int ipi_id __read_mostly; +static bool is_nmi __read_mostly; + +void arch_send_call_nmi_func_ipi_mask(cpumask_t *mask) +{ + if (WARN_ON_ONCE(!ipi_desc)) + return; + + __ipi_send_mask(ipi_desc, mask); +} + +static irqreturn_t ipi_nmi_handler(int irq, void *data) +{ + /* nop, NMI handlers for special features can be added here. */ + + return IRQ_HANDLED; +} + +void ipi_nmi_setup(int cpu) +{ + if (!ipi_desc) + return; + + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_id)) + enable_percpu_nmi(ipi_id, 0); + } else { + enable_percpu_irq(ipi_id, 0); + } +} + +void ipi_nmi_teardown(int cpu) +{ + if (!ipi_desc) + return; + + if (is_nmi) { + disable_percpu_nmi(ipi_id); + teardown_percpu_nmi(ipi_id); + } else { + disable_percpu_irq(ipi_id); + } +} + +void __init set_smp_ipi_nmi(int ipi) +{ + int err; + + err = request_percpu_nmi(ipi, ipi_nmi_handler, "IPI", &cpu_number); + if (err) { + err = request_percpu_irq(ipi, ipi_nmi_handler, "IPI", + &cpu_number); + WARN_ON(err); + is_nmi = false; + } else { + is_nmi = true; + } + + ipi_desc = irq_to_desc(ipi); + irq_set_status_flags(ipi, IRQ_HIDDEN); + ipi_id = ipi; + + /* Setup the boot CPU immediately */ + ipi_nmi_setup(smp_processor_id()); +} From patchwork Fri Sep 11 13:28:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11770585 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 39888112E for ; Fri, 11 Sep 2020 13:32:18 +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 B285722273 for ; Fri, 11 Sep 2020 13:32:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="uKvqpqI3"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ICb2A4Q9" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B285722273 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=5kooRih43fGm/t5U7Txg1kN8My9hDpqccPz6c8LVIE8=; b=uKvqpqI3/oI9CyJoRWwD2GJVBl yEUFxp/Xpmg54QAi4RKht+EBXAbrnINmMg177QzUQ+i/BHAMHtfbbtsgbmXvxaHTrJLeiKGidzV1l gI2FoLwK5JaL7TGUbw7PuVtAXuuBr0weJoV4xXGgJG394uY44WBpJ5GmCD7JQKM6AvUUC7RltYR// GD5ce5QUiNFwMUtMRBpYUIfpyoOu+cU7tmlUUAr3fEHmvXIctxGGR1msYUVJ/WUja5AeJKt5cu+Gh r1AHoKEW1d8sHQyjC6NNQYhLQRokUSxLFIN99ol4HniEooseiP0s61LOcdMyrip7GBc7oNifFDu0C ti1CEiag==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGj9a-0007vZ-Td; Fri, 11 Sep 2020 13:31:51 +0000 Received: from mail-pf1-x443.google.com ([2607:f8b0:4864:20::443]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGj7E-0006Xz-PJ for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 13:29:26 +0000 Received: by mail-pf1-x443.google.com with SMTP id o20so7324536pfp.11 for ; Fri, 11 Sep 2020 06:29:24 -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=kqVh90gZA+Jv+sQxaZ1mzbNqmtA+iD77lIe6xdCdvDA=; b=ICb2A4Q92/WBWM7cefZ5ElnS+BfqFA5z0dbBB4/9D+x61pUUrWW1TIJyG5l2OJJ2J5 /b+lGtutItcjO/D7XmeVO8ZnVREF7WXLuAt2jwJvuvVcSsqEGPxbZ5u5LOpc00sQAHWj gfOC3DyGCrPI5E0Cm6J32sd1Nu8oGV5TOkQacP/WGNAa764VytHt7lu0brBvUxrFOvSa Pw5Mcyi2x9MbzUTws4bDmbU3LsDZxbaiPV+biUykE5780veIyiTyoc63274v3ZgtVsDG TyHyLH9q/0ALmh03yg/t0t0x4rf1uBE9MoH47bCmbU+IFZ52Te0Vqol1v32V9eODx1yV Smkw== 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=kqVh90gZA+Jv+sQxaZ1mzbNqmtA+iD77lIe6xdCdvDA=; b=uXMLEuV6qTgkUnYxC455KN6ywaMvcLP9qNU9MxKcy4ktEO2WxVBNVrhBumahbO68Nb DI/2EObZYHQUYuu1xv0ONAbMd+hwsTOqV5YMhmgFTB0EZbKQzb89D9RLse8q43RGAD5P fX9gw6bl40mV7iAtIdrjHprTVW05yllrH+A6ANXpl2GPaVUq03vxc1du9h3QOqix/0uR 3ZfOkrYqfOpKqYk+exlssxJKZdJ2A1W3vhwwILZlzK3R0fG064lmsgYeNbGdmqXR7zc4 SVGaU8HSQz1UIslkr+/bEzSWnEJUt/L4k5XxgCSUiqd8gDcVw7MjyjNlMh+ayQlAsKGl mnww== X-Gm-Message-State: AOAM532PRse0YUbDbi5i2V69N6gD+Z4r6F7XvCwo3PyJ6Ex60lSeXYAe 115anx/fZkDEu9P+u13TpfgsXw== X-Google-Smtp-Source: ABdhPJydCZ/jXrds01g38SygDtPX4ovyhhGVLoresFGxG+Fvj8jeLjcgon9C79eWnN9h7K1cLegzTg== X-Received: by 2002:a17:902:760b:b029:d1:9be4:856b with SMTP id k11-20020a170902760bb02900d19be4856bmr2313328pll.1.1599830962073; Fri, 11 Sep 2020 06:29:22 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.48]) by smtp.gmail.com with ESMTPSA id e10sm557988pgb.45.2020.09.11.06.29.15 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 06:29:21 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v4 2/5] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Fri, 11 Sep 2020 18:58:41 +0530 Message-Id: <1599830924-13990-3-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_092924_914463_C606E971 X-CRM114-Status: GOOD ( 14.96 ) 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:443 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 Add support to handle SGIs as regular NMIs. As SGIs or IPIs defaults to a special flow handler: handle_percpu_devid_fasteoi_ipi(), so skip NMI handler update in case of SGIs. Also, enable NMI support prior to gic_smp_init() as allocation of SGIs as IRQs/NMIs happen as part of this routine. Signed-off-by: Sumit Garg --- drivers/irqchip/irq-gic-v3.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 7170645..dfd8e03 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -476,6 +476,11 @@ static int gic_irq_nmi_setup(struct irq_data *d) if (WARN_ON(gic_irq(d) >= 8192)) return -EINVAL; + if (get_intid_range(d) == SGI_RANGE) { + gic_irq_set_prio(d, GICD_INT_NMI_PRI); + return 0; + } + /* desc lock should already be held */ if (gic_irq_in_rdist(d)) { u32 idx = gic_get_ppi_index(d); @@ -513,6 +518,11 @@ static void gic_irq_nmi_teardown(struct irq_data *d) if (WARN_ON(gic_irq(d) >= 8192)) return; + if (get_intid_range(d) == SGI_RANGE) { + gic_irq_set_prio(d, GICD_INT_DEF_PRI); + return; + } + /* desc lock should already be held */ if (gic_irq_in_rdist(d)) { u32 idx = gic_get_ppi_index(d); @@ -1666,6 +1676,7 @@ static int __init gic_init_bases(void __iomem *dist_base, gic_dist_init(); gic_cpu_init(); + gic_enable_nmi_support(); gic_smp_init(); gic_cpu_pm_init(); @@ -1677,8 +1688,6 @@ static int __init gic_init_bases(void __iomem *dist_base, gicv2m_init(handle, gic_data.domain); } - gic_enable_nmi_support(); - return 0; out_free: From patchwork Fri Sep 11 13:28:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11770591 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 9052B112E for ; Fri, 11 Sep 2020 13:33:05 +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 1BAB522275 for ; Fri, 11 Sep 2020 13:33:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="vhwtr3sz"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="jGOWZRFH" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 1BAB522275 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=RlRu+gYAzrjpvX0Qi1QmhG+EGO6gptJk0vFVAutQD7o=; b=vhwtr3szGCAP4z4Esj8yUmm9nk hNX4pb8llSu5N6kWf1xtW3RV1tI7Pe1eojVS2H7N213wowZditRZdcVeQSZ0ECyjr82fu4Gq0eRXq mUEQMmCVIMHslshwF646qFiDUY+to7aRuz0RPhUvedsPL6NNfIkRsvhzZ9n1+jjKC8CwCpNWj8jZA VerpfY6dfTYUF161s2CCQ6t6XsjsjwbFcuPat5uYzu+gSkmY8/pG+iY9a0VzohRKOEspl1AJL9YP7 FWLUCbGojVuDXuxma0Ux7Ch/EImVAL9HVHXPjfb8DeZrn85RQTJ29pd/4/HPttULtWhVlbyZsPjZE xnNbGaZA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGjAQ-0008IO-Gb; Fri, 11 Sep 2020 13:32:42 +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 1kGj7L-0006bu-LL for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 13:29:36 +0000 Received: by mail-pg1-x543.google.com with SMTP id 7so6644569pgm.11 for ; Fri, 11 Sep 2020 06:29:30 -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=Borfb2c/AuKaxrPEvHGpc2ZkIkK0QqkS7G7OkbQVw6o=; b=jGOWZRFHUPusoZoYx87HUc0UdvWsBxz/6APZqblOC9XbCFv0ytJIfpKbUiqGR+qoBp OecjXlHzj+qtca8/4IwvdC6BImis+apETeuCYAtSsst/IzfSeJ9zBlJJOWLAZ8Q3b6pm yKHIP/rm3cGeLhNBMovZS3Ac8tjlfx5ca9yGhAwO+l3zo/53AazZkVt70xeUCA9FCju/ EGMp/NOXqs0btZS4XhRbtqqwXskqCdE6JBpojPgaA7D1Dyl9f8kzzekwPx3+YC8LIm61 J7tsBhGdMbL0TwkfjHVGE+2z6hAPvDArpTr24zfjOcqFOHryVEhD9n16KKxaEvvfXSfS 0BOw== 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=Borfb2c/AuKaxrPEvHGpc2ZkIkK0QqkS7G7OkbQVw6o=; b=G/zXVs4vWelHd7SxEK0I5XuAEQethtaW6STF/UOfqigJQ5k7zcWvlyL09PX0541e7l /SWijL3G4yf6T/ptTvbAFYujZY1u7cIWwHOqKeyHVcQSKk2K4yG55vlBMHxtPVi9pA4j jjmQpAv9STJuP20JmfViUvGpviJniNt9VHDIxD1bdjuPUXy9eqIM3+DXalbxKgYe1oSr ZkbzV0r34JqbZWFEzIwZPv5LClcSrp1EDOTZMxfJuyToLTN7oFmgE5rTxDptpGdHsNes nlqk2GBdygceGHpYOxjFxJYUSX2vR+HG73fx8e5tM7miqBlkP4cDXdT1nJ+smAMJJOC6 1iNg== X-Gm-Message-State: AOAM5318e5W+J6ZNywfZIPdP0yOAYX/mLRHE0lI99R7trvjS4Tsh24SU TvfKvAIXYu6UPE8oFmxWriUxAg== X-Google-Smtp-Source: ABdhPJxr9ACTHLE1mqe3DgZIxSLIMmNQF1fyLmvRkWYTYL0CQRvGUt3F8c0z0XSGcO/b1SJoc8A1AA== X-Received: by 2002:a62:5244:: with SMTP id g65mr2133117pfb.132.1599830968549; Fri, 11 Sep 2020 06:29:28 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.48]) by smtp.gmail.com with ESMTPSA id e10sm557988pgb.45.2020.09.11.06.29.22 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 06:29:27 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v4 3/5] arm64: smp: Allocate and setup IPI as NMI Date: Fri, 11 Sep 2020 18:58:42 +0530 Message-Id: <1599830924-13990-4-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_092931_920472_C1C96E7E X-CRM114-Status: GOOD ( 15.35 ) 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:543 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 Allocate an unused IPI that can be turned as NMI using ipi_nmi framework. Also, invoke corresponding NMI setup/teardown APIs. Signed-off-by: Sumit Garg --- arch/arm64/kernel/smp.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index b6bde26..3f3b1ff 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -962,6 +963,8 @@ static void ipi_setup(int cpu) for (i = 0; i < nr_ipi; i++) enable_percpu_irq(ipi_irq_base + i, 0); + + ipi_nmi_setup(cpu); } static void ipi_teardown(int cpu) @@ -973,6 +976,8 @@ static void ipi_teardown(int cpu) for (i = 0; i < nr_ipi; i++) disable_percpu_irq(ipi_irq_base + i); + + ipi_nmi_teardown(cpu); } void __init set_smp_ipi_range(int ipi_base, int n) @@ -993,6 +998,9 @@ void __init set_smp_ipi_range(int ipi_base, int n) irq_set_status_flags(ipi_base + i, IRQ_HIDDEN); } + if (n > nr_ipi) + set_smp_ipi_nmi(ipi_base + nr_ipi); + ipi_irq_base = ipi_base; /* Setup the boot CPU immediately */ From patchwork Fri Sep 11 13:28:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11770593 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 5320C159A for ; Fri, 11 Sep 2020 13:33:39 +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 D8C5F22272 for ; Fri, 11 Sep 2020 13:33:38 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="UKHAZe8b"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="oMLE8rM8" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D8C5F22272 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=1j3VgQF+2R0ZdKWTrb5RaSaBEYfLWWejfWqxuHBwMSY=; b=UKHAZe8bP4oD+0CaHAUmbNbZH5 vnyBLN3rjtnKEnyb2jv1+4fFqV+wLrUR+9j5PlhJ9WSFRy1vLuw/IdZpIxinXmGtAxYanVY67cgTE znfxKcNilaj7mbtOEmQ6RFlr4AVZqhIn2Q7J8IKHTo085cph9valoC0a+Vj8r78P7t+lPt+mPRgSH 88REQ5l8oREz7bi5kPiJF8xSnLr5B/7gL5izYlCy7dstqYIVC2vWRZeg/pxNjUxMxInWVu3dtXGXz ZbR2BYptvPhJvPIh7JahRNhz8g976pY9Zvs+rlTf6ozYpfYrjH9Iy5LdYvZk9quDNy4GS0RH5oLI0 TUx5RJcQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGjAn-0008SK-Sk; Fri, 11 Sep 2020 13:33:06 +0000 Received: from mail-pf1-x444.google.com ([2607:f8b0:4864:20::444]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGj7S-0006g2-AZ for linux-arm-kernel@lists.infradead.org; Fri, 11 Sep 2020 13:29:41 +0000 Received: by mail-pf1-x444.google.com with SMTP id x123so7343471pfc.7 for ; Fri, 11 Sep 2020 06:29:37 -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=J8XXWl4v9PBTaJqTU0LTHaO4yR2LTPizMFNymaqYIWU=; b=oMLE8rM8iM22jHrw1tJVriGCJdRA1UU9284YM4yPrEVz8JGMXc468KKUHFkOv8kZaM IQntWXGwecrKYhSd3zKZekV9erPYLtHP2zh2m+vEJKSME1gs9vAzG2PduN7/i5AI59yy 0txAVl3MJnpldlYdvFKDUWTEpnosfq1O51eVJtT97YcTYT28Ln+iIQbpO741qfgW0rtf xcOwz5P8xsckuDs+y/C97e/Np1ciQuyhzZmKh2cDDh88U5kG0pjFoYklwm7SACpSOI11 4N+M6aUC/v72MEEGG7Zj4jGDZUl1daCgdXxJt4OgYItqqWGNOLZCLTJvL6d0OktecC/G svXA== 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=J8XXWl4v9PBTaJqTU0LTHaO4yR2LTPizMFNymaqYIWU=; b=es0doc1vn/b2OrGltSxPoXlnGA9/tCj6PQMQR9Mz8fh47lhLWbdY+/jqeJGR/ElDbk DKzh86QPVJ1Kas5ACNLf6yZb0bPd3ZaJO9p/fAyPaUf4OKLZr5aIuNqnn4+GG8HpyXBI snQgm/x8EIqivQKYOQi2jJkJWCYJERMPo7t99HCKVgIQADE5KB0Z49Lolwqf80xVYYnu ta89+xyh/w9sLHOFfhp4paOlOeMK5bB5ixDWEZlQBWtgPVqsgrwQsf92ssko5qIWcIpf TYRBmfXRJf7Rg1YP78h3Hc1LljdO4xrnElkNktnDPaFyuZwt7QKpw5trMsgZl9yy8aCp K2AQ== X-Gm-Message-State: AOAM533RMHtdHU7PIXrkQKZmR2Z4nxZDJBkb7765M3oT/Qmhww15i6VJ F6xBJbpb19muDMEpcNDLPBRA3w== X-Google-Smtp-Source: ABdhPJw8LOM8mjmqzKYH9VAZAt/tSr5GGEC3yJjnUtjTsmmZ+TNtaich1KH/B6flKrFEBX4t5n1h7g== X-Received: by 2002:a62:cfc5:0:b029:13e:d13d:a083 with SMTP id b188-20020a62cfc50000b029013ed13da083mr2213644pfg.26.1599830975328; Fri, 11 Sep 2020 06:29:35 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.48]) by smtp.gmail.com with ESMTPSA id e10sm557988pgb.45.2020.09.11.06.29.28 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 11 Sep 2020 06:29:34 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v4 4/5] arm64: kgdb: Round up cpus using IPI as NMI Date: Fri, 11 Sep 2020 18:58:43 +0530 Message-Id: <1599830924-13990-5-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_092938_557120_7D496736 X-CRM114-Status: GOOD ( 17.76 ) 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:444 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 arm64 platforms with GICv3 or later supports pseudo NMIs which can be leveraged to round up CPUs which are stuck in hard lockup state with interrupts disabled that wouldn't be possible with a normal IPI. So instead switch to round up CPUs using IPI turned as NMI. And in case a particular arm64 platform doesn't supports pseudo NMIs, this IPI will act as a normal IPI which maintains existing kgdb functionality. Signed-off-by: Sumit Garg --- arch/arm64/include/asm/kgdb.h | 8 ++++++++ arch/arm64/kernel/ipi_nmi.c | 5 ++++- arch/arm64/kernel/kgdb.c | 21 +++++++++++++++++++++ 3 files changed, 33 insertions(+), 1 deletion(-) diff --git a/arch/arm64/include/asm/kgdb.h b/arch/arm64/include/asm/kgdb.h index 21fc85e..6f3d3af 100644 --- a/arch/arm64/include/asm/kgdb.h +++ b/arch/arm64/include/asm/kgdb.h @@ -24,6 +24,14 @@ static inline void arch_kgdb_breakpoint(void) extern void kgdb_handle_bus_error(void); extern int kgdb_fault_expected; +#ifdef CONFIG_KGDB +extern void ipi_kgdb_nmicallback(int cpu, void *regs); +#else +static inline void ipi_kgdb_nmicallback(int cpu, void *regs) +{ +} +#endif + #endif /* !__ASSEMBLY__ */ /* diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 355ef92..627bc11 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -26,7 +27,9 @@ void arch_send_call_nmi_func_ipi_mask(cpumask_t *mask) static irqreturn_t ipi_nmi_handler(int irq, void *data) { - /* nop, NMI handlers for special features can be added here. */ + unsigned int cpu = smp_processor_id(); + + ipi_kgdb_nmicallback(cpu, get_irq_regs()); return IRQ_HANDLED; } diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 1a157ca3..0991275 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -17,6 +17,7 @@ #include #include +#include #include struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { @@ -353,3 +354,23 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +void ipi_kgdb_nmicallback(int cpu, void *regs) +{ + if (atomic_read(&kgdb_active) != -1) + kgdb_nmicallback(cpu, regs); +} + +#ifdef CONFIG_SMP +void kgdb_roundup_cpus(void) +{ + struct cpumask mask; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return; + + arch_send_call_nmi_func_ipi_mask(&mask); +} +#endif 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; }