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=-10.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable 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 7FFD2C433E7 for ; Mon, 19 Oct 2020 12:17:30 +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 EA06D21D41 for ; Mon, 19 Oct 2020 12:17:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="bZ51s1TI"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=kernel.org header.i=@kernel.org header.b="clVAWMr3" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org EA06D21D41 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:Message-ID:References:In-Reply-To:Subject:To:From: Date:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=incXKbqNgd6UzJHYUqWDvgvEfhZz0JmkZxnoZ3h/Q14=; b=bZ51s1TIHNCbNjTIt8mhuL7X5 nigOll0Gn2/BneBedcirvci3yPnUZOUI2T2NQHJ9XZueoXd3NRL+DY67ppXkRQUzW+4ZYFYu/H84+ Kxu2s+PHPMdPx8ShxtiZ9noa/7EPT9fNhq6lQd0t6Wxtdo4Ivt//7S1gnkn1Fu7DfGxprNqwtnUOS 0qzCP0f82zMG9YY/StPR+xqPcPL1ElLJR+gzCOXjd1BRE7Ng43hC+mH+vfd1PSOxtBknM8K9fPTe+ dKFekDYePhMpToTprVNWpwUbYvMK22nYMJExt2szIB57InoITONpXXe6PRHuY0j7G4CxzlJUhZGYD kcKf01egg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUU4v-0001EK-N3; Mon, 19 Oct 2020 12:15:53 +0000 Received: from mail.kernel.org ([198.145.29.99]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kUU4t-0001Dj-2B for linux-arm-kernel@lists.infradead.org; Mon, 19 Oct 2020 12:15:52 +0000 Received: from disco-boy.misterjones.org (disco-boy.misterjones.org [51.254.78.96]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A74D222268; Mon, 19 Oct 2020 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603109749; bh=RYQpI+PlsEdpivnE+YOvprJVaqwBNAEJkR9tx1GcJa4=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=clVAWMr3IFUpwbSGLYMFnhoyCjXo84OlYKfpqaNOO+RlNVrhG0ePOhZMv7ThU0Grk HN5gRo4gYu4Zgzc5851pH/KlhbP1JUrPDjWrVDMDFBnJZugMi/n1aGYdz/JiF9c+w0 AYzxWQwRXEJq2Lly7B2Q5NN72fAI5MuLdmxYOYq0= Received: from disco-boy.misterjones.org ([51.254.78.96] helo=www.loen.fr) by disco-boy.misterjones.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1kUU4p-002PeW-Im; Mon, 19 Oct 2020 13:15:47 +0100 MIME-Version: 1.0 Date: Mon, 19 Oct 2020 13:15:47 +0100 From: Marc Zyngier To: Sumit Garg Subject: Re: [PATCH v5 4/5] arm64: kgdb: Round up cpus using IPI as NMI In-Reply-To: <1602673931-28782-5-git-send-email-sumit.garg@linaro.org> References: <1602673931-28782-1-git-send-email-sumit.garg@linaro.org> <1602673931-28782-5-git-send-email-sumit.garg@linaro.org> User-Agent: Roundcube Webmail/1.4.9 Message-ID: <0899dcad304ac8bf0ea7d5308ec2e263@kernel.org> X-Sender: maz@kernel.org X-SA-Exim-Connect-IP: 51.254.78.96 X-SA-Exim-Rcpt-To: sumit.garg@linaro.org, catalin.marinas@arm.com, will@kernel.org, linux-arm-kernel@lists.infradead.org, tglx@linutronix.de, jason@lakedaemon.net, mark.rutland@arm.com, julien.thierry.kdev@gmail.com, dianders@chromium.org, daniel.thompson@linaro.org, jason.wessel@windriver.com, msys.mizuma@gmail.com, ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, linux-kernel@vger.kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201019_081551_293750_FB64523D X-CRM114-Status: GOOD ( 26.12 ) 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, daniel.thompson@linaro.org, jason@lakedaemon.net, catalin.marinas@arm.com, ito-yuichi@fujitsu.com, dianders@chromium.org, linux-kernel@vger.kernel.org, julien.thierry.kdev@gmail.com, jason.wessel@windriver.com, kgdb-bugreport@lists.sourceforge.net, tglx@linutronix.de, msys.mizuma@gmail.com, will@kernel.org, linux-arm-kernel@lists.infradead.org Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On 2020-10-14 12:12, Sumit Garg wrote: > 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 a959256..e0a9e03 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()); Please add a return value to ipi_kgdb_nmicallback(), and check it before returning IRQ_HANDLED. Thinking a bit more about the whole thing, you should have a way to avoid requesting the NMI if there is no user for it (there is nothing worse than an enabled interrupt without handlers...). > > 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 There is no such thing as an arm64 UP kernel. > +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); Surely you can come up with a less convoluted name for this function. arm64_send_nmi() would be plenty in my opinion. > +} > +#endif Thanks, M. -- Jazz is not dead. It just smells funny... _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel