Re: [PATCH v22 07/10] kernel: hibernate: Add an arch hook for preventing hiberation

From: Catalin Marinas

Date: Fri Oct 02 2026 - 07:06:56 EST


On Fri, Oct 02, 2026 at 07:15:03AM +0100, Suzuki K Poulose wrote:
> Add a hook to allow arch code disable hibernation. On arm64, with an RMM active,
> there could be pages that are delegated to the "Realm" security state. Any
> access to them are fatal (e.g., hibernate save image or restoring an image to
> a delegated page). pKVM host also has its restrictions on enabling hibernation.
>
> Add a weak arch hook to let the architectures have a say.
>
> Cc: "Rafael J. Wysocki" <rafael@xxxxxxxxxx>
> Cc: Len Brown <lenb@xxxxxxxxxx>
> Cc: Pavel Machek <pavel@xxxxxxxxxx>
> Cc: linux-pm@xxxxxxxxxxxxxxx
> Cc: Sudeep Holla <sudeep.holla@xxxxxxxxxx>
> Suggested-by: Catalin Marinas <catalin.marinas@xxxxxxx>
> Signed-off-by: Suzuki K Poulose <suzuki.poulose@xxxxxxx>

Nit: the subject prefix for kernel/power/ usually is

PM: hibernate: ....

I can fix it locally, no need to respin (and probably the wrap the long
lines in the commit log, we tend to keep them shorter).

> ---
> include/linux/suspend.h | 1 +
> kernel/power/hibernate.c | 8 +++++++-
> 2 files changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/include/linux/suspend.h b/include/linux/suspend.h
> index b02876f1ae38a..a3815027773c5 100644
> --- a/include/linux/suspend.h
> +++ b/include/linux/suspend.h
> @@ -401,6 +401,7 @@ int hibernate_quiet_exec(int (*func)(void *data), void *data);
> int hibernate_resume_nonboot_cpu_disable(void);
> int arch_hibernation_header_save(void *addr, unsigned int max_size);
> int arch_hibernation_header_restore(void *addr);
> +bool arch_hibernation_available(void);
>
> #else /* CONFIG_HIBERNATION */
> static inline void register_nosave_region(unsigned long b, unsigned long e) {}
> diff --git a/kernel/power/hibernate.c b/kernel/power/hibernate.c
> index d2479c69d71a4..9d9d53828542f 100644
> --- a/kernel/power/hibernate.c
> +++ b/kernel/power/hibernate.c
> @@ -106,11 +106,17 @@ bool hibernation_in_progress(void)
> return !atomic_read(&hibernate_atomic);
> }
>
> +__weak bool arch_hibernation_available(void)
> +{
> + return true;
> +}
> +
> bool hibernation_available(void)
> {
> return nohibernate == 0 &&
> !security_locked_down(LOCKDOWN_HIBERNATION) &&
> - !secretmem_active() && !cxl_mem_active();
> + !secretmem_active() && !cxl_mem_active() &&
> + arch_hibernation_available();

Reviewed-by: Catalin Marinas <catalin.marinas@xxxxxxx>

Raphael, any objection to this patch going in through the arm64 tree? It
matches the style of other __weak functions in this file.

Thanks.

--
Catalin