@@ -579,11 +579,23 @@ static void __init alloc_init_pte(pmd_t *pmd, unsigned long addr,
unsigned long end, unsigned long pfn,
const struct mem_type *type)
{
- pte_t *pte = early_pte_alloc(pmd, addr, type->prot_l1);
+ unsigned long next;
+ pte_t *pte;
+
do {
- set_pte_ext(pte, pfn_pte(pfn, __pgprot(type->prot_pte)), 0);
- pfn++;
- } while (pte++, addr += PAGE_SIZE, addr != end);
+ if ((end-addr) & PMD_MASK)
+ next = (addr + PMD_SIZE) & PMD_MASK;
+ else
+ next = end;
+
+ pte = early_pte_alloc(pmd, addr, type->prot_l1);
+ do {
+ set_pte_ext(pte, pfn_pte(pfn,
+ __pgprot(type->prot_pte)), 0);
+ pfn++;
+ } while (pte++, addr += PAGE_SIZE, addr != next);
+
+ } while (pmd++, addr = next, addr != end);
}
static void __init alloc_init_section(pud_t *pud, unsigned long addr,