aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Hansen <dave.hansen@linux.intel.com>2017-12-04 20:25:07 -0500
committerIngo Molnar <mingo@kernel.org>2017-12-22 14:13:02 -0500
commit4fe2d8b11a370af286287a2661de9d4e6c9a145a (patch)
tree80a21157aef3657a706a5ea25e264a7e32d36ed5
parente8ffe96e5933d417195268478479933d56213a3f (diff)
x86/entry: Rename SYSENTER_stack to CPU_ENTRY_AREA_entry_stack
If the kernel oopses while on the trampoline stack, it will print "<SYSENTER>" even if SYSENTER is not involved. That is rather confusing. The "SYSENTER" stack is used for a lot more than SYSENTER now. Give it a better string to display in stack dumps, and rename the kernel code to match. Also move the 32-bit code over to the new naming even though it still uses the entry stack only for SYSENTER. Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com> Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Cc: Andy Lutomirski <luto@kernel.org> Cc: Borislav Petkov <bp@alien8.de> Cc: Borislav Petkov <bp@suse.de> Cc: Brian Gerst <brgerst@gmail.com> Cc: Denys Vlasenko <dvlasenk@redhat.com> Cc: H. Peter Anvin <hpa@zytor.com> Cc: Josh Poimboeuf <jpoimboe@redhat.com> Cc: Juergen Gross <jgross@suse.com> Cc: Linus Torvalds <torvalds@linux-foundation.org> Cc: Peter Zijlstra <peterz@infradead.org> Signed-off-by: Ingo Molnar <mingo@kernel.org>
-rw-r--r--arch/x86/entry/entry_32.S12
-rw-r--r--arch/x86/entry/entry_64.S4
-rw-r--r--arch/x86/include/asm/fixmap.h8
-rw-r--r--arch/x86/include/asm/processor.h6
-rw-r--r--arch/x86/include/asm/stacktrace.h4
-rw-r--r--arch/x86/kernel/asm-offsets.c4
-rw-r--r--arch/x86/kernel/asm-offsets_32.c2
-rw-r--r--arch/x86/kernel/cpu/common.c14
-rw-r--r--arch/x86/kernel/dumpstack.c10
-rw-r--r--arch/x86/kernel/dumpstack_32.c6
-rw-r--r--arch/x86/kernel/dumpstack_64.c12
11 files changed, 44 insertions, 38 deletions
diff --git a/arch/x86/entry/entry_32.S b/arch/x86/entry/entry_32.S
index bd8b57a5c874..ace8f321a5a1 100644
--- a/arch/x86/entry/entry_32.S
+++ b/arch/x86/entry/entry_32.S
@@ -942,9 +942,9 @@ ENTRY(debug)
942 942
943 /* Are we currently on the SYSENTER stack? */ 943 /* Are we currently on the SYSENTER stack? */
944 movl PER_CPU_VAR(cpu_entry_area), %ecx 944 movl PER_CPU_VAR(cpu_entry_area), %ecx
945 addl $CPU_ENTRY_AREA_SYSENTER_stack + SIZEOF_SYSENTER_stack, %ecx 945 addl $CPU_ENTRY_AREA_entry_stack + SIZEOF_entry_stack, %ecx
946 subl %eax, %ecx /* ecx = (end of SYSENTER_stack) - esp */ 946 subl %eax, %ecx /* ecx = (end of entry_stack) - esp */
947 cmpl $SIZEOF_SYSENTER_stack, %ecx 947 cmpl $SIZEOF_entry_stack, %ecx
948 jb .Ldebug_from_sysenter_stack 948 jb .Ldebug_from_sysenter_stack
949 949
950 TRACE_IRQS_OFF 950 TRACE_IRQS_OFF
@@ -986,9 +986,9 @@ ENTRY(nmi)
986 986
987 /* Are we currently on the SYSENTER stack? */ 987 /* Are we currently on the SYSENTER stack? */
988 movl PER_CPU_VAR(cpu_entry_area), %ecx 988 movl PER_CPU_VAR(cpu_entry_area), %ecx
989 addl $CPU_ENTRY_AREA_SYSENTER_stack + SIZEOF_SYSENTER_stack, %ecx 989 addl $CPU_ENTRY_AREA_entry_stack + SIZEOF_entry_stack, %ecx
990 subl %eax, %ecx /* ecx = (end of SYSENTER_stack) - esp */ 990 subl %eax, %ecx /* ecx = (end of entry_stack) - esp */
991 cmpl $SIZEOF_SYSENTER_stack, %ecx 991 cmpl $SIZEOF_entry_stack, %ecx
992 jb .Lnmi_from_sysenter_stack 992 jb .Lnmi_from_sysenter_stack
993 993
994 /* Not on SYSENTER stack. */ 994 /* Not on SYSENTER stack. */
diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index 2812ce043a7a..87cebe78bbef 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -154,8 +154,8 @@ END(native_usergs_sysret64)
154 _entry_trampoline - CPU_ENTRY_AREA_entry_trampoline(%rip) 154 _entry_trampoline - CPU_ENTRY_AREA_entry_trampoline(%rip)
155 155
156/* The top word of the SYSENTER stack is hot and is usable as scratch space. */ 156/* The top word of the SYSENTER stack is hot and is usable as scratch space. */
157#define RSP_SCRATCH CPU_ENTRY_AREA_SYSENTER_stack + \ 157#define RSP_SCRATCH CPU_ENTRY_AREA_entry_stack + \
158 SIZEOF_SYSENTER_stack - 8 + CPU_ENTRY_AREA 158 SIZEOF_entry_stack - 8 + CPU_ENTRY_AREA
159 159
160ENTRY(entry_SYSCALL_64_trampoline) 160ENTRY(entry_SYSCALL_64_trampoline)
161 UNWIND_HINT_EMPTY 161 UNWIND_HINT_EMPTY
diff --git a/arch/x86/include/asm/fixmap.h b/arch/x86/include/asm/fixmap.h
index 94fc4fa14127..8153b8d86a3c 100644
--- a/arch/x86/include/asm/fixmap.h
+++ b/arch/x86/include/asm/fixmap.h
@@ -56,10 +56,10 @@ struct cpu_entry_area {
56 char gdt[PAGE_SIZE]; 56 char gdt[PAGE_SIZE];
57 57
58 /* 58 /*
59 * The GDT is just below SYSENTER_stack and thus serves (on x86_64) as 59 * The GDT is just below entry_stack and thus serves (on x86_64) as
60 * a a read-only guard page. 60 * a a read-only guard page.
61 */ 61 */
62 struct SYSENTER_stack_page SYSENTER_stack_page; 62 struct entry_stack_page entry_stack_page;
63 63
64 /* 64 /*
65 * On x86_64, the TSS is mapped RO. On x86_32, it's mapped RW because 65 * On x86_64, the TSS is mapped RO. On x86_32, it's mapped RW because
@@ -250,9 +250,9 @@ static inline struct cpu_entry_area *get_cpu_entry_area(int cpu)
250 return (struct cpu_entry_area *)__fix_to_virt(__get_cpu_entry_area_page_index(cpu, 0)); 250 return (struct cpu_entry_area *)__fix_to_virt(__get_cpu_entry_area_page_index(cpu, 0));
251} 251}
252 252
253static inline struct SYSENTER_stack *cpu_SYSENTER_stack(int cpu) 253static inline struct entry_stack *cpu_entry_stack(int cpu)
254{ 254{
255 return &get_cpu_entry_area(cpu)->SYSENTER_stack_page.stack; 255 return &get_cpu_entry_area(cpu)->entry_stack_page.stack;
256} 256}
257 257
258#endif /* !__ASSEMBLY__ */ 258#endif /* !__ASSEMBLY__ */
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index da943411d3d8..9e482d8b0b97 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -336,12 +336,12 @@ struct x86_hw_tss {
336#define IO_BITMAP_OFFSET (offsetof(struct tss_struct, io_bitmap) - offsetof(struct tss_struct, x86_tss)) 336#define IO_BITMAP_OFFSET (offsetof(struct tss_struct, io_bitmap) - offsetof(struct tss_struct, x86_tss))
337#define INVALID_IO_BITMAP_OFFSET 0x8000 337#define INVALID_IO_BITMAP_OFFSET 0x8000
338 338
339struct SYSENTER_stack { 339struct entry_stack {
340 unsigned long words[64]; 340 unsigned long words[64];
341}; 341};
342 342
343struct SYSENTER_stack_page { 343struct entry_stack_page {
344 struct SYSENTER_stack stack; 344 struct entry_stack stack;
345} __aligned(PAGE_SIZE); 345} __aligned(PAGE_SIZE);
346 346
347struct tss_struct { 347struct tss_struct {
diff --git a/arch/x86/include/asm/stacktrace.h b/arch/x86/include/asm/stacktrace.h
index f8062bfd43a0..f73706878772 100644
--- a/arch/x86/include/asm/stacktrace.h
+++ b/arch/x86/include/asm/stacktrace.h
@@ -16,7 +16,7 @@ enum stack_type {
16 STACK_TYPE_TASK, 16 STACK_TYPE_TASK,
17 STACK_TYPE_IRQ, 17 STACK_TYPE_IRQ,
18 STACK_TYPE_SOFTIRQ, 18 STACK_TYPE_SOFTIRQ,
19 STACK_TYPE_SYSENTER, 19 STACK_TYPE_ENTRY,
20 STACK_TYPE_EXCEPTION, 20 STACK_TYPE_EXCEPTION,
21 STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1, 21 STACK_TYPE_EXCEPTION_LAST = STACK_TYPE_EXCEPTION + N_EXCEPTION_STACKS-1,
22}; 22};
@@ -29,7 +29,7 @@ struct stack_info {
29bool in_task_stack(unsigned long *stack, struct task_struct *task, 29bool in_task_stack(unsigned long *stack, struct task_struct *task,
30 struct stack_info *info); 30 struct stack_info *info);
31 31
32bool in_sysenter_stack(unsigned long *stack, struct stack_info *info); 32bool in_entry_stack(unsigned long *stack, struct stack_info *info);
33 33
34int get_stack_info(unsigned long *stack, struct task_struct *task, 34int get_stack_info(unsigned long *stack, struct task_struct *task,
35 struct stack_info *info, unsigned long *visit_mask); 35 struct stack_info *info, unsigned long *visit_mask);
diff --git a/arch/x86/kernel/asm-offsets.c b/arch/x86/kernel/asm-offsets.c
index cd360a5e0dca..676b7cf4b62b 100644
--- a/arch/x86/kernel/asm-offsets.c
+++ b/arch/x86/kernel/asm-offsets.c
@@ -97,6 +97,6 @@ void common(void) {
97 /* Layout info for cpu_entry_area */ 97 /* Layout info for cpu_entry_area */
98 OFFSET(CPU_ENTRY_AREA_tss, cpu_entry_area, tss); 98 OFFSET(CPU_ENTRY_AREA_tss, cpu_entry_area, tss);
99 OFFSET(CPU_ENTRY_AREA_entry_trampoline, cpu_entry_area, entry_trampoline); 99 OFFSET(CPU_ENTRY_AREA_entry_trampoline, cpu_entry_area, entry_trampoline);
100 OFFSET(CPU_ENTRY_AREA_SYSENTER_stack, cpu_entry_area, SYSENTER_stack_page); 100 OFFSET(CPU_ENTRY_AREA_entry_stack, cpu_entry_area, entry_stack_page);
101 DEFINE(SIZEOF_SYSENTER_stack, sizeof(struct SYSENTER_stack)); 101 DEFINE(SIZEOF_entry_stack, sizeof(struct entry_stack));
102} 102}
diff --git a/arch/x86/kernel/asm-offsets_32.c b/arch/x86/kernel/asm-offsets_32.c
index 7d20d9c0b3d6..fa1261eefa16 100644
--- a/arch/x86/kernel/asm-offsets_32.c
+++ b/arch/x86/kernel/asm-offsets_32.c
@@ -48,7 +48,7 @@ void foo(void)
48 48
49 /* Offset from the sysenter stack to tss.sp0 */ 49 /* Offset from the sysenter stack to tss.sp0 */
50 DEFINE(TSS_sysenter_sp0, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) - 50 DEFINE(TSS_sysenter_sp0, offsetof(struct cpu_entry_area, tss.x86_tss.sp0) -
51 offsetofend(struct cpu_entry_area, SYSENTER_stack_page.stack)); 51 offsetofend(struct cpu_entry_area, entry_stack_page.stack));
52 52
53#ifdef CONFIG_CC_STACKPROTECTOR 53#ifdef CONFIG_CC_STACKPROTECTOR
54 BLANK(); 54 BLANK();
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c
index 034900623adf..ed4acbce37a8 100644
--- a/arch/x86/kernel/cpu/common.c
+++ b/arch/x86/kernel/cpu/common.c
@@ -487,8 +487,8 @@ static DEFINE_PER_CPU_PAGE_ALIGNED(char, exception_stacks
487 [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]); 487 [(N_EXCEPTION_STACKS - 1) * EXCEPTION_STKSZ + DEBUG_STKSZ]);
488#endif 488#endif
489 489
490static DEFINE_PER_CPU_PAGE_ALIGNED(struct SYSENTER_stack_page, 490static DEFINE_PER_CPU_PAGE_ALIGNED(struct entry_stack_page,
491 SYSENTER_stack_storage); 491 entry_stack_storage);
492 492
493static void __init 493static void __init
494set_percpu_fixmap_pages(int idx, void *ptr, int pages, pgprot_t prot) 494set_percpu_fixmap_pages(int idx, void *ptr, int pages, pgprot_t prot)
@@ -523,8 +523,8 @@ static void __init setup_cpu_entry_area(int cpu)
523#endif 523#endif
524 524
525 __set_fixmap(get_cpu_entry_area_index(cpu, gdt), get_cpu_gdt_paddr(cpu), gdt_prot); 525 __set_fixmap(get_cpu_entry_area_index(cpu, gdt), get_cpu_gdt_paddr(cpu), gdt_prot);
526 set_percpu_fixmap_pages(get_cpu_entry_area_index(cpu, SYSENTER_stack_page), 526 set_percpu_fixmap_pages(get_cpu_entry_area_index(cpu, entry_stack_page),
527 per_cpu_ptr(&SYSENTER_stack_storage, cpu), 1, 527 per_cpu_ptr(&entry_stack_storage, cpu), 1,
528 PAGE_KERNEL); 528 PAGE_KERNEL);
529 529
530 /* 530 /*
@@ -1323,7 +1323,7 @@ void enable_sep_cpu(void)
1323 1323
1324 tss->x86_tss.ss1 = __KERNEL_CS; 1324 tss->x86_tss.ss1 = __KERNEL_CS;
1325 wrmsr(MSR_IA32_SYSENTER_CS, tss->x86_tss.ss1, 0); 1325 wrmsr(MSR_IA32_SYSENTER_CS, tss->x86_tss.ss1, 0);
1326 wrmsr(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_SYSENTER_stack(cpu) + 1), 0); 1326 wrmsr(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_entry_stack(cpu) + 1), 0);
1327 wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0); 1327 wrmsr(MSR_IA32_SYSENTER_EIP, (unsigned long)entry_SYSENTER_32, 0);
1328 1328
1329 put_cpu(); 1329 put_cpu();
@@ -1440,7 +1440,7 @@ void syscall_init(void)
1440 * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit). 1440 * AMD doesn't allow SYSENTER in long mode (either 32- or 64-bit).
1441 */ 1441 */
1442 wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS); 1442 wrmsrl_safe(MSR_IA32_SYSENTER_CS, (u64)__KERNEL_CS);
1443 wrmsrl_safe(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_SYSENTER_stack(cpu) + 1)); 1443 wrmsrl_safe(MSR_IA32_SYSENTER_ESP, (unsigned long)(cpu_entry_stack(cpu) + 1));
1444 wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat); 1444 wrmsrl_safe(MSR_IA32_SYSENTER_EIP, (u64)entry_SYSENTER_compat);
1445#else 1445#else
1446 wrmsrl(MSR_CSTAR, (unsigned long)ignore_sysret); 1446 wrmsrl(MSR_CSTAR, (unsigned long)ignore_sysret);
@@ -1655,7 +1655,7 @@ void cpu_init(void)
1655 */ 1655 */
1656 set_tss_desc(cpu, &get_cpu_entry_area(cpu)->tss.x86_tss); 1656 set_tss_desc(cpu, &get_cpu_entry_area(cpu)->tss.x86_tss);
1657 load_TR_desc(); 1657 load_TR_desc();
1658 load_sp0((unsigned long)(cpu_SYSENTER_stack(cpu) + 1)); 1658 load_sp0((unsigned long)(cpu_entry_stack(cpu) + 1));
1659 1659
1660 load_mm_ldt(&init_mm); 1660 load_mm_ldt(&init_mm);
1661 1661
diff --git a/arch/x86/kernel/dumpstack.c b/arch/x86/kernel/dumpstack.c
index bbd6d986e2d0..1dd3f533d78c 100644
--- a/arch/x86/kernel/dumpstack.c
+++ b/arch/x86/kernel/dumpstack.c
@@ -43,9 +43,9 @@ bool in_task_stack(unsigned long *stack, struct task_struct *task,
43 return true; 43 return true;
44} 44}
45 45
46bool in_sysenter_stack(unsigned long *stack, struct stack_info *info) 46bool in_entry_stack(unsigned long *stack, struct stack_info *info)
47{ 47{
48 struct SYSENTER_stack *ss = cpu_SYSENTER_stack(smp_processor_id()); 48 struct entry_stack *ss = cpu_entry_stack(smp_processor_id());
49 49
50 void *begin = ss; 50 void *begin = ss;
51 void *end = ss + 1; 51 void *end = ss + 1;
@@ -53,7 +53,7 @@ bool in_sysenter_stack(unsigned long *stack, struct stack_info *info)
53 if ((void *)stack < begin || (void *)stack >= end) 53 if ((void *)stack < begin || (void *)stack >= end)
54 return false; 54 return false;
55 55
56 info->type = STACK_TYPE_SYSENTER; 56 info->type = STACK_TYPE_ENTRY;
57 info->begin = begin; 57 info->begin = begin;
58 info->end = end; 58 info->end = end;
59 info->next_sp = NULL; 59 info->next_sp = NULL;
@@ -111,13 +111,13 @@ void show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
111 * - task stack 111 * - task stack
112 * - interrupt stack 112 * - interrupt stack
113 * - HW exception stacks (double fault, nmi, debug, mce) 113 * - HW exception stacks (double fault, nmi, debug, mce)
114 * - SYSENTER stack 114 * - entry stack
115 * 115 *
116 * x86-32 can have up to four stacks: 116 * x86-32 can have up to four stacks:
117 * - task stack 117 * - task stack
118 * - softirq stack 118 * - softirq stack
119 * - hardirq stack 119 * - hardirq stack
120 * - SYSENTER stack 120 * - entry stack
121 */ 121 */
122 for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) { 122 for (regs = NULL; stack; stack = PTR_ALIGN(stack_info.next_sp, sizeof(long))) {
123 const char *stack_name; 123 const char *stack_name;
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
index 5ff13a6b3680..04170f63e3a1 100644
--- a/arch/x86/kernel/dumpstack_32.c
+++ b/arch/x86/kernel/dumpstack_32.c
@@ -26,8 +26,8 @@ const char *stack_type_name(enum stack_type type)
26 if (type == STACK_TYPE_SOFTIRQ) 26 if (type == STACK_TYPE_SOFTIRQ)
27 return "SOFTIRQ"; 27 return "SOFTIRQ";
28 28
29 if (type == STACK_TYPE_SYSENTER) 29 if (type == STACK_TYPE_ENTRY)
30 return "SYSENTER"; 30 return "ENTRY_TRAMPOLINE";
31 31
32 return NULL; 32 return NULL;
33} 33}
@@ -96,7 +96,7 @@ int get_stack_info(unsigned long *stack, struct task_struct *task,
96 if (task != current) 96 if (task != current)
97 goto unknown; 97 goto unknown;
98 98
99 if (in_sysenter_stack(stack, info)) 99 if (in_entry_stack(stack, info))
100 goto recursion_check; 100 goto recursion_check;
101 101
102 if (in_hardirq_stack(stack, info)) 102 if (in_hardirq_stack(stack, info))
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
index abc828f8c297..563e28d14f2c 100644
--- a/arch/x86/kernel/dumpstack_64.c
+++ b/arch/x86/kernel/dumpstack_64.c
@@ -37,8 +37,14 @@ const char *stack_type_name(enum stack_type type)
37 if (type == STACK_TYPE_IRQ) 37 if (type == STACK_TYPE_IRQ)
38 return "IRQ"; 38 return "IRQ";
39 39
40 if (type == STACK_TYPE_SYSENTER) 40 if (type == STACK_TYPE_ENTRY) {
41 return "SYSENTER"; 41 /*
42 * On 64-bit, we have a generic entry stack that we
43 * use for all the kernel entry points, including
44 * SYSENTER.
45 */
46 return "ENTRY_TRAMPOLINE";
47 }
42 48
43 if (type >= STACK_TYPE_EXCEPTION && type <= STACK_TYPE_EXCEPTION_LAST) 49 if (type >= STACK_TYPE_EXCEPTION && type <= STACK_TYPE_EXCEPTION_LAST)
44 return exception_stack_names[type - STACK_TYPE_EXCEPTION]; 50 return exception_stack_names[type - STACK_TYPE_EXCEPTION];
@@ -118,7 +124,7 @@ int get_stack_info(unsigned long *stack, struct task_struct *task,
118 if (in_irq_stack(stack, info)) 124 if (in_irq_stack(stack, info))
119 goto recursion_check; 125 goto recursion_check;
120 126
121 if (in_sysenter_stack(stack, info)) 127 if (in_entry_stack(stack, info))
122 goto recursion_check; 128 goto recursion_check;
123 129
124 goto unknown; 130 goto unknown;