From nobody Thu Dec 18 14:28:53 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6A437EE49A6 for ; Thu, 24 Aug 2023 15:34:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242288AbjHXPdu (ORCPT ); Thu, 24 Aug 2023 11:33:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43738 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242237AbjHXPdP (ORCPT ); Thu, 24 Aug 2023 11:33:15 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D739CEE for ; Thu, 24 Aug 2023 08:33:13 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id d2e1a72fcca58-68a3082c771so21129b3a.0 for ; Thu, 24 Aug 2023 08:33:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1692891193; x=1693495993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=PpvKkEI/e7qDOTO7kkwnbGAWQL/h1j/QJekiYZuCdi8=; b=Eqf7ZSxJom24lSCPPItZp0Jzzsgydj3wjWNxBG8UNQBsegWpHjaQtL61A3HiBfuCSo J6ml8OZW3onJcqmoTMruSdhqZm2KlF9FZfDEflnZQcMt0G9ngDavylngBuvI7gJwipef +GFSyITHnIR+HkAukdoTDl81UHsm3QEZjrhug= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692891193; x=1693495993; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=PpvKkEI/e7qDOTO7kkwnbGAWQL/h1j/QJekiYZuCdi8=; b=KNunR+Sp8uju8wJe1/LSzZ542NzA/SGB4B75Mm0DuXkp3iv7xIoxBOMJIsBWmGgkdk lSh7IV2fT2JFJSZf6fS+Jh+6N+XaA+sGm1V57PbYG5z0c5hquOVRSvp/ZM/l3712tsNq gaGfuba4y7Bvi4Gvb9eUnBc0NDIdbeLYQ8UYby29agT6ObVyiEL3s06VBSQFMcEj9Qtk 82NdpuI8rDQgq0nlhS/xa8XZUHyB6C6k82oT8zLW2lu8YzvAtxm6buW7oNI4hsS5Pg0X dswzFejekUc2VUXG8AYRNrxfIEXbeeihL4dYTq0i5OMNNzX5mY9LFfb5V16rGwciZJk9 AsCA== X-Gm-Message-State: AOJu0YxiHoLFBCj1Y52uzQH1aa/yxghSAb0flirW0/ty9TGru/4oGo3U /8e9nW2DThchg8GYd3MlRV0H4tO8lMUKkJzc8xX0TiHF X-Google-Smtp-Source: AGHT+IH3Wlo4UhfEjU/WdEk/Y/44LnzFs3Gaq+1amqWxjKrBJ8EosqQauQzhM/dQC7jvUfImtbjO5A== X-Received: by 2002:a05:6a00:ccd:b0:68a:45a1:c0f7 with SMTP id b13-20020a056a000ccd00b0068a45a1c0f7mr20902029pfv.8.1692891192681; Thu, 24 Aug 2023 08:33:12 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:afa3:fcf5:1b7f:f7e2]) by smtp.gmail.com with ESMTPSA id m30-20020a63711e000000b0056365ee8603sm11631337pgc.67.2023.08.24.08.33.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 24 Aug 2023 08:33:12 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: "Rafael J . Wysocki" , Ard Biesheuvel , Thomas Gleixner , kgdb-bugreport@lists.sourceforge.net, Lecopzer Chen , linux-perf-users@vger.kernel.org, Masayoshi Mizuma , Chen-Yu Tsai , linux-arm-kernel@lists.infradead.org, ito-yuichi@fujitsu.com, Stephen Boyd , Peter Zijlstra , Douglas Anderson , D Scott Phillips , Josh Poimboeuf , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH v11 6/6] arm64: kgdb: Implement kgdb_roundup_cpus() to enable pseudo-NMI roundup Date: Thu, 24 Aug 2023 08:30:32 -0700 Message-ID: <20230824083012.v11.6.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> X-Mailer: git-send-email 2.42.0.rc1.204.g551eb34607-goog In-Reply-To: <20230824153233.1006420-1-dianders@chromium.org> References: <20230824153233.1006420-1-dianders@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Up until now we've been using the generic (weak) implementation for kgdb_roundup_cpus() when using kgdb on arm64. Let's move to a custom one. The advantage here is that, when pseudo-NMI is enabled on a device, we'll be able to round up CPUs using pseudo-NMI. This allows us to debug CPUs that are stuck with interrupts disabled. If pseudo-NMIs are not enabled then we'll fallback to just using an IPI, which is still slightly better than the generic implementation since it avoids the potential situation described in the generic kgdb_call_nmi_hook(). Co-developed-by: Sumit Garg Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson Reviewed-by: Daniel Thompson Reviewed-by: Stephen Boyd --- I debated whether this should be in "arch/arm64/kernel/smp.c" or if I should try to find a way for it to go into "arch/arm64/kernel/kgdb.c". In the end this is so little code that it didn't seem worth it to find a way to export the IPI defines or to otherwise come up with some API between kgdb.c and smp.c. If someone has strong feelings and wants this to change, please shout and give details of your preferred solution. FWIW, it seems like ~half the other platforms put this in "smp.c" with an ifdef for KGDB and the other half put it in "kgdb.c" with an ifdef for SMP. :-P (no changes since v10) Changes in v10: - Don't allocate the cpumask on the stack; just iterate. - Moved kgdb calls to smp.c to avoid needing to export IPI info. - kgdb now has its own IPI. Changes in v9: - Remove fallback for when debug IPI isn't available. - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. arch/arm64/kernel/smp.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index 4566934aaf9f..d440c8b21ea7 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -32,6 +32,7 @@ #include #include #include +#include #include #include =20 @@ -79,6 +80,7 @@ enum ipi_msg_type { * with trace_ipi_* */ IPI_CPU_BACKTRACE =3D NR_IPI, + IPI_KGDB_ROUNDUP, MAX_IPI }; =20 @@ -868,6 +870,22 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *m= ask, int exclude_cpu) nmi_trigger_cpumask_backtrace(mask, exclude_cpu, arm64_backtrace_ipi); } =20 +#ifdef CONFIG_KGDB +void kgdb_roundup_cpus(void) +{ + int this_cpu =3D raw_smp_processor_id(); + int cpu; + + for_each_online_cpu(cpu) { + /* No need to roundup ourselves */ + if (cpu =3D=3D this_cpu) + continue; + + __ipi_send_single(ipi_desc[IPI_KGDB_ROUNDUP], cpu); + } +} +#endif + /* * Main handler for inter-processor interrupts */ @@ -919,6 +937,10 @@ static void do_handle_IPI(int ipinr) nmi_cpu_backtrace(get_irq_regs()); break; =20 + case IPI_KGDB_ROUNDUP: + kgdb_nmicallback(cpu, get_irq_regs()); + break; + default: pr_crit("CPU%u: Unknown IPI message 0x%x\n", cpu, ipinr); break; @@ -949,6 +971,7 @@ static bool ipi_should_be_nmi(enum ipi_msg_type ipi) case IPI_CPU_STOP: case IPI_CPU_CRASH_STOP: case IPI_CPU_BACKTRACE: + case IPI_KGDB_ROUNDUP: return true; default: return false; --=20 2.42.0.rc1.204.g551eb34607-goog