From: Hari Bathini <hbathini@linux.ibm.com>
To: kexec@lists.infradead.org
Subject: [PATCH 08/30] powerpc/setup: Refactor/untangle panic notifiers
Date: Fri, 6 May 2022 00:25:08 +0530 [thread overview]
Message-ID: <3c34d8e2-6f84-933f-a4ed-338cd300d6b0@linux.ibm.com> (raw)
In-Reply-To: <20220427224924.592546-9-gpiccoli@igalia.com>
On 28/04/22 4:19 am, Guilherme G. Piccoli wrote:
> The panic notifiers infrastructure is a bit limited in the scope of
> the callbacks - basically every kind of functionality is dropped
> in a list that runs in the same point during the kernel panic path.
> This is not really on par with the complexities and particularities
> of architecture / hypervisors' needs, and a refactor is ongoing.
>
> As part of this refactor, it was observed that powerpc has 2 notifiers,
> with mixed goals: one is just a KASLR offset dumper, whereas the other
> aims to hard-disable IRQs (necessary on panic path), warn firmware of
> the panic event (fadump) and run low-level platform-specific machinery
> that might stop kernel execution and never come back.
>
> Clearly, the 2nd notifier has opposed goals: disable IRQs / fadump
> should run earlier while low-level platform actions should
> run late since it might not even return. Hence, this patch decouples
> the notifiers splitting them in three:
>
> - First one is responsible for hard-disable IRQs and fadump,
> should run early;
>
> - The kernel KASLR offset dumper is really an informative notifier,
> harmless and may run at any moment in the panic path;
>
> - The last notifier should run last, since it aims to perform
> low-level actions for specific platforms, and might never return.
> It is also only registered for 2 platforms, pseries and ps3.
>
> The patch better documents the notifiers and clears the code too,
> also removing a useless header.
>
> Currently no functionality change should be observed, but after
> the planned panic refactor we should expect more panic reliability
> with this patch.
>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Hari Bathini <hbathini@linux.ibm.com>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Nicholas Piggin <npiggin@gmail.com>
> Cc: Paul Mackerras <paulus@samba.org>
> Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
The change looks good. I have tested it on an LPAR (ppc64).
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
> ---
>
> We'd like to thanks specially the MiniCloud infrastructure [0] maintainers,
> that allow us to test PowerPC code in a very complete, functional and FREE
> environment (there's no need even for adding a credit card, like many "free"
> clouds require ?? ).
>
> [0] https://openpower.ic.unicamp.br/minicloud
>
> arch/powerpc/kernel/setup-common.c | 74 ++++++++++++++++++++++--------
> 1 file changed, 54 insertions(+), 20 deletions(-)
>
> diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c
> index 518ae5aa9410..52f96b209a96 100644
> --- a/arch/powerpc/kernel/setup-common.c
> +++ b/arch/powerpc/kernel/setup-common.c
> @@ -23,7 +23,6 @@
> #include <linux/console.h>
> #include <linux/screen_info.h>
> #include <linux/root_dev.h>
> -#include <linux/notifier.h>
> #include <linux/cpu.h>
> #include <linux/unistd.h>
> #include <linux/serial.h>
> @@ -680,8 +679,25 @@ int check_legacy_ioport(unsigned long base_port)
> }
> EXPORT_SYMBOL(check_legacy_ioport);
>
> -static int ppc_panic_event(struct notifier_block *this,
> - unsigned long event, void *ptr)
> +/*
> + * Panic notifiers setup
> + *
> + * We have 3 notifiers for powerpc, each one from a different "nature":
> + *
> + * - ppc_panic_fadump_handler() is a hypervisor notifier, which hard-disables
> + * IRQs and deal with the Firmware-Assisted dump, when it is configured;
> + * should run early in the panic path.
> + *
> + * - dump_kernel_offset() is an informative notifier, just showing the KASLR
> + * offset if we have RANDOMIZE_BASE set.
> + *
> + * - ppc_panic_platform_handler() is a low-level handler that's registered
> + * only if the platform wishes to perform final actions in the panic path,
> + * hence it should run late and might not even return. Currently, only
> + * pseries and ps3 platforms register callbacks.
> + */
> +static int ppc_panic_fadump_handler(struct notifier_block *this,
> + unsigned long event, void *ptr)
> {
> /*
> * panic does a local_irq_disable, but we really
> @@ -691,45 +707,63 @@ static int ppc_panic_event(struct notifier_block *this,
>
> /*
> * If firmware-assisted dump has been registered then trigger
> - * firmware-assisted dump and let firmware handle everything else.
> + * its callback and let the firmware handles everything else.
> */
> crash_fadump(NULL, ptr);
> - if (ppc_md.panic)
> - ppc_md.panic(ptr); /* May not return */
> +
> return NOTIFY_DONE;
> }
>
> -static struct notifier_block ppc_panic_block = {
> - .notifier_call = ppc_panic_event,
> - .priority = INT_MIN /* may not return; must be done last */
> -};
> -
> -/*
> - * Dump out kernel offset information on panic.
> - */
> static int dump_kernel_offset(struct notifier_block *self, unsigned long v,
> void *p)
> {
> pr_emerg("Kernel Offset: 0x%lx from 0x%lx\n",
> kaslr_offset(), KERNELBASE);
>
> - return 0;
> + return NOTIFY_DONE;
> }
>
> +static int ppc_panic_platform_handler(struct notifier_block *this,
> + unsigned long event, void *ptr)
> +{
> + /*
> + * This handler is only registered if we have a panic callback
> + * on ppc_md, hence NULL check is not needed.
> + * Also, it may not return, so it runs really late on panic path.
> + */
> + ppc_md.panic(ptr);
> +
> + return NOTIFY_DONE;
> +}
> +
> +static struct notifier_block ppc_fadump_block = {
> + .notifier_call = ppc_panic_fadump_handler,
> + .priority = INT_MAX, /* run early, to notify the firmware ASAP */
> +};
> +
> static struct notifier_block kernel_offset_notifier = {
> - .notifier_call = dump_kernel_offset
> + .notifier_call = dump_kernel_offset,
> +};
> +
> +static struct notifier_block ppc_panic_block = {
> + .notifier_call = ppc_panic_platform_handler,
> + .priority = INT_MIN, /* may not return; must be done last */
> };
>
> void __init setup_panic(void)
> {
> + /* Hard-disables IRQs + deal with FW-assisted dump (fadump) */
> + atomic_notifier_chain_register(&panic_notifier_list,
> + &ppc_fadump_block);
> +
> if (IS_ENABLED(CONFIG_RANDOMIZE_BASE) && kaslr_offset() > 0)
> atomic_notifier_chain_register(&panic_notifier_list,
> &kernel_offset_notifier);
>
> - /* PPC64 always does a hard irq disable in its panic handler */
> - if (!IS_ENABLED(CONFIG_PPC64) && !ppc_md.panic)
> - return;
> - atomic_notifier_chain_register(&panic_notifier_list, &ppc_panic_block);
> + /* Low-level platform-specific routines that should run on panic */
> + if (ppc_md.panic)
> + atomic_notifier_chain_register(&panic_notifier_list,
> + &ppc_panic_block);
> }
>
> #ifdef CONFIG_CHECK_CACHE_COHERENCY
next prev parent reply other threads:[~2022-05-05 18:55 UTC|newest]
Thread overview: 178+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-27 22:48 [PATCH 00/30] The panic notifiers refactor Guilherme G. Piccoli
2022-04-27 22:48 ` [PATCH 01/30] x86/crash, reboot: Avoid re-disabling VMX in all CPUs on crash/restart Guilherme G. Piccoli
2022-05-09 12:32 ` [PATCH 01/30] x86/crash,reboot: " Guilherme G. Piccoli
2022-05-09 15:52 ` Sean Christopherson
2022-05-10 20:11 ` Guilherme G. Piccoli
2022-04-27 22:48 ` [PATCH 02/30] ARM: kexec: Disable IRQs/FIQs also on crash CPUs shutdown path Guilherme G. Piccoli
2022-04-29 16:26 ` Michael Kelley
2022-04-29 18:20 ` Marc Zyngier
2022-04-29 21:38 ` Guilherme G. Piccoli
2022-04-29 21:45 ` Russell King
2022-04-29 21:56 ` Guilherme G. Piccoli
2022-04-29 22:00 ` Marc Zyngier
2022-04-27 22:48 ` [PATCH 03/30] notifier: Add panic notifiers info and purge trailing whitespaces Guilherme G. Piccoli
2022-04-27 22:48 ` [PATCH 04/30] firmware: google: Convert regular spinlock into trylock on panic path Guilherme G. Piccoli
2022-05-03 18:03 ` Evan Green
2022-05-03 19:12 ` Guilherme G. Piccoli
2022-05-03 21:56 ` Evan Green
2022-05-04 12:45 ` Guilherme G. Piccoli
2022-05-10 11:38 ` Petr Mladek
2022-05-10 13:04 ` Guilherme G. Piccoli
2022-05-10 17:20 ` Steven Rostedt
2022-05-10 19:40 ` John Ogness
2022-05-11 11:13 ` Petr Mladek
2022-04-27 22:48 ` [PATCH 05/30] misc/pvpanic: " Guilherme G. Piccoli
2022-05-10 12:14 ` Petr Mladek
2022-05-10 13:00 ` Guilherme G. Piccoli
2022-05-17 10:58 ` Petr Mladek
2022-05-17 13:03 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 06/30] soc: bcm: brcmstb: Document panic notifier action and remove useless header Guilherme G. Piccoli
2022-05-02 15:38 ` Florian Fainelli
2022-05-02 15:47 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 07/30] mips: ip22: Reword PANICED to PANICKED " Guilherme G. Piccoli
2022-05-04 20:32 ` Thomas Bogendoerfer
2022-05-04 21:26 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 08/30] powerpc/setup: Refactor/untangle panic notifiers Guilherme G. Piccoli
2022-05-05 18:55 ` Hari Bathini [this message]
2022-05-05 19:28 ` Guilherme G. Piccoli
2022-05-09 12:50 ` Guilherme G. Piccoli
2022-05-10 13:53 ` Michael Ellerman
2022-05-10 14:10 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 09/30] coresight: cpu-debug: Replace mutex with mutex_trylock on panic notifier Guilherme G. Piccoli
2022-04-28 8:11 ` Suzuki K Poulose
2022-04-29 14:01 ` Guilherme G. Piccoli
2022-05-09 13:09 ` Guilherme G. Piccoli
2022-05-09 16:14 ` Suzuki K Poulose
2022-05-09 16:26 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 10/30] alpha: Clean-up the panic notifier code Guilherme G. Piccoli
2022-05-09 14:13 ` Guilherme G. Piccoli
2022-05-10 14:16 ` Petr Mladek
2022-05-11 20:10 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 11/30] um: Improve panic notifiers consistency and ordering Guilherme G. Piccoli
2022-05-10 14:28 ` Petr Mladek
2022-05-11 20:22 ` Guilherme G. Piccoli
2022-05-13 14:44 ` Johannes Berg
2022-05-15 22:12 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 12/30] parisc: Replace regular spinlock with spin_trylock on panic path Guilherme G. Piccoli
2022-04-28 16:55 ` Helge Deller
2022-04-29 14:34 ` Guilherme G. Piccoli
2022-05-23 20:40 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 13/30] s390/consoles: Improve panic notifiers reliability Guilherme G. Piccoli
2022-04-29 18:46 ` Heiko Carstens
2022-04-29 19:31 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 14/30] panic: Properly identify the panic event to the notifiers' callbacks Guilherme G. Piccoli
2022-05-10 15:16 ` Petr Mladek
2022-05-10 16:16 ` Guilherme G. Piccoli
2022-05-17 13:11 ` Petr Mladek
2022-05-17 15:19 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 15/30] bus: brcmstb_gisb: Clean-up panic/die notifiers Guilherme G. Piccoli
2022-05-02 15:38 ` Florian Fainelli
2022-05-02 15:50 ` Guilherme G. Piccoli
2022-05-10 15:28 ` Petr Mladek
2022-05-17 15:32 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 16/30] drivers/hv/vmbus, video/hyperv_fb: Untangle and refactor Hyper-V panic notifiers Guilherme G. Piccoli
2022-04-29 17:16 ` Michael Kelley
2022-04-29 22:35 ` Guilherme G. Piccoli
2022-05-03 18:13 ` Michael Kelley
2022-05-03 18:57 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 17/30] tracing: Improve panic/die notifiers Guilherme G. Piccoli
2022-04-29 9:22 ` Sergei Shtylyov
2022-04-29 13:23 ` Steven Rostedt
2022-04-29 13:46 ` Guilherme G. Piccoli
2022-04-29 13:56 ` Steven Rostedt
2022-04-29 14:44 ` Guilherme G. Piccoli
2022-05-11 11:45 ` Petr Mladek
2022-05-17 15:33 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 18/30] notifier: Show function names on notifier routines if DEBUG_NOTIFIERS is set Guilherme G. Piccoli
2022-04-28 1:01 ` Xiaoming Ni
2022-04-29 19:38 ` Guilherme G. Piccoli
2022-05-10 17:29 ` Steven Rostedt
2022-05-16 16:14 ` Guilherme G. Piccoli
2022-04-29 16:27 ` Michael Kelley
2022-04-27 22:49 ` [PATCH 19/30] panic: Add the panic hypervisor notifier list Guilherme G. Piccoli
2022-04-29 17:30 ` Michael Kelley
2022-04-29 18:04 ` Guilherme G. Piccoli
2022-05-03 17:44 ` Michael Kelley
2022-05-03 17:56 ` Guilherme G. Piccoli
2022-05-16 14:01 ` Petr Mladek
2022-05-16 15:06 ` Guilherme G. Piccoli
2022-05-16 16:02 ` Evan Green
2022-05-17 13:28 ` Petr Mladek
2022-05-17 16:37 ` Guilherme G. Piccoli
[not found] ` <YoShZVYNAdvvjb7z@alley>
2022-05-18 13:24 ` Guilherme G. Piccoli
2022-05-17 13:57 ` Petr Mladek
2022-05-17 16:42 ` Guilherme G. Piccoli
2022-05-18 7:38 ` Petr Mladek
2022-05-18 13:09 ` Guilherme G. Piccoli
2022-05-18 22:17 ` Scott Branden
2022-05-19 12:19 ` Guilherme G. Piccoli
2022-05-19 19:20 ` Scott Branden
2022-05-23 14:56 ` Guilherme G. Piccoli
2022-05-24 8:04 ` Petr Mladek
2022-05-18 7:58 ` Petr Mladek
2022-05-18 13:16 ` Guilherme G. Piccoli
2022-05-19 7:03 ` Petr Mladek
2022-05-19 12:07 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 20/30] panic: Add the panic informational " Guilherme G. Piccoli
2022-04-27 23:49 ` Paul E. McKenney
2022-04-28 8:14 ` Suzuki K Poulose
2022-04-29 14:50 ` Guilherme G. Piccoli
2022-05-16 14:11 ` Petr Mladek
2022-05-16 14:28 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 21/30] panic: Introduce the panic pre-reboot " Guilherme G. Piccoli
2022-04-28 14:13 ` Alex Elder
2022-04-28 16:26 ` Corey Minyard
2022-04-29 15:18 ` Guilherme G. Piccoli
2022-04-29 16:04 ` Max Filippov
2022-04-29 19:34 ` Guilherme G. Piccoli
2022-05-16 14:33 ` Petr Mladek
2022-05-16 16:05 ` Guilherme G. Piccoli
2022-05-16 16:18 ` Luck, Tony
2022-05-16 16:33 ` Guilherme G. Piccoli
2022-05-17 14:11 ` Petr Mladek
2022-05-17 16:45 ` Guilherme G. Piccoli
2022-05-17 17:02 ` Luck, Tony
2022-05-17 18:12 ` Guilherme G. Piccoli
2022-05-17 19:07 ` Luck, Tony
2022-04-27 22:49 ` [PATCH 22/30] panic: Introduce the panic post-reboot " Guilherme G. Piccoli
2022-05-09 14:16 ` Guilherme G. Piccoli
2022-05-11 16:45 ` Heiko Carstens
2022-05-11 19:58 ` Guilherme G. Piccoli
2022-05-16 14:45 ` Petr Mladek
2022-05-16 16:08 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 23/30] printk: kmsg_dump: Introduce helper to inform number of dumpers Guilherme G. Piccoli
2022-05-10 17:40 ` Steven Rostedt
2022-05-11 20:03 ` Guilherme G. Piccoli
2022-05-16 14:50 ` Petr Mladek
2022-05-16 16:09 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 24/30] panic: Refactor the panic path Guilherme G. Piccoli
2022-04-28 0:28 ` Randy Dunlap
2022-04-29 16:04 ` Guilherme G. Piccoli
2022-05-09 14:25 ` Guilherme G. Piccoli
2022-04-29 17:53 ` Michael Kelley
2022-04-29 20:38 ` Guilherme G. Piccoli
2022-05-03 17:31 ` Michael Kelley
2022-05-03 18:06 ` Guilherme G. Piccoli
2022-05-09 15:16 ` d.hatayama
2022-05-09 16:39 ` Guilherme G. Piccoli
2022-05-12 14:03 ` Petr Mladek
2022-05-15 22:47 ` Guilherme G. Piccoli
2022-05-16 10:21 ` Petr Mladek
2022-05-16 16:32 ` Guilherme G. Piccoli
2022-05-19 23:45 ` Baoquan He
2022-05-20 11:23 ` Guilherme G. Piccoli
2022-05-24 8:01 ` Petr Mladek
2022-05-24 10:18 ` Baoquan He
2022-05-24 8:32 ` Baoquan He
2022-05-24 14:44 ` Eric W. Biederman
2022-05-26 16:25 ` Guilherme G. Piccoli
2022-06-14 14:36 ` Petr Mladek
2022-06-15 9:36 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 25/30] panic, printk: Add console flush parameter and convert panic_print to a notifier Guilherme G. Piccoli
2022-05-16 14:56 ` Petr Mladek
2022-05-16 16:11 ` Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 26/30] Drivers: hv: Do not force all panic notifiers to execute before kdump Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 27/30] powerpc: " Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 28/30] panic: Unexport crash_kexec_post_notifiers Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 29/30] powerpc: ps3, pseries: Avoid duplicate call to kmsg_dump() on panic Guilherme G. Piccoli
2022-04-27 22:49 ` [PATCH 30/30] um: Avoid duplicate call to kmsg_dump() Guilherme G. Piccoli
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3c34d8e2-6f84-933f-a4ed-338cd300d6b0@linux.ibm.com \
--to=hbathini@linux.ibm.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).