[PATCH v1 2/4] arm64: hibernate: Use fixmap for hibernate_map/unmap_page
From: Vincent Donnefort <hidden>
Date: 2026-09-18 13:19:04
Also in:
linux-pm, lkml
Subsystem:
arm64 port (aarch64 architecture), the rest · Maintainers:
Catalin Marinas, Will Deacon, Linus Torvalds
The default implementation for hibernate_map_page uses the direct map. This creates an unnecessary limitation for BBML3 enabled systems which can split linear map blocks and can enable memfd_secret users regardless of the linear map mapping level. Block splitting acquires a mutex (pgtable_split_lock) and as a consequence is incompatible with hibernation. We know hibernation would only call set_direct_map*() on a PTE-level region since it was previously split by memfd_secret. But let's avoid special casing hibernation in split_kernel_leaf_mapping(). On hibernation, do not modify the direct map and instead use a fixmap, better suited for a transient mapping hibernation needs to copy the page content. It removes the need for handling atomic context in split_kernel_leaf_mapping() altogether. Signed-off-by: Vincent Donnefort <redacted> --- arch/arm64/include/asm/fixmap.h | 3 +++ arch/arm64/kernel/hibernate.c | 12 ++++++++++++ 2 files changed, 15 insertions(+)
diff --git a/arch/arm64/include/asm/fixmap.h b/arch/arm64/include/asm/fixmap.h
index 170c3502d723..c8a65fd8584d 100644
--- a/arch/arm64/include/asm/fixmap.h
+++ b/arch/arm64/include/asm/fixmap.h@@ -73,6 +73,9 @@ enum fixed_addresses { FIX_ENTRY_TRAMP_TEXT1, #define TRAMP_VALIAS (__fix_to_virt(FIX_ENTRY_TRAMP_TEXT1)) #endif /* CONFIG_UNMAP_KERNEL_AT_EL0 */ +#ifdef CONFIG_HIBERNATION + FIX_HIBERNATE, +#endif __end_of_permanent_fixed_addresses, /*
diff --git a/arch/arm64/kernel/hibernate.c b/arch/arm64/kernel/hibernate.c
index 7bf117427777..bbd0779081fa 100644
--- a/arch/arm64/kernel/hibernate.c
+++ b/arch/arm64/kernel/hibernate.c@@ -21,6 +21,7 @@ #include <asm/cacheflush.h> #include <asm/cputype.h> #include <asm/daifflags.h> +#include <asm/fixmap.h> #include <asm/irqflags.h> #include <asm/kexec.h> #include <asm/memory.h>
@@ -213,6 +214,17 @@ static int create_safe_exec_page(void *src_start, size_t length, return 0; } +void *hibernate_map_page(struct page *page) +{ + set_fixmap(FIX_HIBERNATE, page_to_phys(page)); + return (void *)__fix_to_virt(FIX_HIBERNATE); +} + +void hibernate_unmap_page(struct page *page) +{ + clear_fixmap(FIX_HIBERNATE); +} + #ifdef CONFIG_ARM64_MTE static DEFINE_XARRAY(mte_pages);
--
2.55.0.1082.g2b9226bbc0-goog