History

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

Linus Torvalds committed 17 years ago

Commit 5bb241b2 parents 76e0134 704daf519 files · +180 −188Browse files

Unified · Split

19 files
  1. arch/x86/boot/compressed/head_32.S +2 −1
  2. arch/x86/boot/compressed/head_64.S +2 −1
  3. arch/x86/boot/compressed/vmlinux.lds.S +4 −2
  4. arch/x86/include/asm/pgtable_types.h +1 −0
  5. arch/x86/include/asm/topology.h +0 −10
  6. arch/x86/kernel/cpu/mcheck/mce-inject.c +4 −3
  7. arch/x86/kernel/cpu/mcheck/mce.c +21 −2
  8. arch/x86/kernel/cpu/mcheck/therm_throt.c +42 −25
  9. arch/x86/kernel/early_printk.c +5 −0
  10. arch/x86/kernel/head_32.S +1 −1
  11. arch/x86/kernel/head_64.S +1 −1
  12. arch/x86/kernel/traps.c +2 −4
  13. arch/x86/kernel/tsc_sync.c +1 −1
  14. arch/x86/kernel/vmlinux.lds.S +13 −66
  15. arch/x86/mm/Makefile +2 −1
  16. arch/x86/mm/init.c +0 −63
  17. arch/x86/mm/pat.c +5 −2
  18. arch/x86/mm/setup_nx.c +69 −0
  19. arch/x86/xen/enlighten.c +5 −5
