aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86
diff options
context:
space:
mode:
authorYinghai Lu <yhlu.kernel@gmail.com>2008-05-21 21:40:18 -0400
committerThomas Gleixner <tglx@linutronix.de>2008-05-25 04:55:12 -0400
commitba5b14cc0311af6ed20dc25aa98a1d5ea6f2e6c0 (patch)
tree7ca09bd16d83d6426fc49f210e61e95e2c74231c /arch/x86
parenta4c81cf684350797939416c99effb9d3ae46bca6 (diff)
x86: extend e820 ealy_res support 32bit - fix
use find_e820_area to find addess for new RAMDISK, instead of using ram blindly also print out low ram and bootmap info Signed-off-by: Yinghai Lu <yhlu.kernel@gmail.com> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Jeremy Fitzhardinge <jeremy@goop.org> Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86')
-rw-r--r--arch/x86/kernel/setup_32.c55
1 files changed, 31 insertions, 24 deletions
diff --git a/arch/x86/kernel/setup_32.c b/arch/x86/kernel/setup_32.c
index fed482c62450..3c451d143eba 100644
--- a/arch/x86/kernel/setup_32.c
+++ b/arch/x86/kernel/setup_32.c
@@ -466,11 +466,11 @@ static bool do_relocate_initrd = false;
466 466
467static void __init reserve_initrd(void) 467static void __init reserve_initrd(void)
468{ 468{
469 unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; 469 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
470 unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; 470 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
471 unsigned long ramdisk_end = ramdisk_image + ramdisk_size; 471 u64 ramdisk_end = ramdisk_image + ramdisk_size;
472 unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT; 472 u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
473 unsigned long ramdisk_here; 473 u64 ramdisk_here;
474 474
475 if (!boot_params.hdr.type_of_loader || 475 if (!boot_params.hdr.type_of_loader ||
476 !ramdisk_image || !ramdisk_size) 476 !ramdisk_image || !ramdisk_size)
@@ -478,14 +478,8 @@ static void __init reserve_initrd(void)
478 478
479 initrd_start = 0; 479 initrd_start = 0;
480 480
481 if (ramdisk_end < ramdisk_image) {
482 free_bootmem(ramdisk_image, ramdisk_size);
483 printk(KERN_ERR "initrd wraps around end of memory, "
484 "disabling initrd\n");
485 return;
486 }
487 if (ramdisk_size >= end_of_lowmem/2) { 481 if (ramdisk_size >= end_of_lowmem/2) {
488 free_bootmem(ramdisk_image, ramdisk_size); 482 free_early(ramdisk_image, ramdisk_image + ramdisk_size - 1);
489 printk(KERN_ERR "initrd too large to handle, " 483 printk(KERN_ERR "initrd too large to handle, "
490 "disabling initrd\n"); 484 "disabling initrd\n");
491 return; 485 return;
@@ -495,8 +489,7 @@ static void __init reserve_initrd(void)
495 /* All in lowmem, easy case */ 489 /* All in lowmem, easy case */
496 /* 490 /*
497 * don't need to reserve again, already reserved early 491 * don't need to reserve again, already reserved early
498 * in i386_start_kernel, and early_res_to_bootmem 492 * in i386_start_kernel
499 * convert that to reserved in bootmem
500 */ 493 */
501 initrd_start = ramdisk_image + PAGE_OFFSET; 494 initrd_start = ramdisk_image + PAGE_OFFSET;
502 initrd_end = initrd_start+ramdisk_size; 495 initrd_end = initrd_start+ramdisk_size;
@@ -504,11 +497,14 @@ static void __init reserve_initrd(void)
504 } 497 }
505 498
506 /* We need to move the initrd down into lowmem */ 499 /* We need to move the initrd down into lowmem */
507 ramdisk_here = (end_of_lowmem - ramdisk_size) & PAGE_MASK; 500 ramdisk_here = find_e820_area(min_low_pfn<<PAGE_SHIFT,
501 end_of_lowmem, ramdisk_size,
502 PAGE_SIZE);
508 503
509 /* Note: this includes all the lowmem currently occupied by 504 /* Note: this includes all the lowmem currently occupied by
510 the initrd, we rely on that fact to keep the data intact. */ 505 the initrd, we rely on that fact to keep the data intact. */
511 reserve_bootmem(ramdisk_here, ramdisk_size, BOOTMEM_DEFAULT); 506 reserve_early(ramdisk_here, ramdisk_here + ramdisk_size - 1,
507 "NEW RAMDISK");
512 initrd_start = ramdisk_here + PAGE_OFFSET; 508 initrd_start = ramdisk_here + PAGE_OFFSET;
513 initrd_end = initrd_start + ramdisk_size; 509 initrd_end = initrd_start + ramdisk_size;
514 510
@@ -519,10 +515,10 @@ static void __init reserve_initrd(void)
519 515
520static void __init relocate_initrd(void) 516static void __init relocate_initrd(void)
521{ 517{
522 unsigned long ramdisk_image = boot_params.hdr.ramdisk_image; 518 u64 ramdisk_image = boot_params.hdr.ramdisk_image;
523 unsigned long ramdisk_size = boot_params.hdr.ramdisk_size; 519 u64 ramdisk_size = boot_params.hdr.ramdisk_size;
524 unsigned long end_of_lowmem = max_low_pfn << PAGE_SHIFT; 520 u64 end_of_lowmem = max_low_pfn << PAGE_SHIFT;
525 unsigned long ramdisk_here; 521 u64 ramdisk_here;
526 unsigned long slop, clen, mapaddr; 522 unsigned long slop, clen, mapaddr;
527 char *p, *q; 523 char *p, *q;
528 524
@@ -540,6 +536,8 @@ static void __init relocate_initrd(void)
540 memcpy(q, p, clen); 536 memcpy(q, p, clen);
541 q += clen; 537 q += clen;
542 /* need to free these low pages...*/ 538 /* need to free these low pages...*/
539 printk(KERN_INFO "Freeing old partial RAMDISK %08llx-%08llx\n",
540 ramdisk_image, ramdisk_image + clen - 1);
543 free_bootmem(ramdisk_image, clen); 541 free_bootmem(ramdisk_image, clen);
544 ramdisk_image += clen; 542 ramdisk_image += clen;
545 ramdisk_size -= clen; 543 ramdisk_size -= clen;
@@ -560,6 +558,11 @@ static void __init relocate_initrd(void)
560 ramdisk_size -= clen; 558 ramdisk_size -= clen;
561 } 559 }
562 /* high pages is not converted by early_res_to_bootmem */ 560 /* high pages is not converted by early_res_to_bootmem */
561 ramdisk_image = boot_params.hdr.ramdisk_image;
562 ramdisk_size = boot_params.hdr.ramdisk_size;
563 printk(KERN_INFO "Copied RAMDISK from %016llx - %016llx to %08llx - %08llx\n",
564 ramdisk_image, ramdisk_image + ramdisk_size - 1,
565 ramdisk_here, ramdisk_here + ramdisk_size - 1);
563} 566}
564 567
565#endif /* CONFIG_BLK_DEV_INITRD */ 568#endif /* CONFIG_BLK_DEV_INITRD */
@@ -576,10 +579,17 @@ void __init setup_bootmem_allocator(void)
576 PAGE_SIZE); 579 PAGE_SIZE);
577 if (bootmap == -1L) 580 if (bootmap == -1L)
578 panic("Cannot find bootmem map of size %ld\n", bootmap_size); 581 panic("Cannot find bootmem map of size %ld\n", bootmap_size);
582 reserve_early(bootmap, bootmap + bootmap_size - 1, "BOOTMAP");
583#ifdef CONFIG_BLK_DEV_INITRD
584 reserve_initrd();
585#endif
579 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn); 586 bootmap_size = init_bootmem(bootmap >> PAGE_SHIFT, max_low_pfn);
587 printk(KERN_INFO " low ram: %08lx - %08lx\n",
588 min_low_pfn<<PAGE_SHIFT, max_low_pfn<<PAGE_SHIFT);
589 printk(KERN_INFO " bootmap [%08lx - %08lx]\n",
590 bootmap, bootmap + bootmap_size - 1);
580 register_bootmem_low_pages(max_low_pfn); 591 register_bootmem_low_pages(max_low_pfn);
581 early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT); 592 early_res_to_bootmem(0, max_low_pfn<<PAGE_SHIFT);
582 reserve_bootmem(bootmap, bootmap_size, BOOTMEM_DEFAULT);
583 593
584#ifdef CONFIG_ACPI_SLEEP 594#ifdef CONFIG_ACPI_SLEEP
585 /* 595 /*
@@ -593,9 +603,6 @@ void __init setup_bootmem_allocator(void)
593 */ 603 */
594 find_smp_config(); 604 find_smp_config();
595#endif 605#endif
596#ifdef CONFIG_BLK_DEV_INITRD
597 reserve_initrd();
598#endif
599 numa_kva_reserve(); 606 numa_kva_reserve();
600 reserve_crashkernel(); 607 reserve_crashkernel();
601 608