diff options
Diffstat (limited to 'arch/x86/mm/init.c')
| -rw-r--r-- | arch/x86/mm/init.c | 77 |
1 files changed, 69 insertions, 8 deletions
diff --git a/arch/x86/mm/init.c b/arch/x86/mm/init.c index 4b98df0973b9..34c1bfb64f1c 100644 --- a/arch/x86/mm/init.c +++ b/arch/x86/mm/init.c | |||
| @@ -11,6 +11,9 @@ | |||
| 11 | #include <asm/setup.h> | 11 | #include <asm/setup.h> |
| 12 | #include <asm/system.h> | 12 | #include <asm/system.h> |
| 13 | #include <asm/tlbflush.h> | 13 | #include <asm/tlbflush.h> |
| 14 | #include <asm/tlb.h> | ||
| 15 | |||
| 16 | DEFINE_PER_CPU(struct mmu_gather, mmu_gathers); | ||
| 14 | 17 | ||
| 15 | unsigned long __initdata e820_table_start; | 18 | unsigned long __initdata e820_table_start; |
| 16 | unsigned long __meminitdata e820_table_end; | 19 | unsigned long __meminitdata e820_table_end; |
| @@ -24,6 +27,69 @@ int direct_gbpages | |||
| 24 | #endif | 27 | #endif |
| 25 | ; | 28 | ; |
| 26 | 29 | ||
| 30 | int nx_enabled; | ||
| 31 | |||
| 32 | #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) | ||
| 33 | static int disable_nx __cpuinitdata; | ||
| 34 | |||
| 35 | /* | ||
| 36 | * noexec = on|off | ||
| 37 | * | ||
| 38 | * Control non-executable mappings for processes. | ||
| 39 | * | ||
| 40 | * on Enable | ||
| 41 | * off Disable | ||
| 42 | */ | ||
| 43 | static int __init noexec_setup(char *str) | ||
| 44 | { | ||
| 45 | if (!str) | ||
| 46 | return -EINVAL; | ||
| 47 | if (!strncmp(str, "on", 2)) { | ||
| 48 | __supported_pte_mask |= _PAGE_NX; | ||
| 49 | disable_nx = 0; | ||
| 50 | } else if (!strncmp(str, "off", 3)) { | ||
| 51 | disable_nx = 1; | ||
| 52 | __supported_pte_mask &= ~_PAGE_NX; | ||
| 53 | } | ||
| 54 | return 0; | ||
| 55 | } | ||
| 56 | early_param("noexec", noexec_setup); | ||
| 57 | #endif | ||
| 58 | |||
| 59 | #ifdef CONFIG_X86_PAE | ||
| 60 | static void __init set_nx(void) | ||
| 61 | { | ||
| 62 | unsigned int v[4], l, h; | ||
| 63 | |||
| 64 | if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) { | ||
| 65 | cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]); | ||
| 66 | |||
| 67 | if ((v[3] & (1 << 20)) && !disable_nx) { | ||
| 68 | rdmsr(MSR_EFER, l, h); | ||
| 69 | l |= EFER_NX; | ||
| 70 | wrmsr(MSR_EFER, l, h); | ||
| 71 | nx_enabled = 1; | ||
| 72 | __supported_pte_mask |= _PAGE_NX; | ||
| 73 | } | ||
| 74 | } | ||
| 75 | } | ||
| 76 | #else | ||
| 77 | static inline void set_nx(void) | ||
| 78 | { | ||
| 79 | } | ||
| 80 | #endif | ||
| 81 | |||
| 82 | #ifdef CONFIG_X86_64 | ||
| 83 | void __cpuinit check_efer(void) | ||
| 84 | { | ||
| 85 | unsigned long efer; | ||
| 86 | |||
| 87 | rdmsrl(MSR_EFER, efer); | ||
| 88 | if (!(efer & EFER_NX) || disable_nx) | ||
| 89 | __supported_pte_mask &= ~_PAGE_NX; | ||
| 90 | } | ||
| 91 | #endif | ||
| 92 | |||
| 27 | static void __init find_early_table_space(unsigned long end, int use_pse, | 93 | static void __init find_early_table_space(unsigned long end, int use_pse, |
| 28 | int use_gbpages) | 94 | int use_gbpages) |
| 29 | { | 95 | { |
| @@ -67,12 +133,11 @@ static void __init find_early_table_space(unsigned long end, int use_pse, | |||
| 67 | */ | 133 | */ |
| 68 | #ifdef CONFIG_X86_32 | 134 | #ifdef CONFIG_X86_32 |
| 69 | start = 0x7000; | 135 | start = 0x7000; |
| 70 | e820_table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT, | 136 | #else |
| 71 | tables, PAGE_SIZE); | ||
| 72 | #else /* CONFIG_X86_64 */ | ||
| 73 | start = 0x8000; | 137 | start = 0x8000; |
| 74 | e820_table_start = find_e820_area(start, end, tables, PAGE_SIZE); | ||
| 75 | #endif | 138 | #endif |
| 139 | e820_table_start = find_e820_area(start, max_pfn_mapped<<PAGE_SHIFT, | ||
| 140 | tables, PAGE_SIZE); | ||
| 76 | if (e820_table_start == -1UL) | 141 | if (e820_table_start == -1UL) |
| 77 | panic("Cannot find space for the kernel page tables"); | 142 | panic("Cannot find space for the kernel page tables"); |
| 78 | 143 | ||
| @@ -160,12 +225,9 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, | |||
| 160 | use_gbpages = direct_gbpages; | 225 | use_gbpages = direct_gbpages; |
| 161 | #endif | 226 | #endif |
| 162 | 227 | ||
| 163 | #ifdef CONFIG_X86_32 | ||
| 164 | #ifdef CONFIG_X86_PAE | ||
| 165 | set_nx(); | 228 | set_nx(); |
| 166 | if (nx_enabled) | 229 | if (nx_enabled) |
| 167 | printk(KERN_INFO "NX (Execute Disable) protection: active\n"); | 230 | printk(KERN_INFO "NX (Execute Disable) protection: active\n"); |
| 168 | #endif | ||
| 169 | 231 | ||
| 170 | /* Enable PSE if available */ | 232 | /* Enable PSE if available */ |
| 171 | if (cpu_has_pse) | 233 | if (cpu_has_pse) |
| @@ -176,7 +238,6 @@ unsigned long __init_refok init_memory_mapping(unsigned long start, | |||
| 176 | set_in_cr4(X86_CR4_PGE); | 238 | set_in_cr4(X86_CR4_PGE); |
| 177 | __supported_pte_mask |= _PAGE_GLOBAL; | 239 | __supported_pte_mask |= _PAGE_GLOBAL; |
| 178 | } | 240 | } |
| 179 | #endif | ||
| 180 | 241 | ||
| 181 | if (use_gbpages) | 242 | if (use_gbpages) |
| 182 | page_size_mask |= 1 << PG_LEVEL_1G; | 243 | page_size_mask |= 1 << PG_LEVEL_1G; |