arch/x86/boot/compressed/head_32.S+2−1
@@ -23,13 +23,14 @@ · 22 unmodified lines
2323 */
2424 .text
2525
26+#include <linux/init.h>
2627 #include <linux/linkage.h>
2728 #include <asm/segment.h>
2829 #include <asm/page_types.h>
2930 #include <asm/boot.h>
3031 #include <asm/asm-offsets.h>
3132
32− .section ".text.head","ax",@progbits
33+ __HEAD
3334 ENTRY(startup_32)
3435 cld
3536 /*
arch/x86/boot/compressed/head_64.S+2−1
@@ -24,6 +24,7 @@ · 23 unmodified lines
2424 .code32
2525 .text
2626
27+#include <linux/init.h>
2728 #include <linux/linkage.h>
2829 #include <asm/segment.h>
2930 #include <asm/pgtable_types.h>
@@ -33,7 +34,7 @@ · 3 unmodified lines
3334 #include <asm/processor-flags.h>
3435 #include <asm/asm-offsets.h>
3536
36− .section ".text.head"
37+ __HEAD
3738 .code32
3839 ENTRY(startup_32)
3940 cld
arch/x86/boot/compressed/vmlinux.lds.S+4−2
@@ -1,3 +1,5 @@
1+#include <asm-generic/vmlinux.lds.h>
2+
13 OUTPUT_FORMAT(CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT, CONFIG_OUTPUT_FORMAT)
24
35 #undef i386
@@ -18,9 +20,9 @@ SECTIONS · 14 unmodified lines
1820 * address 0.
1921 */
2022 . = 0;
21− .text.head : {
23+ .head.text : {
2224 _head = . ;
23− *(.text.head)
25+ HEAD_TEXT
2426 _ehead = . ;
2527 }
2628 .rodata.compressed : {
arch/x86/include/asm/pgtable_types.h+1−0
@@ -277,6 +277,7 @@ static inline pteval_t pte_flags(pte_t pte) · 276 unmodified lines
277277 typedef struct page *pgtable_t;
278278
279279 extern pteval_t __supported_pte_mask;
280+extern void set_nx(void);
280281 extern int nx_enabled;
281282
282283 #define pgprot_writecombine pgprot_writecombine
arch/x86/include/asm/topology.h+0−10
@@ -165,21 +165,11 @@ static inline int numa_node_id(void) · 164 unmodified lines
165165 return 0;
166166 }
167167
168−static inline int cpu_to_node(int cpu)
169−{
170− return 0;
171−}
172−
173168 static inline int early_cpu_to_node(int cpu)
174169 {
175170 return 0;
176171 }
177172
178−static inline const struct cpumask *cpumask_of_node(int node)
179−{
180− return cpu_online_mask;
181−}
182−
183173 static inline void setup_node_to_cpumask_map(void) { }
184174
185175 #endif
arch/x86/kernel/cpu/mcheck/mce-inject.c+4−3
@@ -98,8 +98,9 @@ static struct notifier_block mce_raise_nb = { · 97 unmodified lines
9898 };
9999
100100 /* Inject mce on current CPU */
101−static int raise_local(struct mce *m)
101+static int raise_local(void)
102102 {
103+ struct mce *m = &__get_cpu_var(injectm);
103104 int context = MCJ_CTX(m->inject_flags);
104105 int ret = 0;
105106 int cpu = m->extcpu;
@@ -167,12 +168,12 @@ static void raise_mce(struct mce *m) · 61 unmodified lines
167168 }
168169 cpu_relax();
169170 }
170− raise_local(m);
171+ raise_local();
171172 put_cpu();
172173 put_online_cpus();
173174 } else
174175 #endif
175− raise_local(m);
176+ raise_local();
176177 }
177178
178179 /* Error injection interface */
arch/x86/kernel/cpu/mcheck/mce.c+21−2
@@ -305,13 +305,25 @@ static int msr_to_offset(u32 msr) · 304 unmodified lines
305305 static u64 mce_rdmsrl(u32 msr)
306306 {
307307 u64 v;
308+
308309 if (__get_cpu_var(injectm).finished) {
309310 int offset = msr_to_offset(msr);
311+
310312 if (offset < 0)
311313 return 0;
312314 return *(u64 *)((char *)&__get_cpu_var(injectm) + offset);
313315 }
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+
315327 return v;
316328 }
317329
@@ -319,6 +331,7 @@ static void mce_wrmsrl(u32 msr, u64 v) · 1 unmodified line
319331 {
320332 if (__get_cpu_var(injectm).finished) {
321333 int offset = msr_to_offset(msr);
334+
322335 if (offset >= 0)
323336 *(u64 *)((char *)&__get_cpu_var(injectm) + offset) = v;
324337 return;
@@ -415,7 +428,7 @@ static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) · 90 unmodified lines
415428 m->ip = mce_rdmsrl(rip_msr);
416429 }
417430
418−#ifdef CONFIG_X86_LOCAL_APIC
431+#ifdef CONFIG_X86_LOCAL_APIC
419432 /*
420433 * Called after interrupts have been reenabled again
421434 * when a MCE happened during an interrupts off region
@@ -1172,6 +1185,7 @@ static int mce_banks_init(void) · 750 unmodified lines
11721185 return -ENOMEM;
11731186 for (i = 0; i < banks; i++) {
11741187 struct mce_bank *b = &mce_banks[i];
1188+
11751189 b->ctl = -1ULL;
11761190 b->init = 1;
11771191 }
@@ -1203,6 +1217,7 @@ static int __cpuinit mce_cap_init(void) · 25 unmodified lines
12031217 banks = b;
12041218 if (!mce_banks) {
12051219 int err = mce_banks_init();
1220+
12061221 if (err)
12071222 return err;
12081223 }
@@ -1237,6 +1252,7 @@ static void mce_init(void) · 28 unmodified lines
12371252
12381253 for (i = 0; i < banks; i++) {
12391254 struct mce_bank *b = &mce_banks[i];
1255+
12401256 if (!b->init)
12411257 continue;
12421258 wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl);
@@ -1626,6 +1642,7 @@ static int mce_disable(void) · 383 unmodified lines
16261642
16271643 for (i = 0; i < banks; i++) {
16281644 struct mce_bank *b = &mce_banks[i];
1645+
16291646 if (b->init)
16301647 wrmsrl(MSR_IA32_MCx_CTL(i), 0);
16311648 }
@@ -1911,6 +1928,7 @@ static void mce_disable_cpu(void *h) · 279 unmodified lines
19111928 cmci_clear();
19121929 for (i = 0; i < banks; i++) {
19131930 struct mce_bank *b = &mce_banks[i];
1931+
19141932 if (b->init)
19151933 wrmsrl(MSR_IA32_MCx_CTL(i), 0);
19161934 }
@@ -1928,6 +1946,7 @@ static void mce_reenable_cpu(void *h) · 11 unmodified lines
19281946 cmci_reenable();
19291947 for (i = 0; i < banks; i++) {
19301948 struct mce_bank *b = &mce_banks[i];
1949+
19311950 if (b->init)
19321951 wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl);
19331952 }
arch/x86/kernel/cpu/mcheck/therm_throt.c+42−25
@@ -34,20 +34,31 @@ · 33 unmodified lines
3434 /* How long to wait between reporting thermal events */
3535 #define CHECK_INTERVAL (300 * HZ)
3636
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;
42+
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);
4049
41−static atomic_t therm_throt_en = ATOMIC_INIT(0);
50+static atomic_t therm_throt_en = ATOMIC_INIT(0);
4251
4352 #ifdef CONFIG_SYSFS
4453 #define define_therm_throt_sysdev_one_ro(_name) \
4554 static SYSDEV_ATTR(_name, 0444, therm_throt_sysdev_show_##_name, NULL)
4655
4756 #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) \
5162 { \
5263 unsigned int cpu = dev->id; \
5364 ssize_t ret; \
@@ -55,7 +66,7 @@ static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \ · 1 unmodified line
5566 preempt_disable(); /* CPU hotplug */ \
5667 if (cpu_online(cpu)) \
5768 ret = sprintf(buf, "%lu\n", \
58− per_cpu(thermal_throttle_##name, cpu)); \
69+ per_cpu(thermal_state, cpu).name); \
5970 else \
6071 ret = 0; \
6172 preempt_enable(); \
@@ -63,11 +74,11 @@ static ssize_t therm_throt_sysdev_show_##name(struct sys_device *dev, \ · 1 unmodified line
6374 return ret; \
6475 }
6576
66−define_therm_throt_sysdev_show_func(count);
67−define_therm_throt_sysdev_one_ro(count);
77+define_therm_throt_sysdev_show_func(throttle_count);
78+define_therm_throt_sysdev_one_ro(throttle_count);
6879
6980 static struct attribute *thermal_throttle_attrs[] = {
70− &attr_count.attr,
81+ &attr_throttle_count.attr,
7182 NULL
7283 };
7384
@@ -93,33 +104,39 @@ static struct attribute_group thermal_throttle_attr_group = { · 19 unmodified lines
93104 * 1 : Event should be logged further, and a message has been
94105 * printed to the syslog.
95106 */
96−static int therm_throt_process(int curr)
107+static int therm_throt_process(bool is_throttled)
97108 {
98− unsigned int cpu = smp_processor_id();
99− __u64 tmp_jiffs = get_jiffies_64();
100− bool was_throttled = __get_cpu_var(thermal_throttle_active);
101− bool is_throttled = __get_cpu_var(thermal_throttle_active) = curr;
109+ struct thermal_state *state;
110+ unsigned int this_cpu;
111+ bool was_throttled;
112+ u64 now;
113+
114+ this_cpu = smp_processor_id();
115+ now = get_jiffies_64();
116+ state = &per_cpu(thermal_state, this_cpu);
117+
118+ was_throttled = state->is_throttled;
119+ state->is_throttled = is_throttled;
102120
103121 if (is_throttled)
104− __get_cpu_var(thermal_throttle_count)++;
122+ state->throttle_count++;
105123
106− if (!(was_throttled ^ is_throttled) &&
107− time_before64(tmp_jiffs, __get_cpu_var(next_check)))
124+ if (time_before64(now, state->next_check) &&
125+ state->throttle_count != state->last_throttle_count)
108126 return 0;
109127
110− __get_cpu_var(next_check) = tmp_jiffs + CHECK_INTERVAL;
128+ state->next_check = now + CHECK_INTERVAL;
129+ state->last_throttle_count = state->throttle_count;
111130
112131 /* if we just entered the thermal event */
113132 if (is_throttled) {
114− printk(KERN_CRIT "CPU%d: Temperature above threshold, "
115− "cpu clock throttled (total events = %lu)\n",
116− cpu, __get_cpu_var(thermal_throttle_count));
133+ printk(KERN_CRIT "CPU%d: Temperature above threshold, cpu clock throttled (total events = %lu)\n", this_cpu, state->throttle_count);
117134
118135 add_taint(TAINT_MACHINE_CHECK);
119136 return 1;
120137 }
121138 if (was_throttled) {
122− printk(KERN_INFO "CPU%d: Temperature/speed normal\n", cpu);
139+ printk(KERN_INFO "CPU%d: Temperature/speed normal\n", this_cpu);
123140 return 1;
124141 }
125142
@@ -213,7 +230,7 @@ static void intel_thermal_interrupt(void) · 87 unmodified lines
213230 __u64 msr_val;
214231
215232 rdmsrl(MSR_IA32_THERM_STATUS, msr_val);
216− if (therm_throt_process(msr_val & THERM_STATUS_PROCHOT))
233+ if (therm_throt_process((msr_val & THERM_STATUS_PROCHOT) != 0))
217234 mce_log_therm_throt_event(msr_val);
218235 }
219236
arch/x86/kernel/early_printk.c+5−0
@@ -178,6 +178,11 @@ asmlinkage void early_printk(const char *fmt, ...) · 177 unmodified lines
178178
179179 static inline void early_console_register(struct console *con, int keep_early)
180180 {
181+ if (early_console->index != -1) {
182+ printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n",
183+ con->name);
184+ return;
185+ }
181186 early_console = con;
182187 if (keep_early)
183188 early_console->flags &= ~CON_BOOT;
arch/x86/kernel/head_32.S+1−1
@@ -79,7 +79,7 @@ RESERVE_BRK(pagetables, INIT_MAP_SIZE) · 78 unmodified lines
7979 * any particular GDT layout, because we load our own as soon as we
8080 * can.
8181 */
82−.section .text.head,"ax",@progbits
82+__HEAD
8383 ENTRY(startup_32)
8484 /* test KEEP_SEGMENTS flag to see if the bootloader is asking
8585 us to not reload segments */
arch/x86/kernel/head_64.S+1−1
@@ -40,7 +40,7 @@ L4_START_KERNEL = pgd_index(__START_KERNEL_map) · 39 unmodified lines
4040 L3_START_KERNEL = pud_index(__START_KERNEL_map)
4141
4242 .text
43− .section .text.head
43+ __HEAD
4444 .code64
4545 .globl startup_64
4646 startup_64:
arch/x86/kernel/traps.c+2−4
@@ -72,11 +72,9 @@ char ignore_fpu_irq; · 71 unmodified lines
7272
7373 /*
7474 * 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.
7776 */
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 } } }, };
8078 #endif
8179
8280 DECLARE_BITMAP(used_vectors, NR_VECTORS);
arch/x86/kernel/tsc_sync.c+1−1
@@ -114,7 +114,7 @@ void __cpuinit check_tsc_sync_source(int cpu) · 113 unmodified lines
114114 return;
115115
116116 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");
118118 return;
119119 }
120120
arch/x86/kernel/vmlinux.lds.S+13−66
@@ -65,17 +65,11 @@ SECTIONS · 64 unmodified lines
6565 #endif
6666
6767 /* 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 */
7668 .text : AT(ADDR(.text) - LOAD_OFFSET) {
69+ _text = .;
70+ /* bootstrapping code */
71+ HEAD_TEXT
7772 #ifdef CONFIG_X86_32
78− /* not really needed, already page aligned */
7973 . = ALIGN(PAGE_SIZE);
8074 *(.text.page_aligned)
8175 #endif
@@ -94,13 +88,7 @@ SECTIONS · 12 unmodified lines
9488
9589 NOTES :text :note
9690
97− /* Exception table */
98− . = ALIGN(16);
99− __ex_table : AT(ADDR(__ex_table) - LOAD_OFFSET) {
100− __start___ex_table = .;
101− *(__ex_table)
102− __stop___ex_table = .;
103− } :text = 0x9090
91+ EXCEPTION_TABLE(16) :text = 0x9090
10492
10593 RO_DATA(PAGE_SIZE)
10694
@@ -118,7 +106,6 @@ SECTIONS · 11 unmodified lines
118106 #endif
119107
120108 PAGE_ALIGNED_DATA(PAGE_SIZE)
121− *(.data.idt)
122109
123110 CACHELINE_ALIGNED_DATA(CONFIG_X86_L1_CACHE_BYTES)
124111
@@ -135,24 +122,21 @@ SECTIONS · 10 unmodified lines
135122 #ifdef CONFIG_X86_64
136123
137124 #define VSYSCALL_ADDR (-10*1024*1024)
138−#define VSYSCALL_PHYS_ADDR ((LOADADDR(.data) + SIZEOF(.data) + \
139− PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
140−#define VSYSCALL_VIRT_ADDR ((ADDR(.data) + SIZEOF(.data) + \
141− PAGE_SIZE - 1) & ~(PAGE_SIZE - 1))
142125
143−#define VLOAD_OFFSET (VSYSCALL_ADDR - VSYSCALL_PHYS_ADDR)
126+#define VLOAD_OFFSET (VSYSCALL_ADDR - __vsyscall_0 + LOAD_OFFSET)
144127 #define VLOAD(x) (ADDR(x) - VLOAD_OFFSET)
145128
146−#define VVIRT_OFFSET (VSYSCALL_ADDR - VSYSCALL_VIRT_ADDR)
129+#define VVIRT_OFFSET (VSYSCALL_ADDR - __vsyscall_0)
147130 #define VVIRT(x) (ADDR(x) - VVIRT_OFFSET)
148131
132+ . = ALIGN(4096);
133+ __vsyscall_0 = .;
134+
149135 . = VSYSCALL_ADDR;
150− .vsyscall_0 : AT(VSYSCALL_PHYS_ADDR) {
136+ .vsyscall_0 : AT(VLOAD(.vsyscall_0)) {
151137 *(.vsyscall_0)
152138 } :user
153139
154− __vsyscall_0 = VSYSCALL_VIRT_ADDR;
155−
156140 . = ALIGN(CONFIG_X86_L1_CACHE_BYTES);
157141 .vsyscall_fn : AT(VLOAD(.vsyscall_fn)) {
158142 *(.vsyscall_fn)
@@ -192,11 +176,9 @@ SECTIONS · 33 unmodified lines
192176 *(.vsyscall_3)
193177 }
194178
195− . = VSYSCALL_VIRT_ADDR + PAGE_SIZE;
179+ . = __vsyscall_0 + PAGE_SIZE;
196180
197181 #undef VSYSCALL_ADDR
198−#undef VSYSCALL_PHYS_ADDR
199−#undef VSYSCALL_VIRT_ADDR
200182 #undef VLOAD_OFFSET
201183 #undef VLOAD
202184 #undef VVIRT_OFFSET
@@ -219,36 +201,12 @@ SECTIONS · 16 unmodified lines
219201 PERCPU_VADDR(0, :percpu)
220202 #endif
221203
222− .init.text : AT(ADDR(.init.text) - LOAD_OFFSET) {
223− _sinittext = .;
224− INIT_TEXT
225− _einittext = .;
226− }
204+ INIT_TEXT_SECTION(PAGE_SIZE)
227205 #ifdef CONFIG_X86_64
228206 :init
229207 #endif
230208
231− .init.data : AT(ADDR(.init.data) - LOAD_OFFSET) {
232− INIT_DATA
233− }
234−
235− . = ALIGN(16);
236− .init.setup : AT(ADDR(.init.setup) - LOAD_OFFSET) {
237− __setup_start = .;
238− *(.init.setup)
239− __setup_end = .;
240− }
241− .initcall.init : AT(ADDR(.initcall.init) - LOAD_OFFSET) {
242− __initcall_start = .;
243− INITCALLS
244− __initcall_end = .;
245− }
246−
247− .con_initcall.init : AT(ADDR(.con_initcall.init) - LOAD_OFFSET) {
248− __con_initcall_start = .;
249− *(.con_initcall.init)
250− __con_initcall_end = .;
251− }
209+ INIT_DATA_SECTION(16)
252210
253211 .x86_cpu_dev.init : AT(ADDR(.x86_cpu_dev.init) - LOAD_OFFSET) {
254212 __x86_cpu_dev_start = .;
@@ -256,8 +214,6 @@ SECTIONS · 1 unmodified line
256214 __x86_cpu_dev_end = .;
257215 }
258216
259− SECURITY_INIT
260−
261217 . = ALIGN(8);
262218 .parainstructions : AT(ADDR(.parainstructions) - LOAD_OFFSET) {
263219 __parainstructions = .;
@@ -288,15 +244,6 @@ SECTIONS · 24 unmodified lines
288244 EXIT_DATA
289245 }
290246
291−#ifdef CONFIG_BLK_DEV_INITRD
292− . = ALIGN(PAGE_SIZE);
293− .init.ramfs : AT(ADDR(.init.ramfs) - LOAD_OFFSET) {
294− __initramfs_start = .;
295− *(.init.ramfs)
296− __initramfs_end = .;
297− }
298−#endif
299−
300247 #if !defined(CONFIG_X86_64) || !defined(CONFIG_SMP)
301248 PERCPU(PAGE_SIZE)
302249 #endif
arch/x86/mm/Makefile+2−1
@@ -1,9 +1,10 @@
11 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
33
44 # Make sure __phys_addr has no stackprotector
55 nostackp := $(call cc-option, -fno-stack-protector)
66 CFLAGS_physaddr.o := $(nostackp)
7+CFLAGS_setup_nx.o := $(nostackp)
78
89 obj-$(CONFIG_SMP) += tlb.o
910
arch/x86/mm/init.c+0−63
@@ -28,69 +28,6 @@ int direct_gbpages · 27 unmodified lines
2828 #endif
2929 ;
3030
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−
9431 static void __init find_early_table_space(unsigned long end, int use_pse,
9532 int use_gbpages)
9633 {
arch/x86/mm/pat.c+5−2
@@ -81,6 +81,7 @@ enum { · 80 unmodified lines
8181 void pat_init(void)
8282 {
8383 u64 pat;
84+ bool boot_cpu = !boot_pat_state;
8485
8586 if (!pat_enabled)
8687 return;
@@ -122,8 +123,10 @@ void pat_init(void) · 35 unmodified lines
122123 rdmsrl(MSR_IA32_CR_PAT, boot_pat_state);
123124
124125 wrmsrl(MSR_IA32_CR_PAT, pat);
125− printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n",
126− smp_processor_id(), boot_pat_state, pat);
126+
127+ if (boot_cpu)
128+ printk(KERN_INFO "x86 PAT enabled: cpu %d, old 0x%Lx, new 0x%Lx\n",
129+ smp_processor_id(), boot_pat_state, pat);
127130 }
128131
129132 #undef PAT
arch/x86/mm/setup_nx.c+69−0
@@ -0,0 +1,69 @@
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+
arch/x86/xen/enlighten.c+5−5
@@ -1082,6 +1082,11 @@ asmlinkage void __init xen_start_kernel(void) · 1081 unmodified lines
10821082
10831083 __supported_pte_mask |= _PAGE_IOMAP;
10841084
1085+#ifdef CONFIG_X86_64
1086+ /* Work out if we support NX */
1087+ check_efer();
1088+#endif
1089+
10851090 xen_setup_features();
10861091
10871092 /* Get mfn list */
@@ -1123,11 +1128,6 @@ asmlinkage void __init xen_start_kernel(void) · 35 unmodified lines
11231128
11241129 pgd = (pgd_t *)xen_start_info->pt_base;
11251130
1126−#ifdef CONFIG_X86_64
1127− /* Work out if we support NX */
1128− check_efer();
1129−#endif
1130−
11311131 /* Don't do the full vcpu_info placement stuff until we have a
11321132 possible map and a non-dummy shared_info. */
11331133 per_cpu(xen_vcpu, 0) = &HYPERVISOR_shared_info->vcpu_info[0];

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t