Merge to Fedora kernel-2.6.7-1.492
[linux-2.6.git] / arch / i386 / mm / init.c
index 837110f..2fc263c 100644 (file)
@@ -382,8 +382,8 @@ static int __init noexec_setup(char *str)
 
 __setup("noexec=", noexec_setup);
 
-int use_nx = 0;
 #ifdef CONFIG_X86_PAE
+int nx_enabled = 0;
 
 static void __init set_nx(void)
 {
@@ -395,11 +395,37 @@ static void __init set_nx(void)
                        rdmsr(MSR_EFER, l, h);
                        l |= EFER_NX;
                        wrmsr(MSR_EFER, l, h);
-                       use_nx = 1;
+                       nx_enabled = 1;
                        __supported_pte_mask |= _PAGE_NX;
                }
        }
 }
+/*
+ * Enables/disables executability of a given kernel page and
+ * returns the previous setting.
+ */
+int __init set_kernel_exec(unsigned long vaddr, int enable)
+{
+       pte_t *pte;
+       int ret = 1;
+
+       if (!nx_enabled)
+               goto out;
+
+       pte = lookup_address(vaddr);
+       BUG_ON(!pte);
+
+       if (!pte_exec_kernel(*pte))
+               ret = 0;
+
+       if (enable)
+               pte->pte_high &= ~(1 << (_PAGE_BIT_NX - 32));
+       else
+               pte->pte_high |= 1 << (_PAGE_BIT_NX - 32);
+       __flush_tlb_all();
+out:
+       return ret;
+}
 
 #endif
 
@@ -414,13 +440,8 @@ void __init paging_init(void)
 {
 #ifdef CONFIG_X86_PAE
        set_nx();
-       if (use_nx)
+       if (nx_enabled)
                printk("NX (Execute Disable) protection: active\n");
-       else {
-               printk("NX (Execute Disable) protection: not present!\n");
-               if (exec_shield)
-                       printk("Using x86 segment limits to approximate NX protection\n");
-       }
 #endif
 
        pagetable_init();
@@ -448,6 +469,7 @@ void __init paging_init(void)
        kmap_init();
        zone_sizes_init();
 }
+
 /*
  * Test if the WP bit works in supervisor mode. It isn't supported on 386's
  * and also on some strange 486's (NexGen etc.). All 586+'s are OK. This