diff options
Diffstat (limited to 'arch/x86/kernel/setup.c')
-rw-r--r-- | arch/x86/kernel/setup.c | 162 |
1 files changed, 11 insertions, 151 deletions
diff --git a/arch/x86/kernel/setup.c b/arch/x86/kernel/setup.c index 32fe42f26e79..ae0d8042cf69 100644 --- a/arch/x86/kernel/setup.c +++ b/arch/x86/kernel/setup.c | |||
@@ -93,11 +93,13 @@ | |||
93 | #include <asm/desc.h> | 93 | #include <asm/desc.h> |
94 | #include <asm/dma.h> | 94 | #include <asm/dma.h> |
95 | #include <asm/iommu.h> | 95 | #include <asm/iommu.h> |
96 | #include <asm/gart.h> | ||
96 | #include <asm/mmu_context.h> | 97 | #include <asm/mmu_context.h> |
97 | #include <asm/proto.h> | 98 | #include <asm/proto.h> |
98 | 99 | ||
99 | #include <mach_apic.h> | 100 | #include <mach_apic.h> |
100 | #include <asm/paravirt.h> | 101 | #include <asm/paravirt.h> |
102 | #include <asm/hypervisor.h> | ||
101 | 103 | ||
102 | #include <asm/percpu.h> | 104 | #include <asm/percpu.h> |
103 | #include <asm/topology.h> | 105 | #include <asm/topology.h> |
@@ -448,6 +450,7 @@ static void __init reserve_early_setup_data(void) | |||
448 | * @size: Size of the crashkernel memory to reserve. | 450 | * @size: Size of the crashkernel memory to reserve. |
449 | * Returns the base address on success, and -1ULL on failure. | 451 | * Returns the base address on success, and -1ULL on failure. |
450 | */ | 452 | */ |
453 | static | ||
451 | unsigned long long __init find_and_reserve_crashkernel(unsigned long long size) | 454 | unsigned long long __init find_and_reserve_crashkernel(unsigned long long size) |
452 | { | 455 | { |
453 | const unsigned long long alignment = 16<<20; /* 16M */ | 456 | const unsigned long long alignment = 16<<20; /* 16M */ |
@@ -600,157 +603,7 @@ static struct x86_quirks default_x86_quirks __initdata = { | |||
600 | 603 | ||
601 | struct x86_quirks *x86_quirks __initdata = &default_x86_quirks; | 604 | struct x86_quirks *x86_quirks __initdata = &default_x86_quirks; |
602 | 605 | ||
603 | /* | 606 | #ifdef CONFIG_X86_RESERVE_LOW_64K |
604 | * Some BIOSes seem to corrupt the low 64k of memory during events | ||
605 | * like suspend/resume and unplugging an HDMI cable. Reserve all | ||
606 | * remaining free memory in that area and fill it with a distinct | ||
607 | * pattern. | ||
608 | */ | ||
609 | #ifdef CONFIG_X86_CHECK_BIOS_CORRUPTION | ||
610 | #define MAX_SCAN_AREAS 8 | ||
611 | |||
612 | static int __read_mostly memory_corruption_check = -1; | ||
613 | |||
614 | static unsigned __read_mostly corruption_check_size = 64*1024; | ||
615 | static unsigned __read_mostly corruption_check_period = 60; /* seconds */ | ||
616 | |||
617 | static struct e820entry scan_areas[MAX_SCAN_AREAS]; | ||
618 | static int num_scan_areas; | ||
619 | |||
620 | |||
621 | static int set_corruption_check(char *arg) | ||
622 | { | ||
623 | char *end; | ||
624 | |||
625 | memory_corruption_check = simple_strtol(arg, &end, 10); | ||
626 | |||
627 | return (*end == 0) ? 0 : -EINVAL; | ||
628 | } | ||
629 | early_param("memory_corruption_check", set_corruption_check); | ||
630 | |||
631 | static int set_corruption_check_period(char *arg) | ||
632 | { | ||
633 | char *end; | ||
634 | |||
635 | corruption_check_period = simple_strtoul(arg, &end, 10); | ||
636 | |||
637 | return (*end == 0) ? 0 : -EINVAL; | ||
638 | } | ||
639 | early_param("memory_corruption_check_period", set_corruption_check_period); | ||
640 | |||
641 | static int set_corruption_check_size(char *arg) | ||
642 | { | ||
643 | char *end; | ||
644 | unsigned size; | ||
645 | |||
646 | size = memparse(arg, &end); | ||
647 | |||
648 | if (*end == '\0') | ||
649 | corruption_check_size = size; | ||
650 | |||
651 | return (size == corruption_check_size) ? 0 : -EINVAL; | ||
652 | } | ||
653 | early_param("memory_corruption_check_size", set_corruption_check_size); | ||
654 | |||
655 | |||
656 | static void __init setup_bios_corruption_check(void) | ||
657 | { | ||
658 | u64 addr = PAGE_SIZE; /* assume first page is reserved anyway */ | ||
659 | |||
660 | if (memory_corruption_check == -1) { | ||
661 | memory_corruption_check = | ||
662 | #ifdef CONFIG_X86_BOOTPARAM_MEMORY_CORRUPTION_CHECK | ||
663 | 1 | ||
664 | #else | ||
665 | 0 | ||
666 | #endif | ||
667 | ; | ||
668 | } | ||
669 | |||
670 | if (corruption_check_size == 0) | ||
671 | memory_corruption_check = 0; | ||
672 | |||
673 | if (!memory_corruption_check) | ||
674 | return; | ||
675 | |||
676 | corruption_check_size = round_up(corruption_check_size, PAGE_SIZE); | ||
677 | |||
678 | while(addr < corruption_check_size && num_scan_areas < MAX_SCAN_AREAS) { | ||
679 | u64 size; | ||
680 | addr = find_e820_area_size(addr, &size, PAGE_SIZE); | ||
681 | |||
682 | if (addr == 0) | ||
683 | break; | ||
684 | |||
685 | if ((addr + size) > corruption_check_size) | ||
686 | size = corruption_check_size - addr; | ||
687 | |||
688 | if (size == 0) | ||
689 | break; | ||
690 | |||
691 | e820_update_range(addr, size, E820_RAM, E820_RESERVED); | ||
692 | scan_areas[num_scan_areas].addr = addr; | ||
693 | scan_areas[num_scan_areas].size = size; | ||
694 | num_scan_areas++; | ||
695 | |||
696 | /* Assume we've already mapped this early memory */ | ||
697 | memset(__va(addr), 0, size); | ||
698 | |||
699 | addr += size; | ||
700 | } | ||
701 | |||
702 | printk(KERN_INFO "Scanning %d areas for low memory corruption\n", | ||
703 | num_scan_areas); | ||
704 | update_e820(); | ||
705 | } | ||
706 | |||
707 | static struct timer_list periodic_check_timer; | ||
708 | |||
709 | void check_for_bios_corruption(void) | ||
710 | { | ||
711 | int i; | ||
712 | int corruption = 0; | ||
713 | |||
714 | if (!memory_corruption_check) | ||
715 | return; | ||
716 | |||
717 | for(i = 0; i < num_scan_areas; i++) { | ||
718 | unsigned long *addr = __va(scan_areas[i].addr); | ||
719 | unsigned long size = scan_areas[i].size; | ||
720 | |||
721 | for(; size; addr++, size -= sizeof(unsigned long)) { | ||
722 | if (!*addr) | ||
723 | continue; | ||
724 | printk(KERN_ERR "Corrupted low memory at %p (%lx phys) = %08lx\n", | ||
725 | addr, __pa(addr), *addr); | ||
726 | corruption = 1; | ||
727 | *addr = 0; | ||
728 | } | ||
729 | } | ||
730 | |||
731 | WARN(corruption, KERN_ERR "Memory corruption detected in low memory\n"); | ||
732 | } | ||
733 | |||
734 | static void periodic_check_for_corruption(unsigned long data) | ||
735 | { | ||
736 | check_for_bios_corruption(); | ||
737 | mod_timer(&periodic_check_timer, round_jiffies(jiffies + corruption_check_period*HZ)); | ||
738 | } | ||
739 | |||
740 | void start_periodic_check_for_corruption(void) | ||
741 | { | ||
742 | if (!memory_corruption_check || corruption_check_period == 0) | ||
743 | return; | ||
744 | |||
745 | printk(KERN_INFO "Scanning for low memory corruption every %d seconds\n", | ||
746 | corruption_check_period); | ||
747 | |||
748 | init_timer(&periodic_check_timer); | ||
749 | periodic_check_timer.function = &periodic_check_for_corruption; | ||
750 | periodic_check_for_corruption(0); | ||
751 | } | ||
752 | #endif | ||
753 | |||
754 | static int __init dmi_low_memory_corruption(const struct dmi_system_id *d) | 607 | static int __init dmi_low_memory_corruption(const struct dmi_system_id *d) |
755 | { | 608 | { |
756 | printk(KERN_NOTICE | 609 | printk(KERN_NOTICE |
@@ -762,6 +615,7 @@ static int __init dmi_low_memory_corruption(const struct dmi_system_id *d) | |||
762 | 615 | ||
763 | return 0; | 616 | return 0; |
764 | } | 617 | } |
618 | #endif | ||
765 | 619 | ||
766 | /* List of systems that have known low memory corruption BIOS problems */ | 620 | /* List of systems that have known low memory corruption BIOS problems */ |
767 | static struct dmi_system_id __initdata bad_bios_dmi_table[] = { | 621 | static struct dmi_system_id __initdata bad_bios_dmi_table[] = { |
@@ -920,6 +774,12 @@ void __init setup_arch(char **cmdline_p) | |||
920 | 774 | ||
921 | dmi_check_system(bad_bios_dmi_table); | 775 | dmi_check_system(bad_bios_dmi_table); |
922 | 776 | ||
777 | /* | ||
778 | * VMware detection requires dmi to be available, so this | ||
779 | * needs to be done after dmi_scan_machine, for the BP. | ||
780 | */ | ||
781 | init_hypervisor(&boot_cpu_data); | ||
782 | |||
923 | #ifdef CONFIG_X86_32 | 783 | #ifdef CONFIG_X86_32 |
924 | probe_roms(); | 784 | probe_roms(); |
925 | #endif | 785 | #endif |