Merge branch 'linus' into tracing/mmiotrace-mergefixups
[pandora-kernel.git] / arch / x86 / mm / init_64.c
index b798e7b..a5fd2e0 100644 (file)
@@ -206,7 +206,7 @@ void __init cleanup_highmap(void)
        pmd_t *last_pmd = pmd + PTRS_PER_PMD;
 
        for (; pmd < last_pmd; pmd++, vaddr += PMD_SIZE) {
-               if (!pmd_present(*pmd))
+               if (pmd_none(*pmd))
                        continue;
                if (vaddr < (unsigned long) _text || vaddr > end)
                        set_pmd(pmd, __pmd(0));
@@ -506,7 +506,7 @@ early_param("memtest", parse_memtest);
 
 static void __init early_memtest(unsigned long start, unsigned long end)
 {
-       unsigned long t_start, t_size;
+       u64 t_start, t_size;
        unsigned pattern;
 
        if (!memtest_pattern)
@@ -525,7 +525,7 @@ static void __init early_memtest(unsigned long start, unsigned long end)
                        if (t_start + t_size > end)
                                t_size = end - t_start;
 
-                       printk(KERN_CONT "\n  %016lx - %016lx pattern %d",
+                       printk(KERN_CONT "\n  %016llx - %016llx pattern %d",
                                t_start, t_start + t_size, pattern);
 
                        memtest(t_start, t_size, pattern);
@@ -620,15 +620,6 @@ void __init paging_init(void)
 /*
  * Memory hotplug specific functions
  */
-void online_page(struct page *page)
-{
-       ClearPageReserved(page);
-       init_page_count(page);
-       __free_page(page);
-       totalram_pages++;
-       num_physpages++;
-}
-
 #ifdef CONFIG_MEMORY_HOTPLUG
 /*
  * Memory is added always to NORMAL zone. This means you will never get
@@ -663,6 +654,26 @@ EXPORT_SYMBOL_GPL(memory_add_physaddr_to_nid);
 
 #endif /* CONFIG_MEMORY_HOTPLUG */
 
+/*
+ * devmem_is_allowed() checks to see if /dev/mem access to a certain address
+ * is valid. The argument is a physical page number.
+ *
+ *
+ * On x86, access has to be given to the first megabyte of ram because that area
+ * contains bios code and data regions used by X and dosemu and similar apps.
+ * Access has to be given to non-kernel-ram areas as well, these contain the PCI
+ * mmio resources as well as potential bios/acpi data regions.
+ */
+int devmem_is_allowed(unsigned long pagenr)
+{
+       if (pagenr <= 256)
+               return 1;
+       if (!page_is_ram(pagenr))
+               return 1;
+       return 0;
+}
+
+
 static struct kcore_list kcore_mem, kcore_vmalloc, kcore_kernel,
                         kcore_modules, kcore_vsyscall;
 
@@ -755,6 +766,13 @@ EXPORT_SYMBOL_GPL(rodata_test_data);
 void mark_rodata_ro(void)
 {
        unsigned long start = PFN_ALIGN(_stext), end = PFN_ALIGN(__end_rodata);
+       unsigned long rodata_start =
+               ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
+
+#ifdef CONFIG_DYNAMIC_FTRACE
+       /* Dynamic tracing modifies the kernel text section */
+       start = rodata_start;
+#endif
 
        printk(KERN_INFO "Write protecting the kernel read-only data: %luk\n",
               (end - start) >> 10);
@@ -764,8 +782,7 @@ void mark_rodata_ro(void)
         * The rodata section (but not the kernel text!) should also be
         * not-executable.
         */
-       start = ((unsigned long)__start_rodata + PAGE_SIZE - 1) & PAGE_MASK;
-       set_memory_nx(start, (end - start) >> PAGE_SHIFT);
+       set_memory_nx(rodata_start, (end - rodata_start) >> PAGE_SHIFT);
 
        rodata_test();
 
@@ -790,7 +807,7 @@ void free_initrd_mem(unsigned long start, unsigned long end)
 void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
 {
 #ifdef CONFIG_NUMA
-       int nid = phys_to_nid(phys);
+       int nid, next_nid;
 #endif
        unsigned long pfn = phys >> PAGE_SHIFT;
 
@@ -809,10 +826,16 @@ void __init reserve_bootmem_generic(unsigned long phys, unsigned len)
 
        /* Should check here against the e820 map to avoid double free */
 #ifdef CONFIG_NUMA
-       reserve_bootmem_node(NODE_DATA(nid), phys, len, BOOTMEM_DEFAULT);
+       nid = phys_to_nid(phys);
+       next_nid = phys_to_nid(phys + len - 1);
+       if (nid == next_nid)
+               reserve_bootmem_node(NODE_DATA(nid), phys, len, BOOTMEM_DEFAULT);
+       else
+               reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
 #else
        reserve_bootmem(phys, len, BOOTMEM_DEFAULT);
 #endif
+
        if (phys+len <= MAX_DMA_PFN*PAGE_SIZE) {
                dma_reserve += len / PAGE_SIZE;
                set_dma_reserve(dma_reserve);
@@ -906,6 +929,10 @@ const char *arch_vma_name(struct vm_area_struct *vma)
 /*
  * Initialise the sparsemem vmemmap using huge-pages at the PMD level.
  */
+static long __meminitdata addr_start, addr_end;
+static void __meminitdata *p_start, *p_end;
+static int __meminitdata node_start;
+
 int __meminit
 vmemmap_populate(struct page *start_page, unsigned long size, int node)
 {
@@ -940,12 +967,32 @@ vmemmap_populate(struct page *start_page, unsigned long size, int node)
                                                        PAGE_KERNEL_LARGE);
                        set_pmd(pmd, __pmd(pte_val(entry)));
 
-                       printk(KERN_DEBUG " [%lx-%lx] PMD ->%p on node %d\n",
-                               addr, addr + PMD_SIZE - 1, p, node);
+                       /* check to see if we have contiguous blocks */
+                       if (p_end != p || node_start != node) {
+                               if (p_start)
+                                       printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
+                                               addr_start, addr_end-1, p_start, p_end-1, node_start);
+                               addr_start = addr;
+                               node_start = node;
+                               p_start = p;
+                       }
+                       addr_end = addr + PMD_SIZE;
+                       p_end = p + PMD_SIZE;
                } else {
                        vmemmap_verify((pte_t *)pmd, node, addr, next);
                }
        }
        return 0;
 }
+
+void __meminit vmemmap_populate_print_last(void)
+{
+       if (p_start) {
+               printk(KERN_DEBUG " [%lx-%lx] PMD -> [%p-%p] on node %d\n",
+                       addr_start, addr_end-1, p_start, p_end-1, node_start);
+               p_start = NULL;
+               p_end = NULL;
+               node_start = 0;
+       }
+}
 #endif