Commit | Line | Data |
---|---|---|
c44c9ec0 JF |
1 | #include <linux/spinlock.h> |
2 | #include <linux/errno.h> | |
3 | #include <linux/init.h> | |
4 | ||
5 | #include <asm/pgtable.h> | |
4763ed4d | 6 | #include <asm/proto.h> |
c44c9ec0 | 7 | |
148f9bb8 | 8 | static int disable_nx; |
c44c9ec0 JF |
9 | |
10 | /* | |
11 | * noexec = on|off | |
12 | * | |
13 | * Control non-executable mappings for processes. | |
14 | * | |
15 | * on Enable | |
16 | * off Disable | |
17 | */ | |
18 | static int __init noexec_setup(char *str) | |
19 | { | |
20 | if (!str) | |
21 | return -EINVAL; | |
22 | if (!strncmp(str, "on", 2)) { | |
c44c9ec0 JF |
23 | disable_nx = 0; |
24 | } else if (!strncmp(str, "off", 3)) { | |
25 | disable_nx = 1; | |
c44c9ec0 | 26 | } |
4763ed4d | 27 | x86_configure_nx(); |
c44c9ec0 JF |
28 | return 0; |
29 | } | |
30 | early_param("noexec", noexec_setup); | |
c44c9ec0 | 31 | |
148f9bb8 | 32 | void x86_configure_nx(void) |
c44c9ec0 | 33 | { |
362f924b | 34 | if (boot_cpu_has(X86_FEATURE_NX) && !disable_nx) |
4763ed4d PA |
35 | __supported_pte_mask |= _PAGE_NX; |
36 | else | |
c44c9ec0 JF |
37 | __supported_pte_mask &= ~_PAGE_NX; |
38 | } | |
4b0f3b81 KC |
39 | |
40 | void __init x86_report_nx(void) | |
41 | { | |
362f924b | 42 | if (!boot_cpu_has(X86_FEATURE_NX)) { |
4b0f3b81 | 43 | printk(KERN_NOTICE "Notice: NX (Execute Disable) protection " |
6036f373 | 44 | "missing in CPU!\n"); |
4b0f3b81 KC |
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 | } |