aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/mm/init_64.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/mm/init_64.c')
-rw-r--r--arch/x86/mm/init_64.c61
1 files changed, 40 insertions, 21 deletions
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index f79a02f64d10..9db01db6e3cd 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -671,12 +671,13 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
671 unsigned long last_map_addr = 0; 671 unsigned long last_map_addr = 0;
672 unsigned long page_size_mask = 0; 672 unsigned long page_size_mask = 0;
673 unsigned long start_pfn, end_pfn; 673 unsigned long start_pfn, end_pfn;
674 unsigned long pos;
674 675
675 struct map_range mr[NR_RANGE_MR]; 676 struct map_range mr[NR_RANGE_MR];
676 int nr_range, i; 677 int nr_range, i;
677 int use_pse, use_gbpages; 678 int use_pse, use_gbpages;
678 679
679 printk(KERN_INFO "init_memory_mapping\n"); 680 printk(KERN_INFO "init_memory_mapping: %016lx-%016lx\n", start, end);
680 681
681 /* 682 /*
682 * Find space for the kernel direct mapping tables. 683 * Find space for the kernel direct mapping tables.
@@ -710,35 +711,50 @@ unsigned long __init_refok init_memory_mapping(unsigned long start,
710 711
711 /* head if not big page alignment ?*/ 712 /* head if not big page alignment ?*/
712 start_pfn = start >> PAGE_SHIFT; 713 start_pfn = start >> PAGE_SHIFT;
713 end_pfn = ((start + (PMD_SIZE - 1)) >> PMD_SHIFT) 714 pos = start_pfn << PAGE_SHIFT;
715 end_pfn = ((pos + (PMD_SIZE - 1)) >> PMD_SHIFT)
714 << (PMD_SHIFT - PAGE_SHIFT); 716 << (PMD_SHIFT - PAGE_SHIFT);
715 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0); 717 if (start_pfn < end_pfn) {
718 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
719 pos = end_pfn << PAGE_SHIFT;
720 }
716 721
717 /* big page (2M) range*/ 722 /* big page (2M) range*/
718 start_pfn = ((start + (PMD_SIZE - 1))>>PMD_SHIFT) 723 start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
719 << (PMD_SHIFT - PAGE_SHIFT); 724 << (PMD_SHIFT - PAGE_SHIFT);
720 end_pfn = ((start + (PUD_SIZE - 1))>>PUD_SHIFT) 725 end_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
721 << (PUD_SHIFT - PAGE_SHIFT); 726 << (PUD_SHIFT - PAGE_SHIFT);
722 if (end_pfn > ((end>>PUD_SHIFT)<<(PUD_SHIFT - PAGE_SHIFT))) 727 if (end_pfn > ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT)))
723 end_pfn = ((end>>PUD_SHIFT)<<(PUD_SHIFT - PAGE_SHIFT)); 728 end_pfn = ((end>>PMD_SHIFT)<<(PMD_SHIFT - PAGE_SHIFT));
724 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 729 if (start_pfn < end_pfn) {
725 page_size_mask & (1<<PG_LEVEL_2M)); 730 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
731 page_size_mask & (1<<PG_LEVEL_2M));
732 pos = end_pfn << PAGE_SHIFT;
733 }
726 734
727 /* big page (1G) range */ 735 /* big page (1G) range */
728 start_pfn = end_pfn; 736 start_pfn = ((pos + (PUD_SIZE - 1))>>PUD_SHIFT)
729 end_pfn = (end>>PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT); 737 << (PUD_SHIFT - PAGE_SHIFT);
730 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 738 end_pfn = (end >> PUD_SHIFT) << (PUD_SHIFT - PAGE_SHIFT);
739 if (start_pfn < end_pfn) {
740 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
731 page_size_mask & 741 page_size_mask &
732 ((1<<PG_LEVEL_2M)|(1<<PG_LEVEL_1G))); 742 ((1<<PG_LEVEL_2M)|(1<<PG_LEVEL_1G)));
743 pos = end_pfn << PAGE_SHIFT;
744 }
733 745
734 /* tail is not big page (1G) alignment */ 746 /* tail is not big page (1G) alignment */
735 start_pfn = end_pfn; 747 start_pfn = ((pos + (PMD_SIZE - 1))>>PMD_SHIFT)
736 end_pfn = (end>>PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT); 748 << (PMD_SHIFT - PAGE_SHIFT);
737 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 749 end_pfn = (end >> PMD_SHIFT) << (PMD_SHIFT - PAGE_SHIFT);
738 page_size_mask & (1<<PG_LEVEL_2M)); 750 if (start_pfn < end_pfn) {
751 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn,
752 page_size_mask & (1<<PG_LEVEL_2M));
753 pos = end_pfn << PAGE_SHIFT;
754 }
739 755
740 /* tail is not big page (2M) alignment */ 756 /* tail is not big page (2M) alignment */
741 start_pfn = end_pfn; 757 start_pfn = pos>>PAGE_SHIFT;
742 end_pfn = end>>PAGE_SHIFT; 758 end_pfn = end>>PAGE_SHIFT;
743 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0); 759 nr_range = save_mr(mr, nr_range, start_pfn, end_pfn, 0);
744 760
@@ -842,7 +858,7 @@ int arch_add_memory(int nid, u64 start, u64 size)
842 max_pfn_mapped = last_mapped_pfn; 858 max_pfn_mapped = last_mapped_pfn;
843 859
844 ret = __add_pages(zone, start_pfn, nr_pages); 860 ret = __add_pages(zone, start_pfn, nr_pages);
845 WARN_ON(1); 861 WARN_ON_ONCE(ret);
846 862
847 return ret; 863 return ret;
848} 864}
@@ -884,6 +900,7 @@ static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel,
884void __init mem_init(void) 900void __init mem_init(void)
885{ 901{
886 long codesize, reservedpages, datasize, initsize; 902 long codesize, reservedpages, datasize, initsize;
903 unsigned long absent_pages;
887 904
888 start_periodic_check_for_corruption(); 905 start_periodic_check_for_corruption();
889 906
@@ -899,8 +916,9 @@ void __init mem_init(void)
899#else 916#else
900 totalram_pages = free_all_bootmem(); 917 totalram_pages = free_all_bootmem();
901#endif 918#endif
902 reservedpages = max_pfn - totalram_pages - 919
903 absent_pages_in_range(0, max_pfn); 920 absent_pages = absent_pages_in_range(0, max_pfn);
921 reservedpages = max_pfn - totalram_pages - absent_pages;
904 after_bootmem = 1; 922 after_bootmem = 1;
905 923
906 codesize = (unsigned long) &_etext - (unsigned long) &_text; 924 codesize = (unsigned long) &_etext - (unsigned long) &_text;
@@ -917,10 +935,11 @@ void __init mem_init(void)
917 VSYSCALL_END - VSYSCALL_START); 935 VSYSCALL_END - VSYSCALL_START);
918 936
919 printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, " 937 printk(KERN_INFO "Memory: %luk/%luk available (%ldk kernel code, "
920 "%ldk reserved, %ldk data, %ldk init)\n", 938 "%ldk absent, %ldk reserved, %ldk data, %ldk init)\n",
921 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10), 939 (unsigned long) nr_free_pages() << (PAGE_SHIFT-10),
922 max_pfn << (PAGE_SHIFT-10), 940 max_pfn << (PAGE_SHIFT-10),
923 codesize >> 10, 941 codesize >> 10,
942 absent_pages << (PAGE_SHIFT-10),
924 reservedpages << (PAGE_SHIFT-10), 943 reservedpages << (PAGE_SHIFT-10),
925 datasize >> 10, 944 datasize >> 10,
926 initsize >> 10); 945 initsize >> 10);