From patchwork Thu Jun 1 21:31:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264464 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A04C4C77B7E for ; Thu, 1 Jun 2023 21:37:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=IDcBLWPb4C0LQ4nJBxnks/3aNLDycEvdunf+SpJ5ZFs=; b=Yyd1moJXk8WZ93 8kRxhUZBTD8Pz9ia+r0Gw5F5i2QRhSpDyTKZyVKmcckikyx9tyRyEEDIbO8lfD954BKj92bCZvxX9 11LITYQZ2bwA//bA9vDyUN0NBVA7IREPaOF4wrslejC/hTqCKzChzkphp1wqN1T07kBQlMid+N/89 I8rq/OBq5Px6RIz54sgut6z+EjKRU89AgvsufsEveTRJYAzGxNJbKQoPxzjP7irrqXOmrS9zq5KrF nwFDL7CD/UjjB+fus0TqdwVSMNHXSLzGShjKKW1MbxGr7YKfyjnAiD/iNHcEmx5p2itqvKLJhHTBI ur7rVTojqD01yrOrH5Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pz4-0050q2-1f; Thu, 01 Jun 2023 21:37:26 +0000 Received: from mail-pf1-x435.google.com ([2607:f8b0:4864:20::435]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pz1-0050no-2B for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:25 +0000 Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-652426346bbso542787b3a.3 for ; Thu, 01 Jun 2023 14:37:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655440; x=1688247440; 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=pZEI6Qd7tJdeWnwaS3kN3vC1A5EXJtp5KG07jP5WNyg=; b=JCAPoe0UpPAv7b1ZAoftxG1P1Hl0vpy0Cq9P6rzVeNVHhducqeN2ZSZojZbVaWW7dC V/r0eOU8zgusv6UU08goYhmBOTNL9X1E2+EeO3BOcET7CCGt7ad1tSvNoW5LKgBFJ/Sy CFgDlXkaNjTm6x7b8QEVI4t2zoTG++PINUd2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655440; x=1688247440; 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=pZEI6Qd7tJdeWnwaS3kN3vC1A5EXJtp5KG07jP5WNyg=; b=PUqNxllrfNkz8IbFwdDwgR6WcEwvTPUiAcExpIt1+v1mLYjpnUwkLSmWm0AbTJaUSP oTh3sTp0PuKVY1jBsRNR5ZNqXf+Cy2Vdausx2akD5r+FtoYekzlkLLklNS5cP2nnE6Cx HMZuXWibY/MsnTcrPhx6Mfz/KK6fclcJf7KmQppFeNwD5P9LQrrw0urdYAni9AdNeTNk gmu0GzzHme6aICBeUYSWy9QC9AQ8g5nM0Cexfek0CFuXd3L7EqUNQ7ZRbqIsSyUa0O+B gIo6c5aBpxm3cGLvcqBZWhDVZBkKSE6VO1PbaupOnJTzjWFqMHc3T9KYLkFCBhazmB7l 3FbA== X-Gm-Message-State: AC+VfDzN9+VYYzQ+Sw8MtQ8vK1FvFqOh4b935zmpEMrZtsJ7nLVh/QsO WEpZXg6tdmg8jjlT0WD7C94pGQ== X-Google-Smtp-Source: ACHHUZ7TxkqQeHk3f5nB+sAADSHmxXcXgS1PF5xyCA13nK+lN+RUiZlRh2TxB02uIQ36XVKsZ9fK0A== X-Received: by 2002:a05:6a00:841:b0:643:6aed:3a9 with SMTP id q1-20020a056a00084100b006436aed03a9mr9872210pfk.0.1685655440701; Thu, 01 Jun 2023 14:37:20 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:11b8:2d2:7e02:6bff]) by smtp.gmail.com with ESMTPSA id g22-20020aa78756000000b0064d48d98260sm5319534pfo.156.2023.06.01.14.37.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:20 -0700 (PDT) From: Douglas Anderson To: Mark Rutland , Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier Cc: linux-perf-users@vger.kernel.org, ito-yuichi@fujitsu.com, Chen-Yu Tsai , Ard Biesheuvel , Stephen Boyd , Peter Zijlstra , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, kgdb-bugreport@lists.sourceforge.net, Masayoshi Mizuma , "Rafael J . Wysocki" , Lecopzer Chen , Douglas Anderson , Wei Li , linux-kernel@vger.kernel.org Subject: [PATCH v9 7/7] arm64: kgdb: Roundup cpus using the debug IPI Date: Thu, 1 Jun 2023 14:31:51 -0700 Message-ID: <20230601143109.v9.7.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> X-Mailer: git-send-email 2.41.0.rc2.161.g9c6817b8e7-goog In-Reply-To: <20230601213440.2488667-1-dianders@chromium.org> References: <20230601213440.2488667-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230601_143723_714377_69CA5471 X-CRM114-Status: GOOD ( 16.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Sumit Garg Let's use the debug IPI for rounding up CPUs in kgdb. When the debug IPI is backed by an NMI (or pseudo NMI) then this will let us debug even hard locked CPUs. When the debug IPI isn't backed by an NMI then this won't really have any huge benefit but it will still work. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- 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/ipi_debug.c | 5 +++++ arch/arm64/kernel/kgdb.c | 14 ++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c index 6984ed507e1f..5794894d94f1 100644 --- a/arch/arm64/kernel/ipi_debug.c +++ b/arch/arm64/kernel/ipi_debug.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -40,6 +41,7 @@ void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) static irqreturn_t ipi_debug_handler(int irq, void *data) { irqreturn_t ret = IRQ_NONE; + unsigned int cpu = smp_processor_id(); /* * NOTE: Just like in arch_trigger_cpumask_backtrace(), we're calling @@ -49,6 +51,9 @@ static irqreturn_t ipi_debug_handler(int irq, void *data) 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 4e1f983df3d1..9c4c47507cd4 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -20,6 +20,8 @@ #include #include +#include "ipi_debug.h" + struct dbg_reg_def_t dbg_reg_def[DBG_MAX_REG_NUM] = { { "x0", 8, offsetof(struct pt_regs, regs[0])}, { "x1", 8, offsetof(struct pt_regs, regs[1])}, @@ -356,3 +358,15 @@ 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; + + cpumask_copy(&mask, cpu_online_mask); + cpumask_clear_cpu(raw_smp_processor_id(), &mask); + if (cpumask_empty(&mask)) + return; + + arm64_debug_ipi(&mask); +}