[PATCH v4 1/2] kexec: Add helper to report an active kexec reboot

Mukesh Pilaniya mpilaniy at redhat.com
Mon Oct 26 03:21:13 PDT 2026


Hi Shradha,

On 09/10/26 3:52 pm, Shradha Gupta wrote:
> A shutdown callback in a loadable module may need to distinguish a
> kexec reboot from a normal restart, halt, or poweroff. The Hyper-V
> VMBus driver needs this distinction when moving its kexec cleanup into
> a common syscore shutdown callback.
> 
> Add kexec_is_in_progress() and export it to GPL modules so the callback
> can remain guarded when VMBus is built as a module. Provide a false
> inline implementation when CONFIG_KEXEC_CORE is disabled.
> 
> The helper reports only the normal kexec reboot path. Crash kexec and
> preserve-context kexec do not set this state.
> 
> Signed-off-by: Shradha Gupta <shradhagupta at linux.microsoft.com>
> Acked-by: Mike Rapoport (Microsoft) <rppt at kernel.org>
> Reviewed-by: Michael Kelley <mhklinux at outlook.com>
> Reviewed-by: Bradley Morgan <brads at mainlining.org>
> Reviewed-by: Naman Jain <namjain at linux.microsoft.com>
> ---
>  include/linux/kexec.h | 2 ++
>  kernel/kexec_core.c   | 7 +++++++
>  2 files changed, 9 insertions(+)
> 
> diff --git a/include/linux/kexec.h b/include/linux/kexec.h
> index 8a22bc9b8c6c..827a5311d97a 100644
> --- a/include/linux/kexec.h
> +++ b/include/linux/kexec.h
> @@ -468,6 +468,7 @@ bool kexec_load_permitted(int kexec_image_type);
>  
>  /* flag to track if kexec reboot is in progress */
>  extern bool kexec_in_progress;
> +bool kexec_is_in_progress(void);
>  
>  #ifndef page_to_boot_pfn
>  static inline unsigned long page_to_boot_pfn(struct page *page)
> @@ -544,6 +545,7 @@ static inline void *kimage_map_segment(struct kimage *image, int idx)
>  { return NULL; }
>  static inline void kimage_unmap_segment(void *buffer) { }
>  #define kexec_in_progress false
> +static inline bool kexec_is_in_progress(void) { return false; }
>  #endif /* CONFIG_KEXEC_CORE */
>  
>  #ifdef CONFIG_KEXEC_SIG
> diff --git a/kernel/kexec_core.c b/kernel/kexec_core.c
> index dc770b9a6d05..282c7b3c6c35 100644
> --- a/kernel/kexec_core.c
> +++ b/kernel/kexec_core.c
> @@ -23,6 +23,7 @@
>  #include <linux/hardirq.h>
>  #include <linux/elf.h>
>  #include <linux/elfcore.h>
> +#include <linux/export.h>
>  #include <linux/utsname.h>
>  #include <linux/numa.h>
>  #include <linux/suspend.h>
> @@ -54,6 +55,12 @@ atomic_t __kexec_lock = ATOMIC_INIT(0);
>  /* Flag to indicate we are going to kexec a new kernel */
>  bool kexec_in_progress = false;
>  
> +bool kexec_is_in_progress(void)
> +{
> +	return kexec_in_progress;
> +}
> +EXPORT_SYMBOL_GPL(kexec_is_in_progress);
> +
kexec_is_in_progress() is exported via EXPORT_SYMBOL_GPL but has no
kernel-doc. Could you use a proper kernel-doc block above the function?

>  bool kexec_file_dbg_print;
>  
>  /*

-- 
Regards,
Mukesh Pilaniya




More information about the kexec mailing list