Merge tag 'devicetree-for-4.21' of git://git.kernel.org/pub/scm/linux/kernel/git...
[linux-2.6-block.git] / arch / arm64 / mm / init.c
index ecc316beec6d0d7ec9e4be16356e83081fc29f10..a8f2e4792ef97b52a1f0850766e04dc9994c861f 100644 (file)
@@ -59,6 +59,8 @@
  * that cannot be mistaken for a real physical address.
  */
 s64 memstart_addr __ro_after_init = -1;
+EXPORT_SYMBOL(memstart_addr);
+
 phys_addr_t arm64_dma_phys_limit __ro_after_init;
 
 #ifdef CONFIG_KEXEC_CORE
@@ -271,6 +273,14 @@ int pfn_valid(unsigned long pfn)
 
        if ((addr >> PAGE_SHIFT) != pfn)
                return 0;
+
+#ifdef CONFIG_SPARSEMEM
+       if (pfn_to_section_nr(pfn) >= NR_MEM_SECTIONS)
+               return 0;
+
+       if (!valid_section(__nr_to_section(pfn_to_section_nr(pfn))))
+               return 0;
+#endif
        return memblock_is_map_memory(addr);
 }
 EXPORT_SYMBOL(pfn_valid);
@@ -585,15 +595,7 @@ void __init mem_init(void)
         * detected at build time already.
         */
 #ifdef CONFIG_COMPAT
-       BUILD_BUG_ON(TASK_SIZE_32                       > TASK_SIZE_64);
-#endif
-
-#ifdef CONFIG_SPARSEMEM_VMEMMAP
-       /*
-        * Make sure we chose the upper bound of sizeof(struct page)
-        * correctly when sizing the VMEMMAP array.
-        */
-       BUILD_BUG_ON(sizeof(struct page) > (1 << STRUCT_PAGE_MAX_SHIFT));
+       BUILD_BUG_ON(TASK_SIZE_32 > DEFAULT_MAP_WINDOW_64);
 #endif
 
        if (PAGE_SIZE >= 16384 && get_num_physpages() <= 128) {