From mboxrd@z Thu Jan 1 00:00:00 1970 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 37007C433EF for ; Mon, 17 Jan 2022 17:14:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243772AbiAQROJ (ORCPT ); Mon, 17 Jan 2022 12:14:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243822AbiAQRK1 (ORCPT ); Mon, 17 Jan 2022 12:10:27 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4F360C03F938; Mon, 17 Jan 2022 09:06:23 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 0D9DDB8114B; Mon, 17 Jan 2022 17:06:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6D16DC36AE3; Mon, 17 Jan 2022 17:06:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642439180; bh=JSmRYlIV/nVbbICD6eiKf9M9QQghEUe51u2q/tZL6HI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=u/RbKkDWsyAtQjnrusorW+UVy2YbSLxRSaVCj6Ds5QnZ58Jcdn0lVK2h8kMPuD5zw GdMQTYx3MTkAo3CZpKuJoNe8RIf+Q3pU9a3pwNwg+XWqFe9H6s4urvFBIwgWlLZldl g/NbXdNda0Z6tpWmxJNT95rwFkKTR7smjzCsgP/jHTLI0XW8Lre7XsVh66+xZYNZaj DkrQMPP4NgoAbABkA4SDJbk+Y4t4QFi92uS6wCLd6Tbiwr26C+4J6XVeNYVgtPorrl IdZEMEZ8QwHaBT/6Ql5B8kh7fLCDJjEC9Tb3pD6pbEZ5rvUrQ3bTp+56EmfKysOemZ RcAE1YIpZ6CbA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hari Bathini , kernel test robot , Michael Ellerman , Sasha Levin , srikar@linux.vnet.ibm.com, ego@linux.vnet.ibm.com, clg@kaod.org, parth@linux.ibm.com, npiggin@gmail.com, robh@kernel.org, yukuai3@huawei.com, linuxppc-dev@lists.ozlabs.org Subject: [PATCH AUTOSEL 4.19 12/17] powerpc: handle kdump appropriately with crash_kexec_post_notifiers option Date: Mon, 17 Jan 2022 12:05:46 -0500 Message-Id: <20220117170551.1472640-12-sashal@kernel.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220117170551.1472640-1-sashal@kernel.org> References: <20220117170551.1472640-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hari Bathini [ Upstream commit 219572d2fc4135b5ce65c735d881787d48b10e71 ] Kdump can be triggered after panic_notifers since commit f06e5153f4ae2 ("kernel/panic.c: add "crash_kexec_post_notifiers" option for kdump after panic_notifers") introduced crash_kexec_post_notifiers option. But using this option would mean smp_send_stop(), that marks all other CPUs as offline, gets called before kdump is triggered. As a result, kdump routines fail to save other CPUs' registers. To fix this, kdump friendly crash_smp_send_stop() function was introduced with kernel commit 0ee59413c967 ("x86/panic: replace smp_send_stop() with kdump friendly version in panic path"). Override this kdump friendly weak function to handle crash_kexec_post_notifiers option appropriately on powerpc. Reported-by: kernel test robot Signed-off-by: Hari Bathini [Fixed signature of crash_stop_this_cpu() - reported by lkp@intel.com] Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20211207103719.91117-1-hbathini@linux.ibm.com Signed-off-by: Sasha Levin --- arch/powerpc/kernel/smp.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 4853ac67cf21f..60fc3c71aa7b0 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c @@ -564,6 +564,36 @@ void crash_send_ipi(void (*crash_ipi_callback)(struct pt_regs *)) } #endif +#ifdef CONFIG_NMI_IPI +static void crash_stop_this_cpu(struct pt_regs *regs) +#else +static void crash_stop_this_cpu(void *dummy) +#endif +{ + /* + * Just busy wait here and avoid marking CPU as offline to ensure + * register data is captured appropriately. + */ + while (1) + cpu_relax(); +} + +void crash_smp_send_stop(void) +{ + static bool stopped = false; + + if (stopped) + return; + + stopped = true; + +#ifdef CONFIG_NMI_IPI + smp_send_nmi_ipi(NMI_IPI_ALL_OTHERS, crash_stop_this_cpu, 1000000); +#else + smp_call_function(crash_stop_this_cpu, NULL, 0); +#endif /* CONFIG_NMI_IPI */ +} + #ifdef CONFIG_NMI_IPI static void nmi_stop_this_cpu(struct pt_regs *regs) { -- 2.34.1