[PATCH] x86, mm: Reset max_pfn_mapped before we create direct mappings

From: Zhang Yanfei
Date: Tue May 14 2013 - 23:48:19 EST


We use init_mem_mapping to create direct mappings from scratch. But
in 32bit or xen, we may have already set max_pfn_mapped before in
head_32.S and or xen-enlighten. So put the reset at beginning not
in the middle of init_mem_mapping seems more logical.

Also add comments to explain the reset.

Signed-off-by: Zhang Yanfei <zhangyanfei@xxxxxxxxxxxxxx>
---
arch/x86/mm/init.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c
index fdc5dca..f2e5d28 100644
--- a/arch/x86/mm/init.c
+++ b/arch/x86/mm/init.c
@@ -407,6 +407,14 @@ void __init init_mem_mapping(void)
end = max_low_pfn << PAGE_SHIFT;
#endif

+ /*
+ * In 32bit or xen, max_pfn_mapped has been set way before in
+ * head_32.S or xen-enlighten. So here we reset it since we will
+ * create direct mappings from scratch. And it will get its finally
+ * exact value after we finish the direct mapping in this function.
+ */
+ max_pfn_mapped = 0;
+
/* the ISA range is always mapped regardless of memory holes */
init_memory_mapping(0, ISA_END_ADDRESS);

@@ -416,7 +424,6 @@ void __init init_mem_mapping(void)

/* step_size need to be small so pgt_buf from BRK could cover it */
step_size = PMD_SIZE;
- max_pfn_mapped = 0; /* will get exact value next */
min_pfn_mapped = real_end >> PAGE_SHIFT;
last_start = start = real_end;
while (last_start > ISA_END_ADDRESS) {
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/