From mboxrd@z Thu Jan 1 00:00:00 1970 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=-12.8 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,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 B5B6BC43461 for ; Fri, 11 Sep 2020 13:35:25 +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 3B27C22272 for ; Fri, 11 Sep 2020 13:35:25 +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 3B27C22272 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=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-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 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.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 -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel