From patchwork Wed Apr 19 22:56:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13217648 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 83208C6FD18 for ; Wed, 19 Apr 2023 23:00:59 +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=Yh4re/1h8PaT9GnAAaArMejjAYe3eKpaTgb84PgTg0g=; b=c0Q5VNX+fpxPLu 4fXD4FdrjvZF4B6txqAM7YUEKAsx5B4UArAiTeBwzmiBQwQ6eFv3OUwmQTWZ7ApoRyo0pwWdAl0ax WtJ+d7chvC9QYkGu9LEUnKn7W0DzEShKRgCVAdDxVE8IaUkoMiR8nTqunFBXlgf6cEmk4TxzuJCbx Ld94ZVy2f2HZ+3JfDXZ6jMglM2JNfl6OWxQ0e2exvvGqL7UHwSpBpdp3q0Zby1SArMiB67On6XQoR HsGsV0IdjteMP+Dd29Lwv62g6FVzq/sKIexwKFzPY3mcr+5EPCCnQmiR5S1F013WosCaVy5ktjcFY lTmhycto/TmUgmaCHV8Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1ppGmb-006a49-0P; Wed, 19 Apr 2023 23:00:13 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGlz-006Zbz-0n for linux-arm-kernel@bombadil.infradead.org; Wed, 19 Apr 2023 22:59:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=HWZTrwd5TxmiYLg/mD/63PXcodsl+Y0F8uDPTGYpPFY=; b=g3y1d0DPbiuq9QbIcTjd9ktrk9 aiGE+jUUw0H7/xKBpmRt7nfI2eeKsxcrP7VgqvJcCrx1xvZSXyGcfH06sa2tDHE3R7F9ZcnLckg8P J85BlHWuFrrH9YgOyzlwbcQJIR7XH1QF/PauGxUuTznwcDi7N9aAMJXjTcl4jqMnnXV9FrZrfdkMd QpI83WWRYcSqmempf43I5iUBc5lH1uiCUob4kUuTodp/gpna5S07sLzmdhxvzFWJYL4QrQRvwSSWO 7DNxwC3g9s+TLnZLSqwcAbk5oJ2XuD0LywL6MoYa/rDMgJmxcquKCI74rkgGqVvChxlGCaZvRmkaW fFQP+lZQ==; Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1ppGjv-0022GE-1r for linux-arm-kernel@lists.infradead.org; Wed, 19 Apr 2023 22:59:32 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63b5ce4f069so496046b3a.1 for ; Wed, 19 Apr 2023 15:57:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1681945042; x=1684537042; 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=HWZTrwd5TxmiYLg/mD/63PXcodsl+Y0F8uDPTGYpPFY=; b=ENMXPNPKpUB8x1TeX9CInNTf6Pzm3ER8KeB8ofn5pxz8+lYuSyslgYS+81+WV7V/1A LEf1UqVF5i1wcOYXFEEwNvpTG7LVOyK7V5Mhz7v0lcNNeXQSBJN/9y2kPBa/eges+Jb3 b6xm1J9kPVn558DdKvWhugxeLv8noIfLhyE0A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681945042; x=1684537042; 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=HWZTrwd5TxmiYLg/mD/63PXcodsl+Y0F8uDPTGYpPFY=; b=OBiEOJV3OWwzq9WoKaCdWw5XMIS11+y3oxAFH2px7ZC5ofjcg9dRTwXs7//MhQHfko OBOuBC6UtIWYrBxgpPQrFfzKacJ5FSEhHAyzubakItF5f12eWCifZmeW9KcOaNF4dK9Z 7CgB2g4E2k+wsCvuxTkONLh7ZjckDHwFj8sRpGuhRachxPBmpMz+p7+bicbCglyKjeYB ocaSh0VKvLhSdWzvEpWHofjakapZfyvggDjiCvl3MydBUFRNnDHcqVyWmm9LdnSA9MKm Rxb51QMW3EcYW/Y4534ZUrCufBQ2GSIoCzHwvyIv6ouh3et5l6JDmeit1xqf13Ab1mt3 vZBQ== X-Gm-Message-State: AAQBX9eAPbxo3sFfIx29jz2RzLgPQwMfGrs5mxY7W1wlr5n8IkohA6La 5JW5q9vo0WUU0utA8PySgA54aA== X-Google-Smtp-Source: AKy350bzal91TPSNwTZw0WiWqcU5p5zvcdk0BkVsNFuBNbks1jS5AwavXMPCBAcH6HwZUkYAxgIWew== X-Received: by 2002:a05:6a20:8b2f:b0:cc:5f27:d003 with SMTP id l47-20020a056a208b2f00b000cc5f27d003mr42212pzh.56.1681945041867; Wed, 19 Apr 2023 15:57:21 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:9d:2:8b1:fa03:670e:b784]) by smtp.gmail.com with ESMTPSA id h15-20020a17090aea8f00b00246ea338c96sm1847101pjz.53.2023.04.19.15.57.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 15:57:21 -0700 (PDT) From: Douglas Anderson To: Catalin Marinas , Will Deacon , Sumit Garg , Daniel Thompson , Marc Zyngier , Mark Rutland Cc: ito-yuichi@fujitsu.com, kgdb-bugreport@lists.sourceforge.net, Chen-Yu Tsai , Masayoshi Mizuma , Peter Zijlstra , Ard Biesheuvel , "Rafael J . Wysocki" , linux-arm-kernel@lists.infradead.org, Stephen Boyd , Lecopzer Chen , Thomas Gleixner , linux-perf-users@vger.kernel.org, Douglas Anderson , Alexandru Elisei , Masayoshi Mizuma , linux-kernel@vger.kernel.org Subject: [PATCH v8 09/10] arm64: kgdb: Roundup cpus using IPI as NMI Date: Wed, 19 Apr 2023 15:56:03 -0700 Message-ID: <20230419155341.v8.9.I2ef26d1b3bfbed2d10a281942b0da7d9854de05e@changeid> X-Mailer: git-send-email 2.40.0.634.g4ca3ef3211-goog In-Reply-To: <20230419225604.21204-1-dianders@chromium.org> References: <20230419225604.21204-1-dianders@chromium.org> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_235929_040909_A2563A70 X-CRM114-Status: GOOD ( 14.93 ) 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 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 Tested-by: Chen-Yu Tsai Signed-off-by: Douglas Anderson --- (no changes since v1) 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 c592e92b8cbf..2adaaf1519e5 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 cda9c1e9864f..2c85bc1df013 100644 --- a/arch/arm64/kernel/kgdb.c +++ b/arch/arm64/kernel/kgdb.c @@ -17,6 +17,7 @@ #include #include +#include #include #include @@ -354,3 +355,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); +}