patch-2.3.46 linux/arch/i386/mm/init.c

Next file: linux/arch/ia64/kernel/pci-dma.c
Previous file: linux/arch/i386/kernel/pci-i386.c
Back to the patch index
Back to the overall index

diff -u --recursive --new-file v2.3.45/linux/arch/i386/mm/init.c linux/arch/i386/mm/init.c
@@ -307,27 +307,30 @@
 	pmd_t *pmd;
 	pte_t *pte;
 	int i, j, k;
-	unsigned long vaddr;
-	unsigned long end = (unsigned long)__va(max_low_pfn*PAGE_SIZE);
+	unsigned long vaddr, end;
 
-	pgd_base = swapper_pg_dir;
+	end = (unsigned long)__va(max_low_pfn*PAGE_SIZE) - 1;
 
-	vaddr = PAGE_OFFSET;
-	i = __pgd_offset(vaddr);
+	i = __pgd_offset(PAGE_OFFSET);
+	pgd_base = swapper_pg_dir;
 	pgd = pgd_base + i;
 
-	for (; (i < PTRS_PER_PGD) && (vaddr <= end); pgd++, i++) {
+	for (; i < PTRS_PER_PGD; pgd++, i++) {
 		vaddr = i*PGDIR_SIZE;
+		if (vaddr >= end)
+			break;
 #if CONFIG_X86_PAE
-		pmd = (pmd_t *) alloc_bootmem_low_pages(PAGE_SIZE);
+		pmd = (pmd_t *) alloc_bootmem_pages(PAGE_SIZE);
 		set_pgd(pgd, __pgd(__pa(pmd) + 0x1));
 #else
 		pmd = (pmd_t *)pgd;
 #endif
 		if (pmd != pmd_offset(pgd, 0))
 			BUG();
-		for (j = 0; (j < PTRS_PER_PMD) && (vaddr <= end); pmd++, j++) {
+		for (j = 0; j < PTRS_PER_PMD; pmd++, j++) {
 			vaddr = i*PGDIR_SIZE + j*PMD_SIZE;
+			if (vaddr >= end)
+				break;
 			if (cpu_has_pse) {
 				unsigned long __pe;
 
@@ -349,10 +352,10 @@
 			if (pte != pte_offset(pmd, 0))
 				BUG();
 
-			for (k = 0;
-				(k < PTRS_PER_PTE) && (vaddr <= end);
-					pte++, k++) {
+			for (k = 0; k < PTRS_PER_PTE; pte++, k++) {
 				vaddr = i*PGDIR_SIZE + j*PMD_SIZE + k*PAGE_SIZE;
+				if (vaddr >= end)
+					break;
 				*pte = mk_pte_phys(__pa(vaddr), PAGE_KERNEL);
 			}
 		}

FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)