diff for duplicates of <20180711124008.GF2070@MiWiFi-R3L-srv> diff --git a/a/1.txt b/N1/1.txt index ffbf08d..32f04bf 100644 --- a/a/1.txt +++ b/N1/1.txt @@ -1 +1,74 @@ Please try this v3 patch: + +From 9850d3de9c02e570dc7572069a9749a8add4c4c7 Mon Sep 17 00:00:00 2001 +From: Baoquan He <bhe@redhat.com> +Date: Wed, 11 Jul 2018 20:31:51 +0800 +Subject: [PATCH v3] mm, page_alloc: find movable zone after kernel text + +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 on that node. + +Signed-off-by: Baoquan He <bhe@redhat.com> +--- + mm/page_alloc.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/mm/page_alloc.c b/mm/page_alloc.c +index 1521100..390eb35 100644 +--- a/mm/page_alloc.c ++++ b/mm/page_alloc.c +@@ -6547,7 +6547,7 @@ static unsigned long __init early_calculate_totalpages(void) + static void __init find_zone_movable_pfns_for_nodes(void) + { + int i, nid; +- unsigned long usable_startpfn; ++ unsigned long usable_startpfn, real_startpfn; + unsigned long kernelcore_node, kernelcore_remaining; + /* save the state before borrow the nodemask */ + nodemask_t saved_node_state = node_states[N_MEMORY]; +@@ -6681,10 +6681,20 @@ static void __init find_zone_movable_pfns_for_nodes(void) + if (start_pfn >= end_pfn) + continue; + ++ /* ++ * KASLR may put kernel near tail of node memory, ++ * start after kernel on that node to find PFN ++ * which zone begins. ++ */ ++ if (pfn_to_nid(PFN_UP(_etext)) == i) ++ real_startpfn = max(usable_startpfn, ++ PFN_UP(_etext)) ++ else ++ real_startpfn = usable_startpfn; + /* Account for what is only usable for kernelcore */ +- if (start_pfn < usable_startpfn) { ++ if (start_pfn < real_startpfn) { + unsigned long kernel_pages; +- kernel_pages = min(end_pfn, usable_startpfn) ++ kernel_pages = min(end_pfn, real_startpfn) + - start_pfn; + + kernelcore_remaining -= min(kernel_pages, +@@ -6693,7 +6703,7 @@ static void __init find_zone_movable_pfns_for_nodes(void) + required_kernelcore); + + /* Continue if range is now fully accounted */ +- if (end_pfn <= usable_startpfn) { ++ if (end_pfn <= real_startpfn) { + + /* + * Push zone_movable_pfn to the end so +@@ -6704,7 +6714,7 @@ static void __init find_zone_movable_pfns_for_nodes(void) + zone_movable_pfn[nid] = end_pfn; + continue; + } +- start_pfn = usable_startpfn; ++ start_pfn = real_startpfn; + } + + /* +-- +2.1.0 diff --git a/a/content_digest b/N1/content_digest index 566cb4c..78ccf55 100644 --- a/a/content_digest +++ b/N1/content_digest @@ -19,6 +19,79 @@ " mgorman@techsingularity.net\0" "\00:1\0" "b\0" - Please try this v3 patch: + "Please try this v3 patch:\n" + "\n" + "From 9850d3de9c02e570dc7572069a9749a8add4c4c7 Mon Sep 17 00:00:00 2001\n" + "From: Baoquan He <bhe@redhat.com>\n" + "Date: Wed, 11 Jul 2018 20:31:51 +0800\n" + "Subject: [PATCH v3] mm, page_alloc: find movable zone after kernel text\n" + "\n" + "In find_zone_movable_pfns_for_nodes(), when try to find the starting\n" + "PFN movable zone begins in each node, kernel text position is not\n" + "considered. KASLR may put kernel after which movable zone begins.\n" + "\n" + "Fix it by finding movable zone after kernel text on that node.\n" + "\n" + "Signed-off-by: Baoquan He <bhe@redhat.com>\n" + "---\n" + " mm/page_alloc.c | 20 +++++++++++++++-----\n" + " 1 file changed, 15 insertions(+), 5 deletions(-)\n" + "\n" + "diff --git a/mm/page_alloc.c b/mm/page_alloc.c\n" + "index 1521100..390eb35 100644\n" + "--- a/mm/page_alloc.c\n" + "+++ b/mm/page_alloc.c\n" + "@@ -6547,7 +6547,7 @@ static unsigned long __init early_calculate_totalpages(void)\n" + " static void __init find_zone_movable_pfns_for_nodes(void)\n" + " {\n" + " \tint i, nid;\n" + "-\tunsigned long usable_startpfn;\n" + "+\tunsigned long usable_startpfn, real_startpfn;\n" + " \tunsigned long kernelcore_node, kernelcore_remaining;\n" + " \t/* save the state before borrow the nodemask */\n" + " \tnodemask_t saved_node_state = node_states[N_MEMORY];\n" + "@@ -6681,10 +6681,20 @@ static void __init find_zone_movable_pfns_for_nodes(void)\n" + " \t\t\tif (start_pfn >= end_pfn)\n" + " \t\t\t\tcontinue;\n" + " \n" + "+\t\t\t/*\n" + "+\t\t\t * KASLR may put kernel near tail of node memory,\n" + "+\t\t\t * start after kernel on that node to find PFN\n" + "+\t\t\t * which zone begins.\n" + "+\t\t\t */\n" + "+\t\t\tif (pfn_to_nid(PFN_UP(_etext)) == i)\n" + "+\t\t\t\treal_startpfn = max(usable_startpfn,\n" + "+\t\t\t\t\t\tPFN_UP(_etext))\n" + "+\t\t\telse\n" + "+\t\t\t\treal_startpfn = usable_startpfn;\n" + " \t\t\t/* Account for what is only usable for kernelcore */\n" + "-\t\t\tif (start_pfn < usable_startpfn) {\n" + "+\t\t\tif (start_pfn < real_startpfn) {\n" + " \t\t\t\tunsigned long kernel_pages;\n" + "-\t\t\t\tkernel_pages = min(end_pfn, usable_startpfn)\n" + "+\t\t\t\tkernel_pages = min(end_pfn, real_startpfn)\n" + " \t\t\t\t\t\t\t\t- start_pfn;\n" + " \n" + " \t\t\t\tkernelcore_remaining -= min(kernel_pages,\n" + "@@ -6693,7 +6703,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)\n" + " \t\t\t\t\t\t\trequired_kernelcore);\n" + " \n" + " \t\t\t\t/* Continue if range is now fully accounted */\n" + "-\t\t\t\tif (end_pfn <= usable_startpfn) {\n" + "+\t\t\t\tif (end_pfn <= real_startpfn) {\n" + " \n" + " \t\t\t\t\t/*\n" + " \t\t\t\t\t * Push zone_movable_pfn to the end so\n" + "@@ -6704,7 +6714,7 @@ static void __init find_zone_movable_pfns_for_nodes(void)\n" + " \t\t\t\t\tzone_movable_pfn[nid] = end_pfn;\n" + " \t\t\t\t\tcontinue;\n" + " \t\t\t\t}\n" + "-\t\t\t\tstart_pfn = usable_startpfn;\n" + "+\t\t\t\tstart_pfn = real_startpfn;\n" + " \t\t\t}\n" + " \n" + " \t\t\t/*\n" + "-- \n" + 2.1.0 -b9432bf88e99c3a3648778bb71857bab77ffa62657ff0290d51892536d3d5dac +acec0b8a5a55332ec40ea3c095fc3a51ca6db796d0a8297dd3a95839ab8c6a1d
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.