From: Mukesh R <mrathor@linux.microsoft.com>
To: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>,
rppt@kernel.org, akpm@linux-foundation.org, bhe@redhat.com,
kys@microsoft.com, haiyangz@microsoft.com, wei.liu@kernel.org,
decui@microsoft.com, longli@microsoft.com
Cc: kexec@lists.infradead.org, linux-hyperv@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] kexec: Add permission notifier chain for kexec operations
Date: Thu, 12 Feb 2026 14:12:29 -0800 [thread overview]
Message-ID: <fb651abf-0546-3bef-bf8f-597f35ddc0d6@linux.microsoft.com> (raw)
In-Reply-To: <176962212169.85424.4683391728440118017.stgit@skinsburskii-cloud-desktop.internal.cloudapp.net>
On 1/28/26 09:42, Stanislav Kinsburskii wrote:
> Add a blocking notifier chain to allow subsystems to be notified
> before kexec execution. This enables modules to perform necessary
> cleanup or validation before the system transitions to a new kernel or
> block kexec if not possible under current conditions.
>
> Signed-off-by: Stanislav Kinsburskii <skinsburskii@linux.microsoft.com>
> ---
> include/linux/kexec.h | 6 ++++++
> kernel/kexec_core.c | 24 ++++++++++++++++++++++++
> 2 files changed, 30 insertions(+)
>
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index ff7e231b0485..311037d30f9e 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -35,6 +35,7 @@ extern note_buf_t __percpu *crash_notes;
> #include <linux/ioport.h>
> #include <linux/module.h>
> #include <linux/highmem.h>
> +#include <linux/notifier.h>
> #include <asm/kexec.h>
> #include <linux/crash_core.h>
>
> @@ -532,10 +533,13 @@ extern bool kexec_file_dbg_print;
>
> extern void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size);
> extern void kimage_unmap_segment(void *buffer);
> +extern int kexec_block_notifier_register(struct notifier_block *nb);
> +extern int kexec_block_notifier_unregister(struct notifier_block *nb);
> #else /* !CONFIG_KEXEC_CORE */
> struct pt_regs;
> struct task_struct;
> struct kimage;
> +struct notifier_block;
> static inline void __crash_kexec(struct pt_regs *regs) { }
> static inline void crash_kexec(struct pt_regs *regs) { }
> static inline int kexec_should_crash(struct task_struct *p) { return 0; }
> @@ -543,6 +547,8 @@ static inline int kexec_crash_loaded(void) { return 0; }
> static inline void *kimage_map_segment(struct kimage *image, unsigned long addr, unsigned long size)
> { return NULL; }
> static inline void kimage_unmap_segment(void *buffer) { }
> +static inline int kexec_block_notifier_register(struct notifier_block *nb) { }
> +static inline int kexec_block_notifier_unregister(struct notifier_block *nb) { }
> #define kexec_in_progress false
> #endif /* CONFIG_KEXEC_CORE */
>
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index 0f92acdd354d..1e86a6f175f0 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -57,6 +57,20 @@ bool kexec_in_progress = false;
>
> bool kexec_file_dbg_print;
>
> +static BLOCKING_NOTIFIER_HEAD(kexec_block_list);
> +
> +int kexec_block_notifier_register(struct notifier_block *nb)
> +{
> + return blocking_notifier_chain_register(&kexec_block_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(kexec_block_notifier_register);
> +
> +int kexec_block_notifier_unregister(struct notifier_block *nb)
> +{
> + return blocking_notifier_chain_unregister(&kexec_block_list, nb);
> +}
> +EXPORT_SYMBOL_GPL(kexec_block_notifier_unregister);
> +
> /*
> * When kexec transitions to the new kernel there is a one-to-one
> * mapping between physical and virtual addresses. On processors
> @@ -1124,6 +1138,12 @@ bool kexec_load_permitted(int kexec_image_type)
> return true;
> }
>
> +static int kexec_check_blockers(void)
> +{
> + /* Notify subsystems of impending kexec */
> + return blocking_notifier_call_chain(&kexec_block_list, 0, NULL);
> +}
> +
> /*
> * Move into place and start executing a preloaded standalone
> * executable. If nothing was preloaded return an error.
> @@ -1139,6 +1159,10 @@ int kernel_kexec(void)
> goto Unlock;
> }
>
> + error = kexec_check_blockers();
This could take a long time, and I am not sure if it's a good idea
to stall kexec with such dependencies.
Thanks,
-Mukesh
> + if (error)
> + goto Unlock;
> +
> error = liveupdate_reboot();
> if (error)
> goto Unlock;
>
>
next prev parent reply other threads:[~2026-02-12 22:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-28 17:41 [PATCH 0/2] kexec: Refuse kernel-unsafe Microsoft Hypervisor transitions Stanislav Kinsburskii
2026-01-28 17:42 ` [PATCH 1/2] kexec: Add permission notifier chain for kexec operations Stanislav Kinsburskii
2026-02-12 22:12 ` Mukesh R [this message]
2026-02-19 22:13 ` Stanislav Kinsburskii
2026-01-28 17:42 ` [PATCH 2/2] mshv: Add kexec blocking support Stanislav Kinsburskii
2026-02-12 22:11 ` Mukesh R
2026-02-18 8:14 ` Wei Liu
2026-02-19 22:16 ` Stanislav Kinsburskii
2026-02-11 23:30 ` [PATCH 0/2] kexec: Refuse kernel-unsafe Microsoft Hypervisor transitions Stanislav Kinsburskii
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=fb651abf-0546-3bef-bf8f-597f35ddc0d6@linux.microsoft.com \
--to=mrathor@linux.microsoft.com \
--cc=akpm@linux-foundation.org \
--cc=bhe@redhat.com \
--cc=decui@microsoft.com \
--cc=haiyangz@microsoft.com \
--cc=kexec@lists.infradead.org \
--cc=kys@microsoft.com \
--cc=linux-hyperv@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=longli@microsoft.com \
--cc=rppt@kernel.org \
--cc=skinsburskii@linux.microsoft.com \
--cc=wei.liu@kernel.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