From patchwork Thu Jun 1 21:31:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264458 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 8F9F7C7EE29 for ; Thu, 1 Jun 2023 21:37:36 +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=LLaVbJAf35aJq8x1nvzZAUFQpvj/B7lm1X6sPbPn07g=; b=pYqSPkYG0J4I9C 9NjFZt4IZWFA/zgHKtnwU+mb1S3m5iFGYJ53q7JrhfraDS394e0bumIFqYQ+ZnYCUGiXnxcMJco9y CjJnsSE0C1KU/POxn2J5hh8MihAyavK3h4Q1P3YNKaeObdW/kuerkYsJk/880PKOSUbDcFMQLlVjO qrlgICp2Wzj3McJzHkJmqLN+VPWslJqOaKmQXXlJkyK4e9hh1Z9jA3UslxN5XyxzsofQ9GD7gNCP2 wgKTOH1UmaENylM452fv8ygRxEHiSSqI0VSxKh4MWWNLwNbE4v9DqheFR2N0tPsJWk6yAnBI/S1Js IN9trBiXhfEiMuE/jGNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyq-0050hy-0b; Thu, 01 Jun 2023 21:37:12 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyn-0050fX-1x for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:10 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-652328c18d5so580737b3a.1 for ; Thu, 01 Jun 2023 14:37:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655427; x=1688247427; 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=HjRakdb30yszASmxf/wTOyUnLRsbS0tBSqMyHI/mgmg=; b=BuG16CgsJZuRqklwqhtraGtO9mDBkjKRduhSYXiCHYmDshIggjlraGD2H9A4z6yorm wBu2dEQorFkxnRHLq3Cn+M+LkZWex3ajMYBEgSEujM238OkqShSG0aa2MrkveBlrCXC5 p6NW7FtAcuIScDFj5KSELcmbgvEEVbSabk3PI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655427; x=1688247427; 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=HjRakdb30yszASmxf/wTOyUnLRsbS0tBSqMyHI/mgmg=; b=ca4JTGEWoo8ZLliYsMsl5HELG5EhPy+cnC7hjgycIfHWOarDPrOrispfDqYolm2BbB LFkwqhLROy8pRhtwtsdfV8C4qGJnsrznNKF2nYUElMD5ZHwCKY1VwiTWMxRvRCOuY+dK 4itkcqbbPC8ntE4g0/ifp00AygmEEEwvj1Sq538oNe3w2v3mYias3Jk8l4RKkWvHt4e4 rur+zObiyzGr+R8WQMs4Qp6B99M/RJ7pGFeTeWrTOjjJZnMIQH0RkUh9Qvmyi7foNY0y e9Ejjb1aDzK5a+nRKBz/lqwjVAfqVO2HxWBJLd3NoyiToMzi5Z2/KyZLdYjO9KHMIZCb eU8g== X-Gm-Message-State: AC+VfDz4qserpMiITgp7MKGKUzFLdIxwQa/S7Hghw6s2t52IFhWi81CY 06TU4CM7ucQx9Zs2uKJCP99blQ== X-Google-Smtp-Source: ACHHUZ7X4JWk69pwtWfobliPNOJVZLyvG8aXSBcL3S43aA7yIba6lfLCLzZNDwufKt9JnCsD52RTZQ== X-Received: by 2002:a05:6a21:1647:b0:111:6a14:7d0 with SMTP id no7-20020a056a21164700b001116a1407d0mr6606398pzb.60.1685655427621; Thu, 01 Jun 2023 14:37:07 -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.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:07 -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 , Masayoshi Mizuma , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v9 1/7] irqchip/gic-v3: Enable support for SGIs to act as NMIs Date: Thu, 1 Jun 2023 14:31:45 -0700 Message-ID: <20230601143109.v9.1.I1223c11c88937bd0cbd9b086d4ef216985797302@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_143709_645123_6AFA7FB3 X-CRM114-Status: GOOD ( 14.35 ) 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 Add support to handle SGIs as pseudo NMIs. As SGIs or IPIs default to a special flow handler: handle_percpu_devid_fasteoi_ipi(), so skip NMI handler update in case of SGIs. Also, enable NMI support prior to gic_smp_init() as allocation of SGIs as IRQs/NMIs happen as part of this routine. Signed-off-by: Sumit Garg Reviewed-by: Masayoshi Mizuma Tested-by: Chen-Yu Tsai Signed-off-by: Douglas Anderson --- (no changes since v1) drivers/irqchip/irq-gic-v3.c | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 0c6c1af9a5b7..ed37e02d4c5f 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c @@ -525,6 +525,7 @@ static u32 gic_get_ppi_index(struct irq_data *d) static int gic_irq_nmi_setup(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (!gic_supports_nmi()) return -EINVAL; @@ -542,16 +543,22 @@ static int gic_irq_nmi_setup(struct irq_data *d) return -EINVAL; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Setting up PPI as NMI, only switch handler for first NMI */ if (!refcount_inc_not_zero(&ppi_nmi_refs[idx])) { refcount_set(&ppi_nmi_refs[idx], 1); desc->handle_irq = handle_percpu_devid_fasteoi_nmi; } - } else { + break; + default: desc->handle_irq = handle_fasteoi_nmi; + break; } gic_irq_set_prio(d, GICD_INT_NMI_PRI); @@ -562,6 +569,7 @@ static int gic_irq_nmi_setup(struct irq_data *d) static void gic_irq_nmi_teardown(struct irq_data *d) { struct irq_desc *desc = irq_to_desc(d->irq); + u32 idx; if (WARN_ON(!gic_supports_nmi())) return; @@ -579,14 +587,20 @@ static void gic_irq_nmi_teardown(struct irq_data *d) return; /* desc lock should already be held */ - if (gic_irq_in_rdist(d)) { - u32 idx = gic_get_ppi_index(d); + switch (get_intid_range(d)) { + case SGI_RANGE: + break; + case PPI_RANGE: + case EPPI_RANGE: + idx = gic_get_ppi_index(d); /* Tearing down NMI, only switch handler for last NMI */ if (refcount_dec_and_test(&ppi_nmi_refs[idx])) desc->handle_irq = handle_percpu_devid_irq; - } else { + break; + default: desc->handle_irq = handle_fasteoi_irq; + break; } gic_irq_set_prio(d, GICD_INT_DEF_PRI); @@ -2001,6 +2015,7 @@ static int __init gic_init_bases(phys_addr_t dist_phys_base, gic_dist_init(); gic_cpu_init(); + gic_enable_nmi_support(); gic_smp_init(); gic_cpu_pm_init(); @@ -2013,8 +2028,6 @@ static int __init gic_init_bases(phys_addr_t dist_phys_base, gicv2m_init(handle, gic_data.domain); } - gic_enable_nmi_support(); - return 0; out_free: From patchwork Thu Jun 1 21:31:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264460 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 C1C8FC7EE23 for ; Thu, 1 Jun 2023 21:37:38 +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=ovHsO02kbiyCJcktK7iKX0CqTN12N1jzV6asEjYh+bU=; b=t7cUZLLFiEeRzb w7t2FBcQm0Tevj60eieh8pltvH1wRs+xvk5Vk4HHpmNg/XJYgyvrGlP4Eru8dzfw90d5hI+WaPQJy 4rGWzbqapDr+j241ownQ7e9WFAGPSDk67tXy8acw4YRf4FxcCzCJd44irTXDPfTZc/PECeRKv4Hxr fLQuvtYWwZJZJwfdi+9xuURIY/GAle7Jgn+Ef9oDGvxLAMIY7DTXpNfgCzgtn40gOPqCCINLaJeo7 GXCdilrZ7FrmEwq6Vl4fouAZWMOdgkKeGLaZ67xrCaWOKzfSGhUyosxgNYKNf6HDcGRR8R0vCkf6k hLLqlpmxceZZ7lpCkSJw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyq-0050iF-2e; Thu, 01 Jun 2023 21:37:12 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyo-0050gT-1V for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:11 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-64d247a023aso1064097b3a.2 for ; Thu, 01 Jun 2023 14:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655430; x=1688247430; 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=3FwIy9pdxSPLLDGVrHowuSMAgkehvs21QOIs4DuKC6A=; b=MRdCoSujmCnjjOacpNHectteICFpfTy0Q7HRW6iFcJoXa0fZhuuEBFYooU/G8NXg2X HfAG3gvX2a17Cc1yGXHsw3CBdxIMjz24Xa8DvLZVxCCds24Mumi4TVNGg8ZmNyV/Svls MmHnVj0glIpRBoHcvAP9y7A/SWAwUDBE3yhk0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655430; x=1688247430; 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=3FwIy9pdxSPLLDGVrHowuSMAgkehvs21QOIs4DuKC6A=; b=FbB8Yg/qxDXAlLDjMYkvMwHgbJdkcUXynhLGPfTF5KmgIlunjsz1XSUxW5/EVzd4BT 7ogepoTzPh2PZbh5VRzl/wRO5BGtoGmHVCmMeC0HlskpJKyA7v6gDewbZ5h0WtTPJVON 8d34Pzl4dPo1TRfRW42d3AA/hWTku/jmea8iYi/xEtKnuTlBwLVdLgNvWWChtVMGKcGj bs7OH3WV7yDXtI1FejVfb/4XLHzFBNg5j9jfHeN5hs6ZWAHnjjn9Wbr7fiZF0ACpEI3h zGRMi7kTWaGu6reH9g14ygKcZaa8Lb6G92oixqTbje2wH4bSc2BhauEU5s4IRK/eYa8Y Ho3g== X-Gm-Message-State: AC+VfDx4lhitn7f67hUqmR5LFyHuLS0tGc3E4teEuMYpjMX8oNdp6YEX S+gilgP72lUXgAXlH7dc9TUKGQ== X-Google-Smtp-Source: ACHHUZ50Zg9SNzhD1Ge9escgQjcb0Fjlmif9dRJ8OFu2NuLSDjuQFm2OhosoWIATYrGHV8blhpW1FQ== X-Received: by 2002:a05:6a20:2451:b0:106:c9b7:c92f with SMTP id t17-20020a056a20245100b00106c9b7c92fmr8938270pzc.49.1685655429931; Thu, 01 Jun 2023 14:37:09 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:09 -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 , Frederic Weisbecker , "Gautham R. Shenoy" , Ingo Molnar , linux-kernel@vger.kernel.org Subject: [PATCH v9 2/7] arm64: idle: Tag the arm64 idle functions as __cpuidle Date: Thu, 1 Jun 2023 14:31:46 -0700 Message-ID: <20230601143109.v9.2.I4baba13e220bdd24d11400c67f137c35f07f82c7@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_143710_505254_EE83CFE9 X-CRM114-Status: GOOD ( 18.06 ) 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 As per the (somewhat recent) comment before the definition of `__cpuidle`, the tag is like `noinstr` but also marks a function so it can be identified by cpu_in_idle(). Let'a add this. After doing this then when we dump stack traces of all processors using nmi_cpu_backtrace() then instead of getting useless backtraces we get things like: NMI backtrace for cpu N skipped: idling at cpu_do_idle+0x94/0x98 NOTE: this patch won't make cpu_in_idle() work perfectly for arm64, but it doesn't hurt and does catch some cases. Specifically an example that wasn't caught in my testing looked like this: gic_cpu_sys_reg_init+0x1f8/0x314 gic_cpu_pm_notifier+0x40/0x78 raw_notifier_call_chain+0x5c/0x134 cpu_pm_notify+0x38/0x64 cpu_pm_exit+0x20/0x2c psci_enter_idle_state+0x48/0x70 cpuidle_enter_state+0xb8/0x260 cpuidle_enter+0x44/0x5c do_idle+0x188/0x30c Signed-off-by: Douglas Anderson Acked-by: Mark Rutland --- Changes in v9: - Added to commit message that this doesn't catch all cases. Changes in v8: - "Tag the arm64 idle functions as __cpuidle" new for v8 arch/arm64/kernel/idle.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm64/kernel/idle.c b/arch/arm64/kernel/idle.c index c1125753fe9b..05cfb347ec26 100644 --- a/arch/arm64/kernel/idle.c +++ b/arch/arm64/kernel/idle.c @@ -20,7 +20,7 @@ * ensure that interrupts are not masked at the PMR (because the core will * not wake up if we block the wake up signal in the interrupt controller). */ -void noinstr cpu_do_idle(void) +void __cpuidle cpu_do_idle(void) { struct arm_cpuidle_irq_context context; @@ -35,7 +35,7 @@ void noinstr cpu_do_idle(void) /* * This is our default idle handler. */ -void noinstr arch_cpu_idle(void) +void __cpuidle arch_cpu_idle(void) { /* * This should do all the clock switching and wait for interrupt From patchwork Thu Jun 1 21:31:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264462 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 64676C7EE2F for ; Thu, 1 Jun 2023 21:37:39 +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=ADajAyQExL+we9AinmB7nMGW4DHD+FQM2gXq2P4+CKc=; b=rBJoWTIZSiImlu GTCA8z5ZN87kTaGVJ7nFnJOkpN60pp00WxkowDy6iO+rP01YhpetTiC+gdww8Hi866CfkBk0L533h WGIh0nxvsc1jSJZ5bjUTFwhg7ZygduozQIZFU8sXaDRI3OUZW7wE96bUUpGV0HrYK5ZCtxfmr5OJJ a+Bag071AHt+tZbqVSB22LkVOSE1eYDh8tLs0q/Ao12mzuHpQYKlOLjeDY95Hq3DjCdxV6j4Wnxj+ q2s1PYAJJspn5MfM0bOa9RD08tZ6oGhfWb7gZzY8SPnjJZJsag2aCzZTesjdTwmfDyDomnonDuZmi DkK/e+CAwsIuOKOEixmg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyv-0050ll-0m; Thu, 01 Jun 2023 21:37:17 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyq-0050i8-2M for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:15 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-652699e72f7so471382b3a.3 for ; Thu, 01 Jun 2023 14:37:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655432; x=1688247432; 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=VxngL/nWZ9CvmSVXwg8pkM18NqkUW/hq6cWY9xHbU50=; b=aXtBMJsuEHVcZIKV7cLRpp9gJah5t0XCzX6mPhaAfDBP1dJ5ow0nIMbyHBqXyExXs/ iONAnH757E2JdGKhPAJpJ0T+0at+owiwzn2oTUIqycF0fDPlNwbji/qaAjIXJsOAh/DF EzBp3VrZJfcftxuQAMYGMNArokNyBuLgHVwN8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655432; x=1688247432; 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=VxngL/nWZ9CvmSVXwg8pkM18NqkUW/hq6cWY9xHbU50=; b=WulxU5arhBMcoIkCmQTYL5YORPUAzZhnRsUMpZ8Nsd6LTRshuszD1TFXlHX4n9Dxca VikLLaWO4RIhoESfifv5pwjjENE2O5Ge1wyPrO2FdZpsL0afjHqBNSl2PI6PXSheHTSJ fuLZt78ls18O0INRxAuZ1WgciidATEkTkobzQ6BZ7sxTxEyTr+IZk90kEnw+PD02U6f4 d/Pwjy7D2OAwihb2BEC+krsipuL4UE8q9DsYZT6lareXj5XLPl9JFW+wgOe34znHQ4R/ gOW6PEcfl4kMItFxEMYYSI+bTjrq455+D3lzsiYzLOhp0UVXTcI55709hTyjO4Vgqg4s awmQ== X-Gm-Message-State: AC+VfDwviO2m2PYJgjg0WSTIypOwZ81VHtDlhmX08G9EkvCXmrhTLktg +WMQpH7iVHoNADqwNH+nGMmLAw== X-Google-Smtp-Source: ACHHUZ5ef/rtEIYJxyW1OxKT1bSL//A95UwWPCmZBbTCdj36TOdor4jNJCZmCSlkwGKN3QsCenCWSg== X-Received: by 2002:a05:6a00:8ca:b0:64c:b45f:fc86 with SMTP id s10-20020a056a0008ca00b0064cb45ffc86mr10767019pfu.17.1685655432123; Thu, 01 Jun 2023 14:37:12 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:11 -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 , Andrey Konovalov , Masahiro Yamada , linux-kernel@vger.kernel.org Subject: [PATCH v9 3/7] arm64: Add framework for a debug IPI Date: Thu, 1 Jun 2023 14:31:47 -0700 Message-ID: <20230601143109.v9.3.Ie6c132b96ebbbcddbf6954b9469ed40a6960343c@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_143712_775192_48D83F3B X-CRM114-Status: GOOD ( 24.98 ) 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 Introduce a framework for an IPI that will be used for debug purposes. The primary use case of this IPI will be to generate stack crawls on other CPUs, but it will also be used to round up CPUs for kgdb. When possible, we try to allocate this debug IPI as an NMI (or a pseudo NMI). If that fails (due to CONFIG, an incompatible interrupt controller, a quirk, missing the "irqchip.gicv3_pseudo_nmi=1" kernel parameter, etc) we fall back to a normal IPI. NOTE: hooking this up for CPU backtrace / kgdb will happen in a future patch, this just adds the framework. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson Signed-off-by: Mark Rutland --- I didn't get any feedback from v8 patch #10 [1], but I went ahead and folded it in here anyway since it really simplfies things. If people don't like the fallback to regular IPI, I can also undo it. [1] https://lore.kernel.org/r/20230419155341.v8.10.Ic3659997d6243139d0522fc3afcdfd88d7a5f030@changeid/ Changes in v9: - Fold in v8 patch #10 ("Fallback to a regular IPI if NMI isn't enabled") - Moved header file out of "include" since it didn't need to be there. - Remove arm64_supports_nmi() - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. Changes in v8: - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param arch/arm64/kernel/Makefile | 2 +- arch/arm64/kernel/ipi_debug.c | 76 +++++++++++++++++++++++++++++++++++ arch/arm64/kernel/ipi_debug.h | 13 ++++++ 3 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 arch/arm64/kernel/ipi_debug.c create mode 100644 arch/arm64/kernel/ipi_debug.h diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile index cc22011ab66a..737838f803b7 100644 --- a/arch/arm64/kernel/Makefile +++ b/arch/arm64/kernel/Makefile @@ -34,7 +34,7 @@ obj-y := debug-monitors.o entry.o irq.o fpsimd.o \ cpufeature.o alternative.o cacheinfo.o \ smp.o smp_spin_table.o topology.o smccc-call.o \ syscall.o proton-pack.o idreg-override.o idle.o \ - patching.o + patching.o ipi_debug.o obj-$(CONFIG_COMPAT) += sys32.o signal32.o \ sys_compat.o diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c new file mode 100644 index 000000000000..b57833e31eaf --- /dev/null +++ b/arch/arm64/kernel/ipi_debug.c @@ -0,0 +1,76 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Debug IPI support + * + * Copyright (C) 2020 Linaro Limited + * Author: Sumit Garg + */ + +#include +#include +#include + +#include "ipi_debug.h" + +static struct irq_desc *ipi_debug_desc __read_mostly; +static int ipi_debug_id __read_mostly; +static bool is_nmi; + +void arm64_debug_ipi(cpumask_t *mask) +{ + if (WARN_ON_ONCE(!ipi_debug_desc)) + return; + + __ipi_send_mask(ipi_debug_desc, mask); +} + +static irqreturn_t ipi_debug_handler(int irq, void *data) +{ + /* nop, NMI handlers for special features can be added here. */ + + return IRQ_NONE; +} + +void debug_ipi_setup(void) +{ + if (!ipi_debug_desc) + return; + + if (is_nmi) { + if (!prepare_percpu_nmi(ipi_debug_id)) + enable_percpu_nmi(ipi_debug_id, IRQ_TYPE_NONE); + } else { + enable_percpu_irq(ipi_debug_id, IRQ_TYPE_NONE); + } +} + +void debug_ipi_teardown(void) +{ + if (!ipi_debug_desc) + return; + + if (is_nmi) { + disable_percpu_nmi(ipi_debug_id); + teardown_percpu_nmi(ipi_debug_id); + } else { + disable_percpu_irq(ipi_debug_id); + } +} + +void __init set_smp_debug_ipi(int ipi) +{ + int err; + + if (!request_percpu_nmi(ipi, ipi_debug_handler, "IPI", &cpu_number)) { + is_nmi = true; + } else { + err = request_percpu_irq(ipi, ipi_debug_handler, "IPI", &cpu_number); + if (WARN_ON(err)) + return; + + irq_set_status_flags(ipi, IRQ_HIDDEN); + } + + ipi_debug_desc = irq_to_desc(ipi); + ipi_debug_id = ipi; +} diff --git a/arch/arm64/kernel/ipi_debug.h b/arch/arm64/kernel/ipi_debug.h new file mode 100644 index 000000000000..f6011a09282f --- /dev/null +++ b/arch/arm64/kernel/ipi_debug.h @@ -0,0 +1,13 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __ASM_NMI_H +#define __ASM_NMI_H + +#include + +void arm64_debug_ipi(cpumask_t *mask); + +void set_smp_debug_ipi(int ipi); +void debug_ipi_setup(void); +void debug_ipi_teardown(void); + +#endif From patchwork Thu Jun 1 21:31:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264461 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 79B9BC77B7E for ; Thu, 1 Jun 2023 21:37:39 +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=C124aJHNeu/zNq7ysZ1fnsXzuAtAX4Gw9ROPh1AFRCQ=; b=yRCqFvHexwqxaV ysSbnyrB5ERuha3MNcJR234SlGZ4tWDs1zqkzUo2yo31DVvo99upyLTSIGEjLdSelzt3EY+JY1vAd v6P2imavC7fEwBPjU7IBpsf6KN4UZpqnvGRk6gsReMnc4Yvz9RU1JuVS0s0YrNCy2WZB/GhGWKik2 wdrgPnjhhTcTEwLTQvDy7CSISn1hcKxhfwHBJObQYyN4gSkcvHi3ZMpREa3cef3J8x42kWqmne+1Y iCWVX7sIavz42Ti+o5faDdKKmXrq6zTGf7i7Du68p5R8uiz4U7i0CcOkp8yVuSO29mXp1zJBzJ5GX euZ3b6RBGsTU517+jnyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyx-0050mc-00; Thu, 01 Jun 2023 21:37:19 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pys-0050jn-2h for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:16 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-64d3bc502ddso1698579b3a.0 for ; Thu, 01 Jun 2023 14:37:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655434; x=1688247434; 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=KFbc1DnTsptgPHbVgbrtLnQoZRYq2p52Sq+V7Mil0Po=; b=Y+IRG40LZKw0u4RWejoPo9t2VThioi9WMya6GxurCgZXecIGTCiWNYFwet6YeXaBL1 s6e2+jx6ksC3geJ2joOYMSft3G8UQ2LyzodMjp70BrhkADj72DmV4KOC7eg1PWGkJS7W bhnuM4cF9tMcOEK2gfzpuj7nrcaJZqp/6IeD0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655434; x=1688247434; 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=KFbc1DnTsptgPHbVgbrtLnQoZRYq2p52Sq+V7Mil0Po=; b=c4BYzgweSpbQRbeuK4ErmkU1Jz5rz9KSn07noSNYTKuT2Ne4v2urtzBQqSkpeBxx0r hWsJlBjd8UNs2uQoSf9d3orWycM+7opAxhb6FEvWXdQkg751OT8/VsT7MOclQA9di3mC KDtZSEtigDWN98k9HX8OHE8PYDAf1e7Hs4+y/0TL2NX2NWA9F/D98Kz/HpuOpZkXbtHS LcqALa9NLTUE/VqmnXsAYmApZo9ydqyE+5+aVEwRpzCLhQbw/wVqB4KFFGSEyJKls/rd 4yGDZCZb+fNPEkjpWMdaG7NOyNnb+vDHTLXLhuHPZHGjqwT6bRL+oBAG/M1tCOL6mO/Z oOeA== X-Gm-Message-State: AC+VfDxiLWYSbiMccHiLkXupeGP5CQw+QsI7dNN8f2S7Ngosc4fKbh8d On8K1QzPeBSQuLBzBnHoCJrP3g== X-Google-Smtp-Source: ACHHUZ6rVQO/ue/4i8mO1Mux6x0NhxVI4bfPrl/BtKSwVXR51RsA4b7YL68gkPubx0VgpaYp2gyoBg== X-Received: by 2002:a05:6a00:c89:b0:652:7b99:df30 with SMTP id a9-20020a056a000c8900b006527b99df30mr1613289pfv.25.1685655434352; Thu, 01 Jun 2023 14:37:14 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:13 -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 , Ben Dooks , Ingo Molnar , Josh Poimboeuf , Valentin Schneider , linux-kernel@vger.kernel.org Subject: [PATCH v9 4/7] arm64: smp: Assign and setup the debug IPI Date: Thu, 1 Jun 2023 14:31:48 -0700 Message-ID: <20230601143109.v9.4.I6d7f7d5fa0aa293c8c3374194947254b93114d37@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_143714_871625_1980DE72 X-CRM114-Status: GOOD ( 20.00 ) 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 All current arm64 interrupt controllers have at least 8 IPIs. Currently we are only using 7 of them on arm64. Let's use the 8th one as a debug IPI. This uses the new "debug IPI" infrastructure which will try to allocate this IPI as an NMI/pseudo NMI if possible. Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- I could imagine that people object to using up the last free IPI on interrupt controllers with only 8 IPIs. However, it shouldn't be a big deal. If we later need an extra IPI, it shouldn't be too hard to combine some of the existing ones. Presumably we could just get rid of the "crash stop" IPI and have the normal "stop" IPI do the crash if "waiting_for_crash_ipi" is non-zero Changes in v9: - Add a warning if we don't have enough IPIs for the NMI IPI - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. - Update commit description Changes in v8: - debug_ipi_setup() and debug_ipi_teardown() no longer take cpu param arch/arm64/kernel/smp.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/arch/arm64/kernel/smp.c b/arch/arm64/kernel/smp.c index edd63894d61e..db019b49d3bd 100644 --- a/arch/arm64/kernel/smp.c +++ b/arch/arm64/kernel/smp.c @@ -53,6 +53,8 @@ #include +#include "ipi_debug.h" + DEFINE_PER_CPU_READ_MOSTLY(int, cpu_number); EXPORT_PER_CPU_SYMBOL(cpu_number); @@ -935,6 +937,8 @@ static void ipi_setup(int cpu) for (i = 0; i < nr_ipi; i++) enable_percpu_irq(ipi_irq_base + i, 0); + + debug_ipi_setup(); } #ifdef CONFIG_HOTPLUG_CPU @@ -947,6 +951,8 @@ static void ipi_teardown(int cpu) for (i = 0; i < nr_ipi; i++) disable_percpu_irq(ipi_irq_base + i); + + debug_ipi_teardown(); } #endif @@ -968,6 +974,11 @@ void __init set_smp_ipi_range(int ipi_base, int n) irq_set_status_flags(ipi_base + i, IRQ_HIDDEN); } + if (n > nr_ipi) + set_smp_debug_ipi(ipi_base + nr_ipi); + else + WARN(1, "Not enough IPIs for NMI IPI\n"); + ipi_irq_base = ipi_base; /* Setup the boot CPU immediately */ From patchwork Thu Jun 1 21:31:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264463 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 34727C7EE29 for ; Thu, 1 Jun 2023 21:37:43 +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=qM4NuqHIzD4RBc7qZrz92NHaVDIrzGVdxDr9ESlhH5k=; b=CAK8Ow8wjeamox ymjYxw6yhOglhtcKJ2skFCRJoXqoBdXkSBugOtXN2X0rAr6WMRsbJb69XuBLL/5/bqsIZ1gpPiX+k e5opPvcf0rNoYuadbnx8OYnmjbEIGGBVVo6qrDbM6ns5Ml4+ag1Dj9oqT6D5/RbsrXtfpWLHgwBMi zwzY9noS2XFxkzlslGflQCW4kRIFYUk3DbO7g6OY+tg2zE/ciQ7nqhis1kUiKwU//vvLW88jRKIZ3 bsR4/4p6hLKVbIKD6YH5ogZrsDa4K6oNPNusgYqQ67nxceO9M8MPEP/552JMBKDZ81XfbsrpyxlBk QbdDqUK7XGWtXa5NRYyQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyy-0050nI-2F; Thu, 01 Jun 2023 21:37:20 +0000 Received: from mail-pf1-x42c.google.com ([2607:f8b0:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pyv-0050lG-0D for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:18 +0000 Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-64d18d772bdso1610830b3a.3 for ; Thu, 01 Jun 2023 14:37:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655436; x=1688247436; 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=9zVBczE5O/mOGSjCuNx2rXBFKme8bX0ZhvLdtMhoiJw=; b=gJtJ5FNgW645QFhWJrwgv+eoPxUDcKJjQ0xUeo56kyURgPks4SkoC2MQNDgXTtkZn7 QpKWQwG1Ny/ElORyKFDpyWZbKE5bj+Wp8fgVBvS+d/n6lwbgm1qW/f/93p6MP2NY714A nlF2KzG2LMv/VRRI6kZ2Dt7zapyMsrojNB0GU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655436; x=1688247436; 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=9zVBczE5O/mOGSjCuNx2rXBFKme8bX0ZhvLdtMhoiJw=; b=Edg/YjUwoBjFV7nb96BYKb8Qa/SNksx2Lo6+bPkq0j+qVsHE+C4uzRAvolGamQCsCP tr4oW9h60wQz3z6qDbI8fK9i/33e6nDqZJFU9c8TnNHBips9w+ClWgM7wjbDFx/lT9hL NmjYmOsV+q9qEbMNLpb2RFHc8MnWakz+qlBp0dQmQJ4N31S7RVqaNKolENvxtN0jfyMq v6tqmLsqMnrhUlt1kvS3DsnzKRONOmsPKdtr6sDSXHvvxwQenwNLiFXXmUnrwAl8D1+n 92gg4YS4KSwNf3/Yv3kqns8iqtwq2NWZjAWuqHfgDmJTh4ix2cZe9o0mJzc3mz+IuxgG Hnwg== X-Gm-Message-State: AC+VfDwl8ekZHL+KJhiNoTSoyPlS6K+nYJmNktGwq5J/j5TTJVWvCQ5q HtVnED78bbxTZrN5jQ/ow4WziL4Ap8nL9uxBc4Y= X-Google-Smtp-Source: ACHHUZ5+oSxNdbJJZmlNccaogK7aaVEwJBbdqRJ3q2/KAcjer9oPcCVCtZIErTbQBeOU2bnwefC/oQ== X-Received: by 2002:a05:6a00:1797:b0:651:ce88:27f5 with SMTP id s23-20020a056a00179700b00651ce8827f5mr2208089pfg.13.1685655436495; Thu, 01 Jun 2023 14:37:16 -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.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:15 -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 , linux-kernel@vger.kernel.org Subject: [PATCH v9 5/7] arm64: ipi_debug: Add support for backtrace using the debug IPI Date: Thu, 1 Jun 2023 14:31:49 -0700 Message-ID: <20230601143109.v9.5.I65981105e1f62550b0316625dd1e599deaf9e1aa@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_143717_106436_B972A7C2 X-CRM114-Status: GOOD ( 23.04 ) 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 Enable arch_trigger_cpumask_backtrace() support on arm64 using the new debug IPI. With this arm64 can now get backtraces in cases where callers of the trigger_xyz_backtrace() class of functions don't check the return code and implement a fallback. One example is `kernel.softlockup_all_cpu_backtrace`. This also allows us to backtrace hard locked up CPUs in cases where the debug IPI is backed by an NMI (or pseudo NMI). Signed-off-by: Sumit Garg Signed-off-by: Douglas Anderson --- Changes in v9: - Added comments that we might not be using NMI always. - Renamed "NMI IPI" to "debug IPI" since it might not be backed by NMI. - arch_trigger_cpumask_backtrace() no longer returns bool Changes in v8: - Removed "#ifdef CONFIG_SMP" since arm64 is always SMP arch/arm64/include/asm/irq.h | 3 +++ arch/arm64/kernel/ipi_debug.c | 25 +++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/arch/arm64/include/asm/irq.h b/arch/arm64/include/asm/irq.h index fac08e18bcd5..be2d103f316e 100644 --- a/arch/arm64/include/asm/irq.h +++ b/arch/arm64/include/asm/irq.h @@ -6,6 +6,9 @@ #include +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self); +#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace + struct pt_regs; int set_handle_irq(void (*handle_irq)(struct pt_regs *)); diff --git a/arch/arm64/kernel/ipi_debug.c b/arch/arm64/kernel/ipi_debug.c index b57833e31eaf..6984ed507e1f 100644 --- a/arch/arm64/kernel/ipi_debug.c +++ b/arch/arm64/kernel/ipi_debug.c @@ -8,6 +8,7 @@ #include #include +#include #include #include "ipi_debug.h" @@ -24,11 +25,31 @@ void arm64_debug_ipi(cpumask_t *mask) __ipi_send_mask(ipi_debug_desc, mask); } +void arch_trigger_cpumask_backtrace(const cpumask_t *mask, bool exclude_self) +{ + /* + * NOTE: though nmi_trigger_cpumask_backtrace has "nmi_" in the name, + * nothing about it truly needs to be backed by an NMI, it's just that + * it's _allowed_ to be called from an NMI. If set_smp_debug_ipi() + * failed to get an NMI (or pseudo-NMI) this will just be backed by a + * regular IPI. + */ + nmi_trigger_cpumask_backtrace(mask, exclude_self, arm64_debug_ipi); +} + static irqreturn_t ipi_debug_handler(int irq, void *data) { - /* nop, NMI handlers for special features can be added here. */ + irqreturn_t ret = IRQ_NONE; + + /* + * NOTE: Just like in arch_trigger_cpumask_backtrace(), we're calling + * a function with "nmi_" in the name but it works fine even if we + * are using a regulaor IPI. + */ + if (nmi_cpu_backtrace(get_irq_regs())) + ret = IRQ_HANDLED; - return IRQ_NONE; + return ret; } void debug_ipi_setup(void) From patchwork Thu Jun 1 21:31:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 13264465 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 327E5C7EE23 for ; Thu, 1 Jun 2023 21:37:53 +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=bryKt+Wv1fEAWJllNJu+CRDY9CbonNJBj6KPMw9L+zY=; b=hibdz6kID6uLUN uURgvkvrQqu42L0D4UW79NHv8RuWCB+8ZWEssrwCSY/5sDkpiTZDnOO8Q/nmoh4FccRTWPHvdKzPf c9SyZsucS8Uf7TPFwJvF8VXgX5Sz9El10UfGcaTkCqo3xfO7RqnEMIR3eaVCh8BA6xuXSZvFarAdv 3cP9mgH1vKRzF+u0m6MSVNSNSqBNiENR/c/KqLh2hnWYnZRshXyBRa/XvBt88L5qpNXta+y/7ixyC f2JiEA8AhBciYym+66m7anQWNhBOuTI54oqMW/GgKb7psBDt/bpDzfcbhe5ozs3l8+20LDragLTqB knttuYxoJOIaBPJD/Q6w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q4pz8-0050sX-2r; Thu, 01 Jun 2023 21:37:30 +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 1q4pz7-0050r0-1X for linux-arm-kernel@bombadil.infradead.org; Thu, 01 Jun 2023 21:37:29 +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=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=mikXDC98WtuolpNz9woFCzhq7+ kw5d2skKkcwx2b0sjwKKizvVXNpkgu/vChNNJMjwlrUGkLFz2IhGn2AEUBT11x07v1zeSZ/1qTe8N K2uCUMV8kG47YUkCGvrmlzjMYhiS03aAZMwOCthQV3pujksULu5h/vn+HN39ZNrE803CupeA6OWDU HJ+Hh8kN9BZZXJLhqkXXVJtvracbpr5BS8uzXsI1ZvGuwURRL0tygoYrJNVGsTdhyqD1tClmeI0H5 kjX3FfN2Ye5lpFO3QhyAOZwnqwfghLLKF6nNuRiFHt1HA2vYDPq5EU+L3vlZ8PAJOWc+tETs7mDnH TIRRTxJw==; Received: from mail-pf1-x42d.google.com ([2607:f8b0:4864:20::42d]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q4pz1-00HIPu-0g for linux-arm-kernel@lists.infradead.org; Thu, 01 Jun 2023 21:37:27 +0000 Received: by mail-pf1-x42d.google.com with SMTP id d2e1a72fcca58-65055aa4ed7so808718b3a.3 for ; Thu, 01 Jun 2023 14:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1685655439; x=1688247439; 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=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=AkgOfxeqMJ+Uowmkx4hw7IQZ50qdy2xVCPyodSzFbID79vkX/uuep2hjtkAVQf+ZMY 2Ois27dY1aNRlYZc7JAHlkdtHKB/6T3f05uoIAoto3JEclpb7k9RtEHCD6+WC8K9AjHR 0/+O26QCTSXFLaWGDuAgWq5b1oezjD46LgHAY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1685655439; x=1688247439; 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=MfGBHBvKGGFx2dApaWUV0FsGkRnAHULREps6A6RYWJ4=; b=IKaG1fl+t/Q3za9I1kBEIxN0VYN/fubvvvGM5Mx94CHC9wqJgTWTxw9Qfy35ekO/ja X3353mYjPBkv+SIKPFH+9pKCPcYDhzdIHAU0s7tzE/LX0Po9aGFTrL68wxlRoVL2d9Bd prWBNtpc/WuI3EseN/4/BOaITJcUTQZFZ2AHxjYaDr4glBVKGbCMcLy6RmP9w8FNJl4m VFiGccon9K2kSLh8vz9+9CdvoPhuHfPD3t9DbKFMh7x+acWZJrUWu4XPj+5qN3xpZf7e 4luEQABD7gzOHtwYqIRtt7nXyJ6XbXm3zpkQE7kd/EsdtT0L5Uf6qSAMrs8f8Cp4+19e bXJQ== X-Gm-Message-State: AC+VfDw9ja3XdhBxfw+4TIw+pemSiw9mRMZHKfCj426PtIguO7PUNwql yhQ6vGdsxLGdYVobMOhIQUelkw== X-Google-Smtp-Source: ACHHUZ6c761aOPieAnWSz/n26mxi7TuDnyom5n4cFPpm2ooQ6JFhgncQbyJIHjA9N7SSHuxDQFh8Yw== X-Received: by 2002:a05:6a20:1583:b0:10f:759d:c5b2 with SMTP id h3-20020a056a20158300b0010f759dc5b2mr8808767pzj.45.1685655438667; Thu, 01 Jun 2023 14:37:18 -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.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Jun 2023 14:37:18 -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 , Jason Wessel , linux-kernel@vger.kernel.org Subject: [PATCH v9 6/7] kgdb: Provide a stub kgdb_nmicallback() if !CONFIG_KGDB Date: Thu, 1 Jun 2023 14:31:50 -0700 Message-ID: <20230601143109.v9.6.Ia3aeac89bb6751b682237e76e5ba594318e4b1aa@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_223723_561910_14C4114C X-CRM114-Status: GOOD ( 15.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 To save architectures from needing to wrap the call in #ifdefs, add a stub no-op version of kgdb_nmicallback(), which returns 1 if it didn't handle anything. Reviewed-by: Daniel Thompson Signed-off-by: Douglas Anderson --- In v9 this is the only kgdb dependency. I'm assuming it could go through the arm64 tree? If that's not a good idea, we could always change the patch ("arm64: kgdb: Roundup cpus using IPI as NMI") not to depend on it by only calling kgdb_nmicallback() if CONFIG_KGDB is not defined. Changes in v9: - Added missing "inline" Changes in v8: - "Provide a stub kgdb_nmicallback() if !CONFIG_KGDB" new for v8 include/linux/kgdb.h | 1 + 1 file changed, 1 insertion(+) diff --git a/include/linux/kgdb.h b/include/linux/kgdb.h index 258cdde8d356..76e891ee9e37 100644 --- a/include/linux/kgdb.h +++ b/include/linux/kgdb.h @@ -365,5 +365,6 @@ extern void kgdb_free_init_mem(void); #define dbg_late_init() static inline void kgdb_panic(const char *msg) {} static inline void kgdb_free_init_mem(void) { } +static inline int kgdb_nmicallback(int cpu, void *regs) { return 1; } #endif /* ! CONFIG_KGDB */ #endif /* _KGDB_H_ */ 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); +}