Skip to content

Commit 619b527

Browse files
committed
LoongArch: Fix kernel_page_present() for KPRANGE/XKPRANGE
Now kernel_page_present() always return true for KPRANGE/XKPRANGE addresses, this isn't correct because hibernation (ACPI S4) use it to distinguish whether a page is saveable. If all KPRANGE/XKPRANGE addresses are considered as saveable, then reserved memory such as EFI_RUNTIME_SERVICES_CODE / EFI_RUNTIME_SERVICES_DATA will also be saved and restored. Fix this by returning true only if the KPRANGE/XKPRANGE address is in memblock.memory. Signed-off-by: Huacai Chen <[email protected]>
1 parent edb1942 commit 619b527

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

arch/loongarch/mm/pageattr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* Copyright (C) 2024 Loongson Technology Corporation Limited
44
*/
55

6+
#include <linux/memblock.h>
67
#include <linux/pagewalk.h>
78
#include <linux/pgtable.h>
89
#include <asm/set_memory.h>
@@ -167,7 +168,7 @@ bool kernel_page_present(struct page *page)
167168
unsigned long addr = (unsigned long)page_address(page);
168169

169170
if (addr < vm_map_base)
170-
return true;
171+
return memblock_is_memory(__pa(addr));
171172

172173
pgd = pgd_offset_k(addr);
173174
if (pgd_none(pgdp_get(pgd)))

0 commit comments

Comments
 (0)