aboutsummaryrefslogtreecommitdiffstats
path: root/arch
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2015-10-03 10:53:05 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-10-03 10:53:05 -0400
commit2cf30826bbc6c940568be07e8fab0aee02165cf8 (patch)
tree69a3606e8e965407aee9022ed7ae3f3441f33595 /arch
parent37cc7ab1d2c317cc989b8aa0224cfc5f0478ccbd (diff)
parentf4b4aae1828855db761bf998ce37d3062b1d6446 (diff)
Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull x86 fixes from Ingo Molnar: "Fixes all around the map: W+X kernel mapping fix, WCHAN fixes, two build failure fixes for corner case configs, x32 header fix and a speling fix" * 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: x86/headers/uapi: Fix __BITS_PER_LONG value for x32 builds x86/mm: Set NX on gap between __ex_table and rodata x86/kexec: Fix kexec crash in syscall kexec_file_load() x86/process: Unify 32bit and 64bit implementations of get_wchan() x86/process: Add proper bound checks in 64bit get_wchan() x86, efi, kasan: Fix build failure on !KASAN && KMEMCHECK=y kernels x86/hyperv: Fix the build in the !CONFIG_KEXEC_CORE case x86/cpufeatures: Correct spelling of the HWP_NOTIFY flag
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/include/asm/cpufeature.h2
-rw-r--r--arch/x86/include/uapi/asm/bitsperlong.h2
-rw-r--r--arch/x86/kernel/cpu/mshyperv.c12
-rw-r--r--arch/x86/kernel/cpu/scattered.c2
-rw-r--r--arch/x86/kernel/crash.c7
-rw-r--r--arch/x86/kernel/process.c55
-rw-r--r--arch/x86/kernel/process_32.c28
-rw-r--r--arch/x86/kernel/process_64.c24
-rw-r--r--arch/x86/mm/init_64.c2
9 files changed, 69 insertions, 65 deletions
diff --git a/arch/x86/include/asm/cpufeature.h b/arch/x86/include/asm/cpufeature.h
index e6cf2ad350d1..9727b3b48bd1 100644
--- a/arch/x86/include/asm/cpufeature.h
+++ b/arch/x86/include/asm/cpufeature.h
@@ -193,7 +193,7 @@
193#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */ 193#define X86_FEATURE_HW_PSTATE ( 7*32+ 8) /* AMD HW-PState */
194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */ 194#define X86_FEATURE_PROC_FEEDBACK ( 7*32+ 9) /* AMD ProcFeedbackInterface */
195#define X86_FEATURE_HWP ( 7*32+ 10) /* "hwp" Intel HWP */ 195#define X86_FEATURE_HWP ( 7*32+ 10) /* "hwp" Intel HWP */
196#define X86_FEATURE_HWP_NOITFY ( 7*32+ 11) /* Intel HWP_NOTIFY */ 196#define X86_FEATURE_HWP_NOTIFY ( 7*32+ 11) /* Intel HWP_NOTIFY */
197#define X86_FEATURE_HWP_ACT_WINDOW ( 7*32+ 12) /* Intel HWP_ACT_WINDOW */ 197#define X86_FEATURE_HWP_ACT_WINDOW ( 7*32+ 12) /* Intel HWP_ACT_WINDOW */
198#define X86_FEATURE_HWP_EPP ( 7*32+13) /* Intel HWP_EPP */ 198#define X86_FEATURE_HWP_EPP ( 7*32+13) /* Intel HWP_EPP */
199#define X86_FEATURE_HWP_PKG_REQ ( 7*32+14) /* Intel HWP_PKG_REQ */ 199#define X86_FEATURE_HWP_PKG_REQ ( 7*32+14) /* Intel HWP_PKG_REQ */
diff --git a/arch/x86/include/uapi/asm/bitsperlong.h b/arch/x86/include/uapi/asm/bitsperlong.h
index b0ae1c4dc791..217909b4d6f5 100644
--- a/arch/x86/include/uapi/asm/bitsperlong.h
+++ b/arch/x86/include/uapi/asm/bitsperlong.h
@@ -1,7 +1,7 @@
1#ifndef __ASM_X86_BITSPERLONG_H 1#ifndef __ASM_X86_BITSPERLONG_H
2#define __ASM_X86_BITSPERLONG_H 2#define __ASM_X86_BITSPERLONG_H
3 3
4#ifdef __x86_64__ 4#if defined(__x86_64__) && !defined(__ILP32__)
5# define __BITS_PER_LONG 64 5# define __BITS_PER_LONG 64
6#else 6#else
7# define __BITS_PER_LONG 32 7# define __BITS_PER_LONG 32
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c
index 381c8b9b3a33..20e242ea1bc4 100644
--- a/arch/x86/kernel/cpu/mshyperv.c
+++ b/arch/x86/kernel/cpu/mshyperv.c
@@ -34,11 +34,10 @@
34struct ms_hyperv_info ms_hyperv; 34struct ms_hyperv_info ms_hyperv;
35EXPORT_SYMBOL_GPL(ms_hyperv); 35EXPORT_SYMBOL_GPL(ms_hyperv);
36 36
37static void (*hv_kexec_handler)(void);
38static void (*hv_crash_handler)(struct pt_regs *regs);
39
40#if IS_ENABLED(CONFIG_HYPERV) 37#if IS_ENABLED(CONFIG_HYPERV)
41static void (*vmbus_handler)(void); 38static void (*vmbus_handler)(void);
39static void (*hv_kexec_handler)(void);
40static void (*hv_crash_handler)(struct pt_regs *regs);
42 41
43void hyperv_vector_handler(struct pt_regs *regs) 42void hyperv_vector_handler(struct pt_regs *regs)
44{ 43{
@@ -96,8 +95,8 @@ void hv_remove_crash_handler(void)
96 hv_crash_handler = NULL; 95 hv_crash_handler = NULL;
97} 96}
98EXPORT_SYMBOL_GPL(hv_remove_crash_handler); 97EXPORT_SYMBOL_GPL(hv_remove_crash_handler);
99#endif
100 98
99#ifdef CONFIG_KEXEC_CORE
101static void hv_machine_shutdown(void) 100static void hv_machine_shutdown(void)
102{ 101{
103 if (kexec_in_progress && hv_kexec_handler) 102 if (kexec_in_progress && hv_kexec_handler)
@@ -111,7 +110,8 @@ static void hv_machine_crash_shutdown(struct pt_regs *regs)
111 hv_crash_handler(regs); 110 hv_crash_handler(regs);
112 native_machine_crash_shutdown(regs); 111 native_machine_crash_shutdown(regs);
113} 112}
114 113#endif /* CONFIG_KEXEC_CORE */
114#endif /* CONFIG_HYPERV */
115 115
116static uint32_t __init ms_hyperv_platform(void) 116static uint32_t __init ms_hyperv_platform(void)
117{ 117{
@@ -186,8 +186,10 @@ static void __init ms_hyperv_init_platform(void)
186 no_timer_check = 1; 186 no_timer_check = 1;
187#endif 187#endif
188 188
189#if IS_ENABLED(CONFIG_HYPERV) && defined(CONFIG_KEXEC_CORE)
189 machine_ops.shutdown = hv_machine_shutdown; 190 machine_ops.shutdown = hv_machine_shutdown;
190 machine_ops.crash_shutdown = hv_machine_crash_shutdown; 191 machine_ops.crash_shutdown = hv_machine_crash_shutdown;
192#endif
191 mark_tsc_unstable("running on Hyper-V"); 193 mark_tsc_unstable("running on Hyper-V");
192} 194}
193 195
diff --git a/arch/x86/kernel/cpu/scattered.c b/arch/x86/kernel/cpu/scattered.c
index 3d423a101fae..608fb26c7254 100644
--- a/arch/x86/kernel/cpu/scattered.c
+++ b/arch/x86/kernel/cpu/scattered.c
@@ -37,7 +37,7 @@ void init_scattered_cpuid_features(struct cpuinfo_x86 *c)
37 { X86_FEATURE_PLN, CR_EAX, 4, 0x00000006, 0 }, 37 { X86_FEATURE_PLN, CR_EAX, 4, 0x00000006, 0 },
38 { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 }, 38 { X86_FEATURE_PTS, CR_EAX, 6, 0x00000006, 0 },
39 { X86_FEATURE_HWP, CR_EAX, 7, 0x00000006, 0 }, 39 { X86_FEATURE_HWP, CR_EAX, 7, 0x00000006, 0 },
40 { X86_FEATURE_HWP_NOITFY, CR_EAX, 8, 0x00000006, 0 }, 40 { X86_FEATURE_HWP_NOTIFY, CR_EAX, 8, 0x00000006, 0 },
41 { X86_FEATURE_HWP_ACT_WINDOW, CR_EAX, 9, 0x00000006, 0 }, 41 { X86_FEATURE_HWP_ACT_WINDOW, CR_EAX, 9, 0x00000006, 0 },
42 { X86_FEATURE_HWP_EPP, CR_EAX,10, 0x00000006, 0 }, 42 { X86_FEATURE_HWP_EPP, CR_EAX,10, 0x00000006, 0 },
43 { X86_FEATURE_HWP_PKG_REQ, CR_EAX,11, 0x00000006, 0 }, 43 { X86_FEATURE_HWP_PKG_REQ, CR_EAX,11, 0x00000006, 0 },
diff --git a/arch/x86/kernel/crash.c b/arch/x86/kernel/crash.c
index e068d6683dba..74ca2fe7a0b3 100644
--- a/arch/x86/kernel/crash.c
+++ b/arch/x86/kernel/crash.c
@@ -185,10 +185,9 @@ void native_machine_crash_shutdown(struct pt_regs *regs)
185} 185}
186 186
187#ifdef CONFIG_KEXEC_FILE 187#ifdef CONFIG_KEXEC_FILE
188static int get_nr_ram_ranges_callback(unsigned long start_pfn, 188static int get_nr_ram_ranges_callback(u64 start, u64 end, void *arg)
189 unsigned long nr_pfn, void *arg)
190{ 189{
191 int *nr_ranges = arg; 190 unsigned int *nr_ranges = arg;
192 191
193 (*nr_ranges)++; 192 (*nr_ranges)++;
194 return 0; 193 return 0;
@@ -214,7 +213,7 @@ static void fill_up_crash_elf_data(struct crash_elf_data *ced,
214 213
215 ced->image = image; 214 ced->image = image;
216 215
217 walk_system_ram_range(0, -1, &nr_ranges, 216 walk_system_ram_res(0, -1, &nr_ranges,
218 get_nr_ram_ranges_callback); 217 get_nr_ram_ranges_callback);
219 218
220 ced->max_nr_ranges = nr_ranges; 219 ced->max_nr_ranges = nr_ranges;
diff --git a/arch/x86/kernel/process.c b/arch/x86/kernel/process.c
index 6d0e62ae8516..39e585a554b7 100644
--- a/arch/x86/kernel/process.c
+++ b/arch/x86/kernel/process.c
@@ -506,3 +506,58 @@ unsigned long arch_randomize_brk(struct mm_struct *mm)
506 return randomize_range(mm->brk, range_end, 0) ? : mm->brk; 506 return randomize_range(mm->brk, range_end, 0) ? : mm->brk;
507} 507}
508 508
509/*
510 * Called from fs/proc with a reference on @p to find the function
511 * which called into schedule(). This needs to be done carefully
512 * because the task might wake up and we might look at a stack
513 * changing under us.
514 */
515unsigned long get_wchan(struct task_struct *p)
516{
517 unsigned long start, bottom, top, sp, fp, ip;
518 int count = 0;
519
520 if (!p || p == current || p->state == TASK_RUNNING)
521 return 0;
522
523 start = (unsigned long)task_stack_page(p);
524 if (!start)
525 return 0;
526
527 /*
528 * Layout of the stack page:
529 *
530 * ----------- topmax = start + THREAD_SIZE - sizeof(unsigned long)
531 * PADDING
532 * ----------- top = topmax - TOP_OF_KERNEL_STACK_PADDING
533 * stack
534 * ----------- bottom = start + sizeof(thread_info)
535 * thread_info
536 * ----------- start
537 *
538 * The tasks stack pointer points at the location where the
539 * framepointer is stored. The data on the stack is:
540 * ... IP FP ... IP FP
541 *
542 * We need to read FP and IP, so we need to adjust the upper
543 * bound by another unsigned long.
544 */
545 top = start + THREAD_SIZE - TOP_OF_KERNEL_STACK_PADDING;
546 top -= 2 * sizeof(unsigned long);
547 bottom = start + sizeof(struct thread_info);
548
549 sp = READ_ONCE(p->thread.sp);
550 if (sp < bottom || sp > top)
551 return 0;
552
553 fp = READ_ONCE(*(unsigned long *)sp);
554 do {
555 if (fp < bottom || fp > top)
556 return 0;
557 ip = READ_ONCE(*(unsigned long *)(fp + sizeof(unsigned long)));
558 if (!in_sched_functions(ip))
559 return ip;
560 fp = READ_ONCE(*(unsigned long *)fp);
561 } while (count++ < 16 && p->state != TASK_RUNNING);
562 return 0;
563}
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c
index c13df2c735f8..737527b40e5b 100644
--- a/arch/x86/kernel/process_32.c
+++ b/arch/x86/kernel/process_32.c
@@ -324,31 +324,3 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p)
324 324
325 return prev_p; 325 return prev_p;
326} 326}
327
328#define top_esp (THREAD_SIZE - sizeof(unsigned long))
329#define top_ebp (THREAD_SIZE - 2*sizeof(unsigned long))
330
331unsigned long get_wchan(struct task_struct *p)
332{
333 unsigned long bp, sp, ip;
334 unsigned long stack_page;
335 int count = 0;
336 if (!p || p == current || p->state == TASK_RUNNING)
337 return 0;
338 stack_page = (unsigned long)task_stack_page(p);
339 sp = p->thread.sp;
340 if (!stack_page || sp < stack_page || sp > top_esp+stack_page)
341 return 0;
342 /* include/asm-i386/system.h:switch_to() pushes bp last. */
343 bp = *(unsigned long *) sp;
344 do {
345 if (bp < stack_page || bp > top_ebp+stack_page)
346 return 0;
347 ip = *(unsigned long *) (bp+4);
348 if (!in_sched_functions(ip))
349 return ip;
350 bp = *(unsigned long *) bp;
351 } while (count++ < 16);
352 return 0;
353}
354
diff --git a/arch/x86/kernel/process_64.c b/arch/x86/kernel/process_64.c
index 3c1bbcf12924..b35921a670b2 100644
--- a/arch/x86/kernel/process_64.c
+++ b/arch/x86/kernel/process_64.c
@@ -499,30 +499,6 @@ void set_personality_ia32(bool x32)
499} 499}
500EXPORT_SYMBOL_GPL(set_personality_ia32); 500EXPORT_SYMBOL_GPL(set_personality_ia32);
501 501
502unsigned long get_wchan(struct task_struct *p)
503{
504 unsigned long stack;
505 u64 fp, ip;
506 int count = 0;
507
508 if (!p || p == current || p->state == TASK_RUNNING)
509 return 0;
510 stack = (unsigned long)task_stack_page(p);
511 if (p->thread.sp < stack || p->thread.sp >= stack+THREAD_SIZE)
512 return 0;
513 fp = *(u64 *)(p->thread.sp);
514 do {
515 if (fp < (unsigned long)stack ||
516 fp >= (unsigned long)stack+THREAD_SIZE)
517 return 0;
518 ip = *(u64 *)(fp+8);
519 if (!in_sched_functions(ip))
520 return ip;
521 fp = *(u64 *)fp;
522 } while (count++ < 16);
523 return 0;
524}
525
526long do_arch_prctl(struct task_struct *task, int code, unsigned long addr) 502long do_arch_prctl(struct task_struct *task, int code, unsigned long addr)
527{ 503{
528 int ret = 0; 504 int ret = 0;
diff --git a/arch/x86/mm/init_64.c b/arch/x86/mm/init_64.c
index 30564e2752d3..df48430c279b 100644
--- a/arch/x86/mm/init_64.c
+++ b/arch/x86/mm/init_64.c
@@ -1132,7 +1132,7 @@ void mark_rodata_ro(void)
1132 * has been zapped already via cleanup_highmem(). 1132 * has been zapped already via cleanup_highmem().
1133 */ 1133 */
1134 all_end = roundup((unsigned long)_brk_end, PMD_SIZE); 1134 all_end = roundup((unsigned long)_brk_end, PMD_SIZE);
1135 set_memory_nx(rodata_start, (all_end - rodata_start) >> PAGE_SHIFT); 1135 set_memory_nx(text_end, (all_end - text_end) >> PAGE_SHIFT);
1136 1136
1137 rodata_test(); 1137 rodata_test();
1138 1138