diff options
author | Huacai Chen <chenhuacai@loongson.cn> | 2025-02-13 12:02:35 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2025-03-22 12:56:47 -0700 |
commit | 03fa04cffc3bca565371067db90f513f7149b9c7 (patch) | |
tree | c9a778e78b0936b4fe179a3d3ccca70e46c1b17f /arch | |
parent | d1d9dba68d3a740461ef8d150c24236fb0709e83 (diff) | |
download | linux-03fa04cffc3bca565371067db90f513f7149b9c7.tar.gz linux-03fa04cffc3bca565371067db90f513f7149b9c7.tar.bz2 linux-03fa04cffc3bca565371067db90f513f7149b9c7.zip |
LoongArch: Fix kernel_page_present() for KPRANGE/XKPRANGE
[ Upstream commit 619b52777a4972bdb6ddf86ac54c6f68a47b51c4 ]
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 <chenhuacai@loongson.cn>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/loongarch/mm/pageattr.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/arch/loongarch/mm/pageattr.c b/arch/loongarch/mm/pageattr.c index bf8678248444..99165903908a 100644 --- a/arch/loongarch/mm/pageattr.c +++ b/arch/loongarch/mm/pageattr.c @@ -3,6 +3,7 @@ * Copyright (C) 2024 Loongson Technology Corporation Limited */ +#include <linux/memblock.h> #include <linux/pagewalk.h> #include <linux/pgtable.h> #include <asm/set_memory.h> @@ -167,7 +168,7 @@ bool kernel_page_present(struct page *page) unsigned long addr = (unsigned long)page_address(page); if (addr < vm_map_base) - return true; + return memblock_is_memory(__pa(addr)); pgd = pgd_offset_k(addr); if (pgd_none(pgdp_get(pgd))) |