Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge branch 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip

* 'x86-fixes-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/linux-2.6-tip:
x86: Remove redundant non-NUMA topology functions
x86: early_printk: Protect against using the same device twice
x86: Reduce verbosity of "PAT enabled" kernel message
x86: Reduce verbosity of "TSC is reliable" message
x86: mce: Use safer ways to access MCE registers
x86: mce, inject: Use real inject-msg in raise_local
x86: mce: Fix thermal throttling message storm
x86: mce: Clean up thermal throttling state tracking code
x86: split NX setup into separate file to limit unstack-protected code
xen: check EFER for NX before setting up GDT mapping
x86: Cleanup linker script using new linker script macros.
x86: Use section .data.page_aligned for the idt_table.
x86: convert to use __HEAD and HEAD_TEXT macros.
x86: convert compressed loader to use __HEAD and HEAD_TEXT macros.
x86: fix fragile computation of vsyscall address

+180 -188
+2 -1
arch/x86/boot/compressed/head_32.S
··· 23 23 */ 24 24 .text 25 25 26 + #include <linux/init.h> 26 27 #include <linux/linkage.h> 27 28 #include <asm/segment.h> 28 29 #include <asm/page_types.h> 29 30 #include <asm/boot.h> 30 31 #include <asm/asm-offsets.h> 31 32 32 - .section ".text.head","ax",@progbits 33 + __HEAD 33 34 ENTRY(startup_32) 34 35 cld 35 36 /*
+2 -1
arch/x86/boot/compressed/head_64.S
··· 24 24 .code32 25 25 .text 26 26 27 + #include <linux/init.h> 27 28 #include <linux/linkage.h> 28 29 #include <asm/segment.h> 29 30 #include <asm/pgtable_types.h> ··· 34 33 #include <asm/processor-flags.h> 35 34 #include <asm/asm-offsets.h> 36 35 37 - .section ".text.head" 36 + __HEAD 38 37 .code32 39 38 ENTRY(startup_32) 40 39 cld
+4 -2
arch/x86/boot/compressed/vmlinux.lds.S
··· 1 + #include <asm-generic/vmlinux.lds.h> 2 + 1 3 OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT) 2 4 3 5 #undef i386 ··· 20 18 * address 0. 21 19 */ 22 20 . = 0; 23 - .text.head : { 21 + .head.text : { 24 22 _head = . ; 25 - *(.text.head) 23 + HEAD_TEXT 26 24 _ehead = . ; 27 25 } 28 26 .rodata.compressed : {
+1
arch/x86/include/asm/pgtable_types.h
··· 277 277 typedef struct page *pgtable_t; 278 278 279 279 extern pteval_t __supported_pte_mask; 280 + extern void set_nx(void); 280 281 extern int nx_enabled; 281 282 282 283 #define pgprot_writecombine pgprot_writecombine
-10
arch/x86/include/asm/topology.h
··· 165 165 return 0; 166 166 } 167 167 168 - static inline int cpu_to_node(int cpu) 169 - { 170 - return 0; 171 - } 172 - 173 168 static inline int early_cpu_to_node(int cpu) 174 169 { 175 170 return 0; 176 - } 177 - 178 - static inline const struct cpumask *cpumask_of_node(int node) 179 - { 180 - return cpu_online_mask; 181 171 } 182 172 183 173 static inline void setup_node_to_cpumask_map(void) { }
+4 -3
arch/x86/kernel/cpu/mcheck/mce-inject.c
··· 98 98 }; 99 99 100 100 /* Inject mce on current CPU */ 101 - static int raise_local(struct mce *m) 101 + static int raise_local(void) 102 102 { 103 + struct mce *m = &__get_cpu_var(injectm); 103 104 int context = MCJ_CTX(m->inject_flags); 104 105 int ret = 0; 105 106 int cpu = m->extcpu; ··· 168 167 } 169 168 cpu_relax(); 170 169 } 171 - raise_local(m); 170 + raise_local(); 172 171 put_cpu(); 173 172 put_online_cpus(); 174 173 } else 175 174 #endif 176 - raise_local(m); 175 + raise_local(); 177 176 } 178 177 179 178 /* Error injection interface */
+21 -2
arch/x86/kernel/cpu/mcheck/mce.c
··· 305 305 static u64 mce_rdmsrl(u32 msr) 306 306 { 307 307 u64 v; 308 + 308 309 if (__get_cpu_var(injectm).finished) { 309 310 int offset = msr_to_offset(msr); 311 + 310 312 if (offset < 0) 311 313 return 0; 312 314 return *(u64 *)((char *)&__get_cpu_var(injectm) + offset); 313 315 } 314 - rdmsrl(msr, v); 316 + 317 + if (rdmsrl_safe(msr, &v)) { 318 + WARN_ONCE(1, "mce: Unable to read msr %d!\n", msr); 319 + /* 320 + * Return zero in case the access faulted. This should 321 + * not happen normally but can happen if the CPU does 322 + * something weird, or if the code is buggy. 323 + */ 324 + v = 0; 325 + } 326 + 315 327 return v; 316 328 } 317 329 ··· 331 319 { 332 320 if (__get_cpu_var(injectm).finished) { 333 321 int offset = msr_to_offset(msr); 322 + 334 323 if (offset >= 0) 335 324 *(u64 *)((char *)&__get_cpu_var(injectm) + offset) = v; 336 325 return; ··· 428 415 m->ip = mce_rdmsrl(rip_msr); 429 416 } 430 417 431 - #ifdef CONFIG_X86_LOCAL_APIC 418 + #ifdef CONFIG_X86_LOCAL_APIC 432 419 /* 433 420 * Called after interrupts have been reenabled again 434 421 * when a MCE happened during an interrupts off region ··· 1185 1172 return -ENOMEM; 1186 1173 for (i = 0; i < banks; i++) { 1187 1174 struct mce_bank *b = &mce_banks[i]; 1175 + 1188 1176 b->ctl = -1ULL; 1189 1177 b->init = 1; 1190 1178 } ··· 1217 1203 banks = b; 1218 1204 if (!mce_banks) { 1219 1205 int err = mce_banks_init(); 1206 + 1220 1207 if (err) 1221 1208 return err; 1222 1209 } ··· 1252 1237 1253 1238 for (i = 0; i < banks; i++) { 1254 1239 struct mce_bank *b = &mce_banks[i]; 1240 + 1255 1241 if (!b->init) 1256 1242 continue; 1257 1243 wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl); ··· 1642 1626 1643 1627 for (i = 0; i < banks; i++) { 1644 1628 struct mce_bank *b = &mce_banks[i]; 1629 + 1645 1630 if (b->init) 1646 1631 wrmsrl(MSR_IA32_MCx_CTL(i), 0); 1647 1632 } ··· 1928 1911 cmci_clear(); 1929 1912 for (i = 0; i < banks; i++) { 1930 1913 struct mce_bank *b = &mce_banks[i]; 1914 + 1931 1915 if (b->init) 1932 1916 wrmsrl(MSR_IA32_MCx_CTL(i), 0); 1933 1917 } ··· 1946 1928 cmci_reenable(); 1947 1929 for (i = 0; i < banks; i++) { 1948 1930 struct mce_bank *b = &mce_banks[i]; 1931 + 1949 1932 if (b->init) 1950 1933 wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl); 1951 1934 }
+42 -25
arch/x86/kernel/cpu/mcheck/therm_throt.c
··· 34 34 /* How long to wait between reporting thermal events */ 35 35 #define CHECK_INTERVAL (300 * HZ) 36 36 37 - static DEFINE_PER_CPU(__u64, next_check) = INITIAL_JIFFIES; 38 - static DEFINE_PER_CPU(unsigned long, thermal_throttle_count); 39 - static DEFINE_PER_CPU(bool, thermal_throttle_active); 37 + /* 38 + * Current thermal throttling state: 39 + */ 40 + struct thermal_state { 41 + bool is_throttled; 40 42 41 - static atomic_t therm_throt_en = ATOMIC_INIT(0); 43 + u64 next_check; 44 + unsigned long throttle_count; 45 + unsigned long last_throttle_count; 46 + }; 47 + 48 + static DEFINE_PER_CPU(struct thermal_state, thermal_state); 49 + 50 + static atomic_t therm_throt_en = ATOMIC_INIT(0); 42 51 43 52 #ifdef CONFIG_SYSFS 44 53 #define define_therm_throt_sysdev_one_ro(_name) \ 45 54 static SYSDEV_ATTR(_name, 0444, therm_throt_sysdev_show_##_name, NULL) 46 55 47 56 #define define_therm_throt_sysdev_show_func(name) \ 48 - static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \ 49 - struct sysdev_attribute *attr, \ 50 - char *buf) \ 57 + \ 58 + static ssize_t therm_throt_sysdev_show_##name( \ 59 + struct sys_device *dev, \ 60 + struct sysdev_attribute *attr, \ 61 + char *buf) \ 51 62 { \ 52 63 unsigned int cpu = dev->id; \ 53 64 ssize_t ret; \ ··· 66 55 preempt_disable(); /* CPU hotplug */ \ 67 56 if (cpu_online(cpu)) \ 68 57 ret = sprintf(buf, "%lu\n", \ 69 - per_cpu(thermal_throttle_##name, cpu)); \ 58 + per_cpu(thermal_state, cpu).name); \ 70 59 else \ 71 60 ret = 0; \ 72 61 preempt_enable(); \ ··· 74 63 return ret; \ 75 64 } 76 65 77 - define_therm_throt_sysdev_show_func(count); 78 - define_therm_throt_sysdev_one_ro(count); 66 + define_therm_throt_sysdev_show_func(throttle_count); 67 + define_therm_throt_sysdev_one_ro(throttle_count); 79 68 80 69 static struct attribute *thermal_throttle_attrs[] = { 81 - &attr_count.attr, 70 + &attr_throttle_count.attr, 82 71 NULL 83 72 }; 84 73 ··· 104 93 * 1 : Event should be logged further, and a message has been 105 94 * printed to the syslog. 106 95 */ 107 - static int therm_throt_process(int curr) 96 + static int therm_throt_process(bool is_throttled) 108 97 { 109 - unsigned int cpu = smp_processor_id(); 110 - __u64 tmp_jiffs = get_jiffies_64(); 111 - bool was_throttled = __get_cpu_var(thermal_throttle_active); 112 - bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr; 98 + struct thermal_state *state; 99 + unsigned int this_cpu; 100 + bool was_throttled; 101 + u64 now; 102 + 103 + this_cpu = smp_processor_id(); 104 + now = get_jiffies_64(); 105 + state = &per_cpu(thermal_state, this_cpu); 106 + 107 + was_throttled = state->is_throttled; 108 + state->is_throttled = is_throttled; 113 109 114 110 if (is_throttled) 115 - __get_cpu_var(thermal_throttle_count)++; 111 + state->throttle_count++; 116 112 117 - if (!(was_throttled ^ is_throttled) && 118 - time_before64(tmp_jiffs, __get_cpu_var(next_check))) 113 + if (time_before64(now, state->next_check) && 114 + state->throttle_count != state->last_throttle_count) 119 115 return 0; 120 116 121 - __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL; 117 + state->next_check = now + CHECK_INTERVAL; 118 + state->last_throttle_count = state->throttle_count; 122 119 123 120 /* if we just entered the thermal event */ 124 121 if (is_throttled) { 125 - printk(KERN_CRIT "CPU%d: Temperature above threshold, " 126 - "cpu clock throttled (total events = %lu)\n", 127 - cpu, __get_cpu_var(thermal_throttle_count)); 122 + printk(KERN_CRIT "CPU%d: Temperature above threshold, cpu clock throttled (total events = %lu)\n", this_cpu, state->throttle_count); 128 123 129 124 add_taint(TAINT_MACHINE_CHECK); 130 125 return 1; 131 126 } 132 127 if (was_throttled) { 133 - printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu); 128 + printk(KERN_INFO "CPU%d: Temperature/speed normal\n", this_cpu); 134 129 return 1; 135 130 } 136 131 ··· 230 213 __u64 msr_val; 231 214 232 215 rdmsrl(MSR_IA32_THERM_STATUS, msr_val); 233 - if (therm_throt_process(msr_val & THERM_STATUS_PROCHOT)) 216 + if (therm_throt_process((msr_val & THERM_STATUS_PROCHOT) != 0)) 234 217 mce_log_therm_throt_event(msr_val); 235 218 } 236 219
+5
arch/x86/kernel/early_printk.c
··· 178 178 179 179 static inline void early_console_register(struct console *con, int keep_early) 180 180 { 181 + if (early_console->index != -1) { 182 + printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n", 183 + con->name); 184 + return; 185 + } 181 186 early_console = con; 182 187 if (keep_early) 183 188 early_console->flags &= ~CON_BOOT;
+1 -1
arch/x86/kernel/head_32.S
··· 79 79 * any particular GDT layout, because we load our own as soon as we 80 80 * can. 81 81 */ 82 - .section .text.head,"ax",@progbits 82 + __HEAD 83 83 ENTRY(startup_32) 84 84 /* test KEEP_SEGMENTS flag to see if the bootloader is asking 85 85 us to not reload segments */
+1 -1
arch/x86/kernel/head_64.S
··· 40 40 L3_START_KERNEL = pud_index(__START_KERNEL_map) 41 41 42 42 .text 43 - .section .text.head 43 + __HEAD 44 44 .code64 45 45 .globl startup_64 46 46 startup_64:
+2 -4
arch/x86/kernel/traps.c
··· 72 72 73 73 /* 74 74 * The IDT has to be page-aligned to simplify the Pentium 75 - * F0 0F bug workaround.. We have a special link segment 76 - * for this. 75 + * F0 0F bug workaround. 77 76 */ 78 - gate_desc idt_table[NR_VECTORS] 79 - __attribute__((__section__(".data.idt"))) = { { { { 0, 0 } } }, }; 77 + gate_desc idt_table[NR_VECTORS] __page_aligned_data = { { { { 0, 0 } } }, }; 80 78 #endif 81 79 82 80 DECLARE_BITMAP(used_vectors, NR_VECTORS);
+1 -1
arch/x86/kernel/tsc_sync.c
··· 114 114 return; 115 115 116 116 if (boot_cpu_has(X86_FEATURE_TSC_RELIABLE)) { 117 - pr_info("Skipping synchronization checks as TSC is reliable.\n"); 117 + printk_once(KERN_INFO "Skipping synchronization checks as TSC is reliable.\n"); 118 118 return; 119 119 } 120 120
+13 -66
arch/x86/kernel/vmlinux.lds.S
··· 65 65 #endif 66 66 67 67 /* Text and read-only data */ 68 - 69 - /* bootstrapping code */ 70 - .text.head : AT(ADDR(.text.head) - LOAD_OFFSET) { 71 - _text = .; 72 - *(.text.head) 73 - } :text = 0x9090 74 - 75 - /* The rest of the text */ 76 68 .text : AT(ADDR(.text) - LOAD_OFFSET) { 69 + _text = .; 70 + /* bootstrapping code */ 71 + HEAD_TEXT 77 72 #ifdef CONFIG_X86_32 78 - /* not really needed, already page aligned */ 79 73 . = ALIGN(PAGE_SIZE); 80 74 *(.text.page_aligned) 81 75 #endif ··· 88 94 89 95 NOTES :text :note 90 96 91 - /* Exception table */ 92 - . = ALIGN(16); 93 - __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) { 94 - __start___ex_table = .; 95 - *(__ex_table) 96 - __stop___ex_table = .; 97 - } :text = 0x9090 97 + EXCEPTION_TABLE(16) :text = 0x9090 98 98 99 99 RO_DATA(PAGE_SIZE) 100 100 ··· 106 118 #endif 107 119 108 120 PAGE_ALIGNED_DATA(PAGE_SIZE) 109 - *(.data.idt) 110 121 111 122 CACHELINE_ALIGNED_DATA(CONFIG_X86_L1_CACHE_BYTES) 112 123 ··· 122 135 #ifdef CONFIG_X86_64 123 136 124 137 #define VSYSCALL_ADDR (-10*1024*1024) 125 - #define VSYSCALL_PHYS_ADDR ((LOADADDR(.data) + SIZEOF(.data) + \ 126 - PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) 127 - #define VSYSCALL_VIRT_ADDR ((ADDR(.data) + SIZEOF(.data) + \ 128 - PAGE_SIZE - 1) & ~(PAGE_SIZE - 1)) 129 138 130 - #define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR) 139 + #define VLOAD_OFFSET (VSYSCALL_ADDR - __vsyscall_0 + LOAD_OFFSET) 131 140 #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET) 132 141 133 - #define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR) 142 + #define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0) 134 143 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET) 135 144 145 + . = ALIGN(4096); 146 + __vsyscall_0 = .; 147 + 136 148 . = VSYSCALL_ADDR; 137 - .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) { 149 + .vsyscall_0 : AT(VLOAD(.vsyscall_0)) { 138 150 *(.vsyscall_0) 139 151 } :user 140 - 141 - __vsyscall_0 = VSYSCALL_VIRT_ADDR; 142 152 143 153 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES); 144 154 .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) { ··· 176 192 *(.vsyscall_3) 177 193 } 178 194 179 - . = VSYSCALL_VIRT_ADDR + PAGE_SIZE; 195 + . = __vsyscall_0 + PAGE_SIZE; 180 196 181 197 #undef VSYSCALL_ADDR 182 - #undef VSYSCALL_PHYS_ADDR 183 - #undef VSYSCALL_VIRT_ADDR 184 198 #undef VLOAD_OFFSET 185 199 #undef VLOAD 186 200 #undef VVIRT_OFFSET ··· 201 219 PERCPU_VADDR(0, :percpu) 202 220 #endif 203 221 204 - .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) { 205 - _sinittext = .; 206 - INIT_TEXT 207 - _einittext = .; 208 - } 222 + INIT_TEXT_SECTION(PAGE_SIZE) 209 223 #ifdef CONFIG_X86_64 210 224 :init 211 225 #endif 212 226 213 - .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) { 214 - INIT_DATA 215 - } 216 - 217 - . = ALIGN(16); 218 - .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) { 219 - __setup_start = .; 220 - *(.init.setup) 221 - __setup_end = .; 222 - } 223 - .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) { 224 - __initcall_start = .; 225 - INITCALLS 226 - __initcall_end = .; 227 - } 228 - 229 - .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) { 230 - __con_initcall_start = .; 231 - *(.con_initcall.init) 232 - __con_initcall_end = .; 233 - } 227 + INIT_DATA_SECTION(16) 234 228 235 229 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) { 236 230 __x86_cpu_dev_start = .; 237 231 *(.x86_cpu_dev.init) 238 232 __x86_cpu_dev_end = .; 239 233 } 240 - 241 - SECURITY_INIT 242 234 243 235 . = ALIGN(8); 244 236 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) { ··· 243 287 .exit.data : AT(ADDR(.exit.data) - LOAD_OFFSET) { 244 288 EXIT_DATA 245 289 } 246 - 247 - #ifdef CONFIG_BLK_DEV_INITRD 248 - . = ALIGN(PAGE_SIZE); 249 - .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) { 250 - __initramfs_start = .; 251 - *(.init.ramfs) 252 - __initramfs_end = .; 253 - } 254 - #endif 255 290 256 291 #if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP) 257 292 PERCPU(PAGE_SIZE)
+2 -1
arch/x86/mm/Makefile
··· 1 1 obj-y := init.o init_$(BITS).o fault.o ioremap.o extable.o pageattr.o mmap.o \ 2 - pat.o pgtable.o physaddr.o gup.o 2 + pat.o pgtable.o physaddr.o gup.o setup_nx.o 3 3 4 4 # Make sure __phys_addr has no stackprotector 5 5 nostackp := $(call cc-option, -fno-stack-protector) 6 6 CFLAGS_physaddr.o := $(nostackp) 7 + CFLAGS_setup_nx.o := $(nostackp) 7 8 8 9 obj-$(CONFIG_SMP) += tlb.o 9 10
-63
arch/x86/mm/init.c
··· 28 28 #endif 29 29 ; 30 30 31 - int nx_enabled; 32 - 33 - #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 34 - static int disable_nx __cpuinitdata; 35 - 36 - /* 37 - * noexec = on|off 38 - * 39 - * Control non-executable mappings for processes. 40 - * 41 - * on Enable 42 - * off Disable 43 - */ 44 - static int __init noexec_setup(char *str) 45 - { 46 - if (!str) 47 - return -EINVAL; 48 - if (!strncmp(str, "on", 2)) { 49 - __supported_pte_mask |= _PAGE_NX; 50 - disable_nx = 0; 51 - } else if (!strncmp(str, "off", 3)) { 52 - disable_nx = 1; 53 - __supported_pte_mask &= ~_PAGE_NX; 54 - } 55 - return 0; 56 - } 57 - early_param("noexec", noexec_setup); 58 - #endif 59 - 60 - #ifdef CONFIG_X86_PAE 61 - static void __init set_nx(void) 62 - { 63 - unsigned int v[4], l, h; 64 - 65 - if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) { 66 - cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]); 67 - 68 - if ((v[3] & (1 << 20)) && !disable_nx) { 69 - rdmsr(MSR_EFER, l, h); 70 - l |= EFER_NX; 71 - wrmsr(MSR_EFER, l, h); 72 - nx_enabled = 1; 73 - __supported_pte_mask |= _PAGE_NX; 74 - } 75 - } 76 - } 77 - #else 78 - static inline void set_nx(void) 79 - { 80 - } 81 - #endif 82 - 83 - #ifdef CONFIG_X86_64 84 - void __cpuinit check_efer(void) 85 - { 86 - unsigned long efer; 87 - 88 - rdmsrl(MSR_EFER, efer); 89 - if (!(efer & EFER_NX) || disable_nx) 90 - __supported_pte_mask &= ~_PAGE_NX; 91 - } 92 - #endif 93 - 94 31 static void __init find_early_table_space(unsigned long end, int use_pse, 95 32 int use_gbpages) 96 33 {
+5 -2
arch/x86/mm/pat.c
··· 81 81 void pat_init(void) 82 82 { 83 83 u64 pat; 84 + bool boot_cpu = !boot_pat_state; 84 85 85 86 if (!pat_enabled) 86 87 return; ··· 123 122 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state); 124 123 125 124 wrmsrl(MSR_IA32_CR_PAT, pat); 126 - printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n", 127 - smp_processor_id(), boot_pat_state, pat); 125 + 126 + if (boot_cpu) 127 + printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n", 128 + smp_processor_id(), boot_pat_state, pat); 128 129 } 129 130 130 131 #undef PAT
+69
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 + 7 + int nx_enabled; 8 + 9 + #if defined(CONFIG_X86_64) || defined(CONFIG_X86_PAE) 10 + static int disable_nx __cpuinitdata; 11 + 12 + /* 13 + * noexec = on|off 14 + * 15 + * Control non-executable mappings for processes. 16 + * 17 + * on Enable 18 + * off Disable 19 + */ 20 + static int __init noexec_setup(char *str) 21 + { 22 + if (!str) 23 + return -EINVAL; 24 + if (!strncmp(str, "on", 2)) { 25 + __supported_pte_mask |= _PAGE_NX; 26 + disable_nx = 0; 27 + } else if (!strncmp(str, "off", 3)) { 28 + disable_nx = 1; 29 + __supported_pte_mask &= ~_PAGE_NX; 30 + } 31 + return 0; 32 + } 33 + early_param("noexec", noexec_setup); 34 + #endif 35 + 36 + #ifdef CONFIG_X86_PAE 37 + void __init set_nx(void) 38 + { 39 + unsigned int v[4], l, h; 40 + 41 + if (cpu_has_pae && (cpuid_eax(0x80000000) > 0x80000001)) { 42 + cpuid(0x80000001, &v[0], &v[1], &v[2], &v[3]); 43 + 44 + if ((v[3] & (1 << 20)) && !disable_nx) { 45 + rdmsr(MSR_EFER, l, h); 46 + l |= EFER_NX; 47 + wrmsr(MSR_EFER, l, h); 48 + nx_enabled = 1; 49 + __supported_pte_mask |= _PAGE_NX; 50 + } 51 + } 52 + } 53 + #else 54 + void set_nx(void) 55 + { 56 + } 57 + #endif 58 + 59 + #ifdef CONFIG_X86_64 60 + void __cpuinit check_efer(void) 61 + { 62 + unsigned long efer; 63 + 64 + rdmsrl(MSR_EFER, efer); 65 + if (!(efer & EFER_NX) || disable_nx) 66 + __supported_pte_mask &= ~_PAGE_NX; 67 + } 68 + #endif 69 +
+5 -5
arch/x86/xen/enlighten.c
··· 1082 1082 1083 1083 __supported_pte_mask |= _PAGE_IOMAP; 1084 1084 1085 + #ifdef CONFIG_X86_64 1086 + /* Work out if we support NX */ 1087 + check_efer(); 1088 + #endif 1089 + 1085 1090 xen_setup_features(); 1086 1091 1087 1092 /* Get mfn list */ ··· 1127 1122 xen_smp_init(); 1128 1123 1129 1124 pgd = (pgd_t *)xen_start_info->pt_base; 1130 - 1131 - #ifdef CONFIG_X86_64 1132 - /* Work out if we support NX */ 1133 - check_efer(); 1134 - #endif 1135 1125 1136 1126 /* Don't do the full vcpu_info placement stuff until we have a 1137 1127 possible map and a non-dummy shared_info. */