@@ -47,6 +47,21 @@ int get_hibernation_key(u8 **hkey)
return hibernation_keys->hkey_status;
}
+
+bool swsusp_page_is_keys(struct page *page)
+{
+ bool ret = false;
+
+ if (!hibernation_keys || hibernation_keys->hkey_status)
+ return ret;
+
+ ret = (page_to_pfn(page) == page_to_pfn(virt_to_page(hibernation_keys)));
+ if (ret)
+ pr_info("PM: Avoid snapshot the page of hibernation key.\n");
+
+ return ret;
+}
+
static int __init init_hibernation_keys(void)
{
struct hibernation_keys *keys;
@@ -19,6 +19,9 @@ struct swsusp_info {
#ifdef CONFIG_HIBERNATE_VERIFICATION
/* arch/x86/power/hibernate_keys.c */
extern int get_hibernation_key(u8 **hkey);
+extern bool swsusp_page_is_keys(struct page *page);
+#else
+static inline bool swsusp_page_is_keys(struct page *page) { return false; }
#endif
/* kernel/power/snapshot.c */
@@ -1093,6 +1093,9 @@ static struct page *saveable_highmem_page(struct zone *zone, unsigned long pfn)
BUG_ON(!PageHighMem(page));
+ if (swsusp_page_is_keys(page))
+ return NULL;
+
if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page) ||
PageReserved(page))
return NULL;
@@ -1155,6 +1158,9 @@ static struct page *saveable_page(struct zone *zone, unsigned long pfn)
BUG_ON(PageHighMem(page));
+ if (swsusp_page_is_keys(page))
+ return NULL;
+
if (swsusp_page_is_forbidden(page) || swsusp_page_is_free(page))
return NULL;