]> git.karo-electronics.de Git - karo-tx-linux.git/blob - arch/x86/mm/setup_nx.c
Merge branch 'akpm-current/current'
[karo-tx-linux.git] / arch / x86 / mm / setup_nx.c
1 #include <linux/spinlock.h>
2 #include <linux/errno.h>
3 #include <linux/init.h>
4
5 #include <asm/pgtable.h>
6 #include <asm/proto.h>
7 #include <asm/cpufeature.h>
8
9 static int disable_nx;
10
11 /*
12  * noexec = on|off
13  *
14  * Control non-executable mappings for processes.
15  *
16  * on      Enable
17  * off     Disable
18  */
19 static int __init noexec_setup(char *str)
20 {
21         if (!str)
22                 return -EINVAL;
23         if (!strncmp(str, "on", 2)) {
24                 disable_nx = 0;
25         } else if (!strncmp(str, "off", 3)) {
26                 disable_nx = 1;
27         }
28         x86_configure_nx();
29         return 0;
30 }
31 early_param("noexec", noexec_setup);
32
33 void x86_configure_nx(void)
34 {
35         /* If disable_nx is set, clear NX on all new mappings going forward. */
36         if (disable_nx)
37                 __supported_pte_mask &= ~_PAGE_NX;
38 }
39
40 void __init x86_report_nx(void)
41 {
42         if (!boot_cpu_has(X86_FEATURE_NX)) {
43                 printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
44                        "missing in CPU!\n");
45         } else {
46 #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE)
47                 if (disable_nx) {
48                         printk(KERN_INFO "NX (Execute Disable) protection: "
49                                "disabled by kernel command line option\n");
50                 } else {
51                         printk(KERN_INFO "NX (Execute Disable) protection: "
52                                "active\n");
53                 }
54 #else
55                 /* 32bit non-PAE kernel, NX cannot be used */
56                 printk(KERN_NOTICE "Notice: NX (Execute Disable) protection "
57                        "cannot be enabled: non-PAE kernel!\n");
58 #endif
59         }
60 }