From patchwork Thu Sep 3 12:05:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11753471 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 BE124739 for ; Thu, 3 Sep 2020 12:07:40 +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 92BAC2072A for ; Thu, 3 Sep 2020 12:07:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="StUbgCZv"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="vWyyppW7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 92BAC2072A 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=IH8rLDnrya1B5kPq8xovRbB/SrnkfD4YTmlyV28mPx4=; b=StUbgCZvMVdgBzQDEc/0UZPwVD Y9HPyigH97kRYaaKfdqS5LBE/ZoPElKn6uul+wBVtZIAAjKez3ihGfN1Lp3mV0ipL0xU7Qp+/fy4b yB2zAwozIld/DFZwBURi+Stc6/DU0O6cGCivXE2sJziQNF5KRYJOJmIfpLRUtKQ8Wlq/72tIHEY/H qfuovi28cZN6I0/blKqAIXZAB9NC1SNR5PKTJK2QcTIKwwYgOrncKJa2VHDRu6FMEfSezDwFWeGTt CyZAl3iTds7z21jb3Fb6+pVm9UJ3lTDbqJHE5rA+/tFzuc8LtsEbl2VdsLUy5r+1vpKn5PgHIDvfv 3IMEcTUg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDo0R-0002Ij-3z; Thu, 03 Sep 2020 12:06:19 +0000 Received: from mail-pg1-x541.google.com ([2607:f8b0:4864:20::541]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kDo0K-0002Fx-I3 for linux-arm-kernel@lists.infradead.org; Thu, 03 Sep 2020 12:06:16 +0000 Received: by mail-pg1-x541.google.com with SMTP id w186so1958384pgb.8 for ; Thu, 03 Sep 2020 05:06:12 -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=6rT3Oq3fCAt3C31zNixC41u1K5vlck9GLS8EDOYTmew=; b=vWyyppW7hpygvE/IkGGf/gUhETTigprQq6UV1DJ8NWDb0v+mRfJtrPiVVREDvTmBLE 9wbVYxBwL7yziCp3zIGYydYwRUYaBmUoWla/7w6E6i7WekurGkRwFVOgFAzuX4EsdWK7 SgBKTIy7EM9aXrk2pWefgyzvaHDSHZqiySbVvBukeOU9l09HsqE+QVe9pa2IW5Gd3RcA 0N9szfLficZOOZaiT0Qzu0ekzkT7ttJz62H81vng9XHHjh762SLxUQzRLjfuQmZEa+mw v01MFTpWgVsZStU4//S/zrx2uL8iDLqzxfbPuBGKVITP0EfjiLk7cxCHzzs/rYzrKLm5 mAbw== 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=6rT3Oq3fCAt3C31zNixC41u1K5vlck9GLS8EDOYTmew=; b=XyWQ7LXrJvtjDll2GCT80h7SpsynUSGd3WQhsxXjNAOX2mVuCJbi+j7GHO9spAJL4g a9/F/vtHoky0e0kgNI07JyjOZLZLo+fJUs9lk93qdKzLi0qQ5lEljmJ5mke2sNDtDEsj Jz90YLGfUERIueAbWAdNCORGXV198ueWpK49SEMf98RuA5QC5divjFKp1mWeM3JlUyIH rckwp/iXw2iKd7tUK4GP3br6t4EIcNcBEEkWvYQ1HEbAmx8eIHNr7tdWUEiDKXSD2BV0 2uQ+wF1Br1DiNZETXvh8LvyXrZWNqE/NesAUgPu4f1YiB4EZluGRJJ751+CEgAcIYcae ScZA== X-Gm-Message-State: AOAM532Fzn/XOXUn2QU7EEioA/iwnZbPUGbBBplYa70RIzf3xEfotoYl GTqVRbzskFyKGjGucOst29J8xw== X-Google-Smtp-Source: ABdhPJxmXC2UZJ7VbILNUGeZ4ZMRSdONwYc1dH1QIufwvZKqDdpG8ds3OWY7AMUfJZYq3qtbgunWWw== X-Received: by 2002:a63:4503:: with SMTP id s3mr2696201pga.119.1599134770782; Thu, 03 Sep 2020 05:06:10 -0700 (PDT) Received: from localhost.localdomain ([117.210.209.248]) by smtp.gmail.com with ESMTPSA id s1sm2922022pgh.47.2020.09.03.05.06.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 Sep 2020 05:06:10 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v3 4/4] arm64: kgdb: Round up cpus using IPI_CALL_NMI_FUNC Date: Thu, 3 Sep 2020 17:35:12 +0530 Message-Id: <1599134712-30923-5-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1599134712-30923-1-git-send-email-sumit.garg@linaro.org> References: <1599134712-30923-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200903_080612_652713_2BCCD1AB X-CRM114-Status: GOOD ( 16.74 ) 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:541 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_AU Message has a valid DKIM or DK signature from author's domain -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 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: 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_CALL_NMI_FUNC. And in case a particular arm64 platform doesn't supports pseudo NMIs, IPI_CALL_NMI_FUNC 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/kgdb.c | 21 +++++++++++++++++++++ arch/arm64/kernel/smp.c | 3 ++- 3 files changed, 31 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/kgdb.c b/arch/arm64/kernel/kgdb.c index 1a157ca3..3a8ed97 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -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 diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 572f8f5..b4760d3 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include @@ -941,7 +942,7 @@ static void do_handle_IPI(int ipinr) #endif case IPI_CALL_NMI_FUNC: - /* nop, IPI handlers for special features can be added here. */ + ipi_kgdb_nmicallback(cpu, get_irq_regs()); break; default: