}
                get_page_bootmem(section_nr, pud_page(*pud), MIX_SECTION_INFO);
 
-               if (!boot_cpu_has(X86_FEATURE_PSE)) {
+               pmd = pmd_offset(pud, addr);
+               if (pmd_none(*pmd)) {
+                       next = (addr + PAGE_SIZE) & PAGE_MASK;
+                       continue;
+               }
+
+               if (!boot_cpu_has(X86_FEATURE_PSE) || !pmd_leaf(*pmd)) {
                        next = (addr + PAGE_SIZE) & PAGE_MASK;
-                       pmd = pmd_offset(pud, addr);
-                       if (pmd_none(*pmd))
-                               continue;
                        get_page_bootmem(section_nr, pmd_page(*pmd),
                                         MIX_SECTION_INFO);
 
                                         SECTION_INFO);
                } else {
                        next = pmd_addr_end(addr, end);
-
-                       pmd = pmd_offset(pud, addr);
-                       if (pmd_none(*pmd))
-                               continue;
-
-                       nr_pmd_pages = 1 << get_order(PMD_SIZE);
+                       nr_pmd_pages = (next - addr) >> PAGE_SHIFT;
                        page = pmd_page(*pmd);
                        while (nr_pmd_pages--)
                                get_page_bootmem(section_nr, page++,