From patchwork Mon Nov 2 11:44:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11873703 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=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 44C07C2D0A3 for ; Mon, 2 Nov 2020 11:47:55 +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 C819821D91 for ; Mon, 2 Nov 2020 11:47:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="eJY/mWaD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="uCcmpbko" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C819821D91 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=wkzX+uRsj+xfLRgjXNDQiX+FUIoIs4tNIscFwT6umKA=; b=eJY/mWaDY+O8akgINu9fc3Y+rv IpjxboSsn1NYTJLWbPNHjT1mq8qcrFCIx3iwM6TXNBw/qhAm1LiuZX1LmZydDUpJtSZY9XLWcIONH RzeHsfuK6fQsx7jpFa1PbQdW8LvDHqMJDRjcWwen3EdqYHyk1yCjYG8QQvthw5Hx1mKuO8Xeslxcm LSQEnu5ePLj6/B44A8ILi/CoAZ1I2y4/MTBGNOIMfOn+E+LT/zI00x8bZeul5gL0LESQWwU3ynJc1 LBspUOXQOUU4T0RnhpbPz4nq/rlH8lJFBiL8cPuCrQSHi6JgvXb7XCs0AUpnC94ooXIj1wkkvphFz FWPdQ2Pg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kZYIw-0007hd-Pj; Mon, 02 Nov 2020 11:47:18 +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 1kZYIM-0007Ql-0U for linux-arm-kernel@lists.infradead.org; Mon, 02 Nov 2020 11:46:43 +0000 Received: by mail-pg1-x541.google.com with SMTP id x13so10556063pgp.7 for ; Mon, 02 Nov 2020 03:46:41 -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=JyvPCaqqbOYfCXpYx0pOVqmUQ12hYhEPEwMON22pNjk=; b=uCcmpbkowm5jgVzKL5iyPFHUhu/8J3iCv9LXeYwdXeL0hGI1Lcu7XVewGbCxodYOqi Uf67FbBxpsW5SKTmkpPHTDL0w4EiYZX7WMblNDDAm4+FSg4Hs+wZ9Sz70B3pUHPF0oQn 44q18yg4+jIlgmULBSgTvbTsnwRC7b+YmVZjZXlDoYyc85PDhTsi+645DPsajTudK96v mNa/J+dBSFYD1BopcjX4zTxQY5Om0JD0iUcYMz9arNALeRncogCniUb1qlIj+sC1q+2m 7DmOPf0nu6RNqv7qF4L0V8P1R/n2xF3qKsCA1IbccTPBH7b0sTq75OoLX8vrU91wvE4Q bFww== 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=JyvPCaqqbOYfCXpYx0pOVqmUQ12hYhEPEwMON22pNjk=; b=CNXSVyKsINSuNZUlc2eSKiRPwOms6UuKUqRPy1xELGVCgJ4ofmN5r/Ml+oqh9Te0b8 At3TcKWWUwAKsuyA4VvFU0ZoQZFZQCN93UKPBxE5eX8rIr0NLsIZGX3kQzbWGCV6Qr8H ztjg8PSFhiIcOTcAs0lLx7kBRtUxNKJ7X1xFanIiur1AI/bPGY+2nVbc5xVNAd1/ve3m 10dG+sdgBeaZlPe9PSP0ZCJRxz1+SJ3hI8ZBkYuOL5OANdLQxm05MlfcklI/8pDBGQBU 372eEEsCsqPyKIOzbrSRlc1SH0fJsuQdF8q/8oRcSJwpI6fmXorsJgLlCxyW9CGD3BH3 Xung== X-Gm-Message-State: AOAM532GJfFwXcHNJa1qAtP/WtXMk0871GNrFdSF3OtEpo6rJiZOtyKj SK9mRNk6crjCNcPrJbYALoO1hw== X-Google-Smtp-Source: ABdhPJxya51ixKRZ4J+w5F3LFYNiyvEMS5yCU1E+CoRLMD+YzEfvZmLOlP27VhF4kmnTj0B5cnUOLQ== X-Received: by 2002:a17:90b:111:: with SMTP id p17mr17762114pjz.159.1604317600138; Mon, 02 Nov 2020 03:46:40 -0800 (PST) Received: from localhost.localdomain ([122.173.169.225]) by smtp.gmail.com with ESMTPSA id y5sm14276184pfq.79.2020.11.02.03.46.32 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 02 Nov 2020 03:46:39 -0800 (PST) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org, daniel.thompson@linaro.org Subject: [PATCH v7 7/7] arm64: kgdb: Roundup cpus using IPI as NMI Date: Mon, 2 Nov 2020 17:14:47 +0530 Message-Id: <1604317487-14543-8-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_064642_347023_1FBE42E3 X-CRM114-Status: GOOD ( 16.99 ) 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 arm64 platforms with GICv3 or later supports pseudo NMIs which can be leveraged to roundup CPUs which are stuck in hard lockup state with interrupts disabled that wouldn't be possible with a normal IPI. So instead switch to roundup CPUs using IPI turned as NMI. And in case a particular arm64 platform doesn't supports pseudo NMIs, it will switch back to default kgdb CPUs roundup mechanism. Signed-off-by: Sumit Garg --- arch/arm64/kernel/ipi_nmi.c | 5 +++++ arch/arm64/kernel/kgdb.c | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 597dcf7..898d69c 100644 --- a/arch/arm64/kernel/ipi_nmi.c +++ b/arch/arm64/kernel/ipi_nmi.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -45,10 +46,14 @@ bool arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) static irqreturn_t ipi_nmi_handler(int irq, void *data) { irqreturn_t ret = IRQ_NONE; + unsigned int cpu = smp_processor_id(); if (nmi_cpu_backtrace(get_irq_regs())) ret = IRQ_HANDLED; + if (!kgdb_nmicallback(cpu, get_irq_regs())) + ret = IRQ_HANDLED; + return ret; } diff --git a/arch/arm64/kernel/kgdb.c b/arch/arm64/kernel/kgdb.c index 1a157ca3..371b176 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,20 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +void kgdb_roundup_cpus(void) +{ + struct cpumask mask; + + if (!arm64_supports_nmi()) { + kgdb_smp_call_nmi_hook(); + return; + } + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return; + + arm64_send_nmi(&mask); +}