[PATCH v2] mm, page_alloc: find movable zone after kernel text

From: Baoquan He
Date: Wed Jul 11 2018 - 06:30:04 EST


In find_zone_movable_pfns_for_nodes(), when try to find the starting
PFN movable zone begins in each node, kernel text position is not
considered. KASLR may put kernel after which movable zone begins.

Fix it by finding movable zone after kernel text.

Signed-off-by: Baoquan He <bhe@xxxxxxxxxx>
---
mm/page_alloc.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/mm/page_alloc.c b/mm/page_alloc.c
index 1521100..17584cc 100644
--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -6678,6 +6678,8 @@ static void __init find_zone_movable_pfns_for_nodes(void)
unsigned long size_pages;

start_pfn = max(start_pfn, zone_movable_pfn[nid]);
+ /* KASLR may put kernel after 'start_pfn', start after kernel */
+ start_pfn = max(start_pfn, PFN_UP(_etext));
if (start_pfn >= end_pfn)
continue;

--
2.1.0