From patchwork Thu Oct 29 14:56:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sumit Garg X-Patchwork-Id: 11866599 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 CB63BC4363A for ; Thu, 29 Oct 2020 15:00:33 +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 498B82067C for ; Thu, 29 Oct 2020 15:00:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="zckRqa9N"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="n+vTpMTQ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 498B82067C 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=LQ74cLauy6cXcMzbICfGpsP2KyvD8tpmuN7hUOervM0=; b=zckRqa9Nz4b5sRrJwB1GbEq8iP 5F6KDo5h104Ph+mOC1qTPzIDJ/HCLifdBnXm+BKRUjjWiNZbVaTyW6a6F7s+4DMI25Ygr1BafU85k xQlbOg4nGg9Sni/OMejBgd54IJatDF64UN87pvbUn4qfCs/4FuNgY6WRJl2wfM6jLqXHfzR5LBXRB oo5hd3eaAxZ01lSYrfnAMtt+kHyTibY4iEGOzfsHlbjInev/crpMs14dVxjduZ5xQpg89F8Esnvf5 MdIYLIYw4ew7vWZc99hsL2NSf1ZgZJwoPqQL+aMMUxs1atrWBnbtv5/5ofDZgXgbgDQUaTbEujnTs jxz9SQYg==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY9PD-0004pl-Jc; Thu, 29 Oct 2020 14:59:59 +0000 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kY9OV-0004YJ-3T for linux-arm-kernel@lists.infradead.org; Thu, 29 Oct 2020 14:59:19 +0000 Received: by mail-pl1-x642.google.com with SMTP id t6so1400126plq.11 for ; Thu, 29 Oct 2020 07:59:14 -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=p2BcD1V2PWIC84tedyjPNBhOL9YmKQfq2/p2+3YKmlM=; b=n+vTpMTQwDqndje9E2gUY+QXt7Qn9stwgTDRJVc0Cb2sT9hBHygE98lnxVG0ts+MDi /o6XKBcMYGUY+P667hm/S4Q4mSnWcAPronjlvdfnJM73yqvIfjttWAKSf5Jskef3zhN0 evwSzWN0/Y7S52GsN5KSLAgUTXGLSclADgHcOAWt0/aDq2JzFi3aacKFk49xlKIB/3on 3TC13ZIo2vI9A2lDoROQlyqL2+IdRMfsRKM4bj8eua2ExXB55m4eeSeLvshwkQK9G8YN I5xYYQGNNIb4u0pOelBmyBqijvUZzbzPvPVE1l3zQupUh/v/3fQZuFt5Bft8kuOlOIJ9 BtNg== 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=p2BcD1V2PWIC84tedyjPNBhOL9YmKQfq2/p2+3YKmlM=; b=X3t6/L0XjNbLuuEHbVTw+2ufTWfwDubg/0lzLqbqyUAmEXT3ut4nXIEOeYsADA3Nmc 2N7NJAC8qeB4bjR+S0IL58hBp2m5QaE+b3XQBFHJz3OHSJCy9WPh3krtbJW7/UgUXKCH ggPrfbdsOIrCI05TmFe0i1wIzV1gS9y4aWge+O7/DT6HMLgS4/uGH+RuUdcDmtT4zLux +m0WfjNktFknjsp91XvXa7qNamJ+fewSSiCTwyuVxNi+VT0wHzrxXkxlkURci4U88Lyf ibNLtbziJc70Wmww2pQ+CsPCU37y0e940kTSFb9OCFWpKq76m9rEvmvug3Rhak6oVwPp G4/g== X-Gm-Message-State: AOAM5334YUqdMoIQejoQUs/SEREVBC6seh+72Nf1A5N9MO2HSvNlTsnH REsXYUABOGD7Zv3j7YmnLNWYZg== X-Google-Smtp-Source: ABdhPJwzdKIE9Z+RU535miYWHiUs7hW+ACKuH9/ZGTNzlFy1YROrCmeOP6o4woJU5feSQy9V41Wcyg== X-Received: by 2002:a17:902:bf43:b029:d6:19b1:7942 with SMTP id u3-20020a170902bf43b02900d619b17942mr4289008pls.61.1603983552904; Thu, 29 Oct 2020 07:59:12 -0700 (PDT) Received: from localhost.localdomain ([117.252.71.231]) by smtp.gmail.com with ESMTPSA id j11sm3085082pfc.64.2020.10.29.07.59.04 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Oct 2020 07:59:12 -0700 (PDT) From: Sumit Garg To: maz@kernel.org, catalin.marinas@arm.com, will@kernel.org Subject: [PATCH v6 7/7] arm64: kgdb: Roundup cpus using IPI as NMI Date: Thu, 29 Oct 2020 20:26:27 +0530 Message-Id: <1603983387-8738-8-git-send-email-sumit.garg@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1603983387-8738-1-git-send-email-sumit.garg@linaro.org> References: <1603983387-8738-1-git-send-email-sumit.garg@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201029_105915_312110_2953A8BC X-CRM114-Status: GOOD ( 18.06 ) 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, 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/include/asm/kgdb.h | 9 +++++++++ arch/arm64/kernel/ipi_nmi.c | 5 +++++ arch/arm64/kernel/kgdb.c | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 49 insertions(+) diff --git a/arch/arm64/include/asm/kgdb.h b/arch/arm64/include/asm/kgdb.h index 21fc85e..c3d2425 100644 --- a/arch/arm64/include/asm/kgdb.h +++ b/arch/arm64/include/asm/kgdb.h @@ -24,6 +24,15 @@ static inline void arch_kgdb_breakpoint(void) extern void kgdb_handle_bus_error(void); extern int kgdb_fault_expected; +#ifdef CONFIG_KGDB +extern bool kgdb_ipi_nmicallback(int cpu, void *regs); +#else +static inline bool kgdb_ipi_nmicallback(int cpu, void *regs) +{ + return false; +} +#endif + #endif /* !__ASSEMBLY__ */ /* diff --git a/arch/arm64/kernel/ipi_nmi.c b/arch/arm64/kernel/ipi_nmi.c index 597dcf7..6ace182 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_ipi_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..c26e710 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,37 @@ int kgdb_arch_remove_breakpoint(struct kgdb_bkpt *bpt) return aarch64_insn_write((void *)bpt->bpt_addr, *(u32 *)bpt->saved_instr); } + +bool kgdb_ipi_nmicallback(int cpu, void *regs) +{ + if (atomic_read(&kgdb_active) != -1) { + kgdb_nmicallback(cpu, regs); + return true; + } + + return false; +} + +static void kgdb_smp_callback(void *data) +{ + unsigned int cpu = smp_processor_id(); + + if (atomic_read(&kgdb_active) != -1) + kgdb_nmicallback(cpu, get_irq_regs()); +} + +bool kgdb_arch_roundup_cpus(void) +{ + struct cpumask mask; + + if (!arm64_supports_nmi()) + return false; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return false; + + arm64_send_nmi(&mask); + return true; +}