Just like the way we calculate next for pud and pmd, aka
round down and add size.

Also, do not do boundary-checking with 'next', and just pass 'end' down
to phys_pud_init() instead. Because the loop in phys_pud_init() stops at
PTRS_PER_PUD and thus can handle a possibly bigger 'end' properly.

Signed-off-by: Yinghai Lu <ying...@kernel.org>
---
 arch/x86/mm/init_64.c |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 167439c..b1178eb 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -530,9 +530,7 @@ kernel_physical_mapping_init(unsigned long start,
                pgd_t *pgd = pgd_offset_k(start);
                pud_t *pud;
 
-               next = (start + PGDIR_SIZE) & PGDIR_MASK;
-               if (next > end)
-                       next = end;
+               next = (start & PGDIR_MASK) + PGDIR_SIZE;
 
                if (pgd_val(*pgd)) {
                        pud = (pud_t *)pgd_page_vaddr(*pgd);
@@ -542,7 +540,7 @@ kernel_physical_mapping_init(unsigned long start,
                }
 
                pud = alloc_low_page();
-               last_map_addr = phys_pud_init(pud, __pa(start), __pa(next),
+               last_map_addr = phys_pud_init(pud, __pa(start), __pa(end),
                                                 page_size_mask);
 
                spin_lock(&init_mm.page_table_lock);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to