linux 2.6.16.38 w/ vs2.0.3-rc1
[linux-2.6.git] / arch / i386 / mm / init.c
index f136da5..2700f01 100644 (file)
@@ -6,6 +6,7 @@
  *  Support of BIGMEM added by Gerhard Wichert, Siemens AG, July 1999
  */
 
+#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/signal.h>
 #include <linux/sched.h>
 #include <linux/init.h>
 #include <linux/highmem.h>
 #include <linux/pagemap.h>
-#include <linux/poison.h>
 #include <linux/bootmem.h>
 #include <linux/slab.h>
 #include <linux/proc_fs.h>
 #include <linux/efi.h>
 #include <linux/memory_hotplug.h>
 #include <linux/initrd.h>
-#include <linux/cpumask.h>
 
 #include <asm/processor.h>
 #include <asm/system.h>
@@ -233,27 +232,6 @@ int page_is_ram(unsigned long pagenr)
        return 0;
 }
 
-/*
- * 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;
-}
-
-EXPORT_SYMBOL_GPL(page_is_ram);
-
 #ifdef CONFIG_HIGHMEM
 pte_t *kmap_pte;
 pgprot_t kmap_prot;
@@ -292,7 +270,7 @@ static void __init permanent_kmaps_init(pgd_t *pgd_base)
 
 static void __meminit free_new_highpage(struct page *page)
 {
-       init_page_count(page);
+       set_page_count(page, 1);
        __free_page(page);
        totalhigh_pages++;
 }
@@ -406,7 +384,7 @@ static void __init pagetable_init (void)
 #endif
 }
 
-#if defined(CONFIG_SOFTWARE_SUSPEND) || defined(CONFIG_ACPI_SLEEP)
+#ifdef CONFIG_SOFTWARE_SUSPEND
 /*
  * Swap suspend & friends need this for resume because things like the intel-agp
  * driver might have split up a kernel 4MB mapping.
@@ -454,7 +432,7 @@ u64 __supported_pte_mask __read_mostly = ~_PAGE_NX;
  * Control non executable mappings.
  *
  * on      Enable
- * off     Disable (disables exec-shield too)
+ * off     Disable
  */
 void __init noexec_setup(const char *str)
 {
@@ -464,7 +442,6 @@ void __init noexec_setup(const char *str)
        } else if (!strncmp(str,"off",3)) {
                disable_nx = 1;
                __supported_pte_mask &= ~_PAGE_NX;
-               exec_shield = 0;
        }
 }
 
@@ -529,10 +506,7 @@ void __init paging_init(void)
        set_nx();
        if (nx_enabled)
                printk("NX (Execute Disable) protection: active\n");
-       else
 #endif
-       if (exec_shield)
-               printk("Using x86 segment limits to approximate NX protection\n");
 
        pagetable_init();
 
@@ -677,9 +651,8 @@ void __init mem_init(void)
  * Specifically, in the case of x86, we will always add
  * memory to the highmem for now.
  */
-#ifdef CONFIG_MEMORY_HOTPLUG
 #ifndef CONFIG_NEED_MULTIPLE_NODES
-int arch_add_memory(int nid, u64 start, u64 size)
+int add_memory(u64 start, u64 size)
 {
        struct pglist_data *pgdata = &contig_page_data;
        struct zone *zone = pgdata->node_zones + MAX_NR_ZONES-1;
@@ -694,7 +667,6 @@ int remove_memory(u64 start, u64 size)
        return -EINVAL;
 }
 #endif
-#endif
 
 kmem_cache_t *pgd_cache;
 kmem_cache_t *pmd_cache;
@@ -748,17 +720,33 @@ static int noinline do_test_wp_bit(void)
        return flag;
 }
 
+void free_initmem(void)
+{
+       unsigned long addr;
+
+       addr = (unsigned long)(&__init_begin);
+       for (; addr < (unsigned long)(&__init_end); addr += PAGE_SIZE) {
+               ClearPageReserved(virt_to_page(addr));
+               set_page_count(virt_to_page(addr), 1);
+               memset((void *)addr, 0xcc, PAGE_SIZE);
+               free_page(addr);
+               totalram_pages++;
+       }
+       printk (KERN_INFO "Freeing unused kernel memory: %dk freed\n", (__init_end - __init_begin) >> 10);
+}
+
 #ifdef CONFIG_DEBUG_RODATA
 
+extern char __start_rodata, __end_rodata;
 void mark_rodata_ro(void)
 {
-       unsigned long addr = (unsigned long)__start_rodata;
+       unsigned long addr = (unsigned long)&__start_rodata;
 
-       for (; addr < (unsigned long)__end_rodata; addr += PAGE_SIZE)
+       for (; addr < (unsigned long)&__end_rodata; addr += PAGE_SIZE)
                change_page_attr(virt_to_page(addr), 1, PAGE_KERNEL_RO);
 
-       printk("Write protecting the kernel read-only data: %uk\n",
-                       (__end_rodata - __start_rodata) >> 10);
+       printk ("Write protecting the kernel read-only data: %luk\n",
+                       (unsigned long)(&__end_rodata - &__start_rodata) >> 10);
 
        /*
         * change_page_attr() requires a global_flush_tlb() call after it.
@@ -770,31 +758,17 @@ void mark_rodata_ro(void)
 }
 #endif
 
-void free_init_pages(char *what, unsigned long begin, unsigned long end)
-{
-       unsigned long addr;
-
-       for (addr = begin; addr < end; addr += PAGE_SIZE) {
-               ClearPageReserved(virt_to_page(addr));
-               init_page_count(virt_to_page(addr));
-               memset((void *)addr, POISON_FREE_INITMEM, PAGE_SIZE);
-               free_page(addr);
-               totalram_pages++;
-       }
-       printk(KERN_INFO "Freeing %s: %ldk freed\n", what, (end - begin) >> 10);
-}
-
-void free_initmem(void)
-{
-       free_init_pages("unused kernel memory",
-                       (unsigned long)(&__init_begin),
-                       (unsigned long)(&__init_end));
-}
 
 #ifdef CONFIG_BLK_DEV_INITRD
 void free_initrd_mem(unsigned long start, unsigned long end)
 {
-       free_init_pages("initrd memory", start, end);
+       if (start < end)
+               printk (KERN_INFO "Freeing initrd memory: %ldk freed\n", (end - start) >> 10);
+       for (; start < end; start += PAGE_SIZE) {
+               ClearPageReserved(virt_to_page(start));
+               set_page_count(virt_to_page(start), 1);
+               free_page(start);
+               totalram_pages++;
+       }
 }
 #endif
-