Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 1 | #include <linux/spinlock.h> |
| 2 | #include <linux/errno.h> |
| 3 | #include <linux/init.h> |
| 4 | |
| 5 | #include <asm/pgtable.h> |
H. Peter Anvin | 4763ed4 | 2009-11-13 15:28:16 -0800 | [diff] [blame^] | 6 | #include <asm/proto.h> |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 7 | |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 8 | static int disable_nx __cpuinitdata; |
| 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)) { |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 23 | disable_nx = 0; |
| 24 | } else if (!strncmp(str, "off", 3)) { |
| 25 | disable_nx = 1; |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 26 | } |
H. Peter Anvin | 4763ed4 | 2009-11-13 15:28:16 -0800 | [diff] [blame^] | 27 | x86_configure_nx(); |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 28 | return 0; |
| 29 | } |
| 30 | early_param("noexec", noexec_setup); |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 31 | |
H. Peter Anvin | 4763ed4 | 2009-11-13 15:28:16 -0800 | [diff] [blame^] | 32 | void __cpuinit x86_configure_nx(void) |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 33 | { |
H. Peter Anvin | 4763ed4 | 2009-11-13 15:28:16 -0800 | [diff] [blame^] | 34 | if (cpu_has_nx && !disable_nx) |
| 35 | __supported_pte_mask |= _PAGE_NX; |
| 36 | else |
Jeremy Fitzhardinge | c44c9ec | 2009-09-21 13:40:42 -0700 | [diff] [blame] | 37 | __supported_pte_mask &= ~_PAGE_NX; |
| 38 | } |