diff options
author | Ingo Molnar <mingo@kernel.org> | 2014-04-02 03:48:56 -0400 |
---|---|---|
committer | Ingo Molnar <mingo@kernel.org> | 2014-04-02 03:48:56 -0400 |
commit | b8764fe6d0ba654c8705ebbb8c2c8ddd776d8928 (patch) | |
tree | 3e28a08a044547d5429f011bcce24a3c82c89fec /arch/x86/kernel | |
parent | b8c89c6a0d56d47ae7f22755a133540b32fa81cf (diff) | |
parent | 683b6c6f82a60fabf47012581c2cfbf1b037ab95 (diff) |
Merge branch 'linus' into x86/urgent
Pick up Linus's latest, to fix a bug.
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/cpu/common.c | 11 | ||||
-rw-r--r-- | arch/x86/kernel/cpu/mshyperv.c | 78 | ||||
-rw-r--r-- | arch/x86/kernel/dumpstack_32.c | 44 | ||||
-rw-r--r-- | arch/x86/kernel/dumpstack_64.c | 117 | ||||
-rw-r--r-- | arch/x86/kernel/early-quirks.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/hpet.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/irq.c | 6 | ||||
-rw-r--r-- | arch/x86/kernel/irq_32.c | 83 | ||||
-rw-r--r-- | arch/x86/kernel/process_32.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/ptrace.c | 8 | ||||
-rw-r--r-- | arch/x86/kernel/reboot.c | 15 | ||||
-rw-r--r-- | arch/x86/kernel/smpboot.c | 4 | ||||
-rw-r--r-- | arch/x86/kernel/time.c | 2 |
13 files changed, 245 insertions, 146 deletions
diff --git a/arch/x86/kernel/cpu/common.c b/arch/x86/kernel/cpu/common.c index 8e28bf2fc3ef..a135239badb7 100644 --- a/arch/x86/kernel/cpu/common.c +++ b/arch/x86/kernel/cpu/common.c | |||
@@ -1025,7 +1025,8 @@ __setup("show_msr=", setup_show_msr); | |||
1025 | 1025 | ||
1026 | static __init int setup_noclflush(char *arg) | 1026 | static __init int setup_noclflush(char *arg) |
1027 | { | 1027 | { |
1028 | setup_clear_cpu_cap(X86_FEATURE_CLFLSH); | 1028 | setup_clear_cpu_cap(X86_FEATURE_CLFLUSH); |
1029 | setup_clear_cpu_cap(X86_FEATURE_CLFLUSHOPT); | ||
1029 | return 1; | 1030 | return 1; |
1030 | } | 1031 | } |
1031 | __setup("noclflush", setup_noclflush); | 1032 | __setup("noclflush", setup_noclflush); |
@@ -1078,6 +1079,10 @@ static __init int setup_disablecpuid(char *arg) | |||
1078 | } | 1079 | } |
1079 | __setup("clearcpuid=", setup_disablecpuid); | 1080 | __setup("clearcpuid=", setup_disablecpuid); |
1080 | 1081 | ||
1082 | DEFINE_PER_CPU(unsigned long, kernel_stack) = | ||
1083 | (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE; | ||
1084 | EXPORT_PER_CPU_SYMBOL(kernel_stack); | ||
1085 | |||
1081 | #ifdef CONFIG_X86_64 | 1086 | #ifdef CONFIG_X86_64 |
1082 | struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table }; | 1087 | struct desc_ptr idt_descr = { NR_VECTORS * 16 - 1, (unsigned long) idt_table }; |
1083 | struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, | 1088 | struct desc_ptr debug_idt_descr = { NR_VECTORS * 16 - 1, |
@@ -1094,10 +1099,6 @@ DEFINE_PER_CPU(struct task_struct *, current_task) ____cacheline_aligned = | |||
1094 | &init_task; | 1099 | &init_task; |
1095 | EXPORT_PER_CPU_SYMBOL(current_task); | 1100 | EXPORT_PER_CPU_SYMBOL(current_task); |
1096 | 1101 | ||
1097 | DEFINE_PER_CPU(unsigned long, kernel_stack) = | ||
1098 | (unsigned long)&init_thread_union - KERNEL_STACK_OFFSET + THREAD_SIZE; | ||
1099 | EXPORT_PER_CPU_SYMBOL(kernel_stack); | ||
1100 | |||
1101 | DEFINE_PER_CPU(char *, irq_stack_ptr) = | 1102 | DEFINE_PER_CPU(char *, irq_stack_ptr) = |
1102 | init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64; | 1103 | init_per_cpu_var(irq_stack_union.irq_stack) + IRQ_STACK_SIZE - 64; |
1103 | 1104 | ||
diff --git a/arch/x86/kernel/cpu/mshyperv.c b/arch/x86/kernel/cpu/mshyperv.c index 832d05a914ba..76f98fe5b35c 100644 --- a/arch/x86/kernel/cpu/mshyperv.c +++ b/arch/x86/kernel/cpu/mshyperv.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/hardirq.h> | 17 | #include <linux/hardirq.h> |
18 | #include <linux/efi.h> | 18 | #include <linux/efi.h> |
19 | #include <linux/interrupt.h> | 19 | #include <linux/interrupt.h> |
20 | #include <linux/irq.h> | ||
20 | #include <asm/processor.h> | 21 | #include <asm/processor.h> |
21 | #include <asm/hypervisor.h> | 22 | #include <asm/hypervisor.h> |
22 | #include <asm/hyperv.h> | 23 | #include <asm/hyperv.h> |
@@ -31,6 +32,45 @@ | |||
31 | struct ms_hyperv_info ms_hyperv; | 32 | struct ms_hyperv_info ms_hyperv; |
32 | EXPORT_SYMBOL_GPL(ms_hyperv); | 33 | EXPORT_SYMBOL_GPL(ms_hyperv); |
33 | 34 | ||
35 | #if IS_ENABLED(CONFIG_HYPERV) | ||
36 | static void (*vmbus_handler)(void); | ||
37 | |||
38 | void hyperv_vector_handler(struct pt_regs *regs) | ||
39 | { | ||
40 | struct pt_regs *old_regs = set_irq_regs(regs); | ||
41 | |||
42 | irq_enter(); | ||
43 | exit_idle(); | ||
44 | |||
45 | inc_irq_stat(irq_hv_callback_count); | ||
46 | if (vmbus_handler) | ||
47 | vmbus_handler(); | ||
48 | |||
49 | irq_exit(); | ||
50 | set_irq_regs(old_regs); | ||
51 | } | ||
52 | |||
53 | void hv_setup_vmbus_irq(void (*handler)(void)) | ||
54 | { | ||
55 | vmbus_handler = handler; | ||
56 | /* | ||
57 | * Setup the IDT for hypervisor callback. Prevent reallocation | ||
58 | * at module reload. | ||
59 | */ | ||
60 | if (!test_bit(HYPERVISOR_CALLBACK_VECTOR, used_vectors)) | ||
61 | alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, | ||
62 | hyperv_callback_vector); | ||
63 | } | ||
64 | |||
65 | void hv_remove_vmbus_irq(void) | ||
66 | { | ||
67 | /* We have no way to deallocate the interrupt gate */ | ||
68 | vmbus_handler = NULL; | ||
69 | } | ||
70 | EXPORT_SYMBOL_GPL(hv_setup_vmbus_irq); | ||
71 | EXPORT_SYMBOL_GPL(hv_remove_vmbus_irq); | ||
72 | #endif | ||
73 | |||
34 | static uint32_t __init ms_hyperv_platform(void) | 74 | static uint32_t __init ms_hyperv_platform(void) |
35 | { | 75 | { |
36 | u32 eax; | 76 | u32 eax; |
@@ -119,41 +159,3 @@ const __refconst struct hypervisor_x86 x86_hyper_ms_hyperv = { | |||
119 | .init_platform = ms_hyperv_init_platform, | 159 | .init_platform = ms_hyperv_init_platform, |
120 | }; | 160 | }; |
121 | EXPORT_SYMBOL(x86_hyper_ms_hyperv); | 161 | EXPORT_SYMBOL(x86_hyper_ms_hyperv); |
122 | |||
123 | #if IS_ENABLED(CONFIG_HYPERV) | ||
124 | static int vmbus_irq = -1; | ||
125 | static irq_handler_t vmbus_isr; | ||
126 | |||
127 | void hv_register_vmbus_handler(int irq, irq_handler_t handler) | ||
128 | { | ||
129 | /* | ||
130 | * Setup the IDT for hypervisor callback. | ||
131 | */ | ||
132 | alloc_intr_gate(HYPERVISOR_CALLBACK_VECTOR, hyperv_callback_vector); | ||
133 | |||
134 | vmbus_irq = irq; | ||
135 | vmbus_isr = handler; | ||
136 | } | ||
137 | |||
138 | void hyperv_vector_handler(struct pt_regs *regs) | ||
139 | { | ||
140 | struct pt_regs *old_regs = set_irq_regs(regs); | ||
141 | struct irq_desc *desc; | ||
142 | |||
143 | irq_enter(); | ||
144 | exit_idle(); | ||
145 | |||
146 | desc = irq_to_desc(vmbus_irq); | ||
147 | |||
148 | if (desc) | ||
149 | generic_handle_irq_desc(vmbus_irq, desc); | ||
150 | |||
151 | irq_exit(); | ||
152 | set_irq_regs(old_regs); | ||
153 | } | ||
154 | #else | ||
155 | void hv_register_vmbus_handler(int irq, irq_handler_t handler) | ||
156 | { | ||
157 | } | ||
158 | #endif | ||
159 | EXPORT_SYMBOL_GPL(hv_register_vmbus_handler); | ||
diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c index a21d49c071db..5abd4cd4230c 100644 --- a/arch/x86/kernel/dumpstack_32.c +++ b/arch/x86/kernel/dumpstack_32.c | |||
@@ -16,12 +16,35 @@ | |||
16 | 16 | ||
17 | #include <asm/stacktrace.h> | 17 | #include <asm/stacktrace.h> |
18 | 18 | ||
19 | static void *is_irq_stack(void *p, void *irq) | ||
20 | { | ||
21 | if (p < irq || p >= (irq + THREAD_SIZE)) | ||
22 | return NULL; | ||
23 | return irq + THREAD_SIZE; | ||
24 | } | ||
25 | |||
26 | |||
27 | static void *is_hardirq_stack(unsigned long *stack, int cpu) | ||
28 | { | ||
29 | void *irq = per_cpu(hardirq_stack, cpu); | ||
30 | |||
31 | return is_irq_stack(stack, irq); | ||
32 | } | ||
33 | |||
34 | static void *is_softirq_stack(unsigned long *stack, int cpu) | ||
35 | { | ||
36 | void *irq = per_cpu(softirq_stack, cpu); | ||
37 | |||
38 | return is_irq_stack(stack, irq); | ||
39 | } | ||
19 | 40 | ||
20 | void dump_trace(struct task_struct *task, struct pt_regs *regs, | 41 | void dump_trace(struct task_struct *task, struct pt_regs *regs, |
21 | unsigned long *stack, unsigned long bp, | 42 | unsigned long *stack, unsigned long bp, |
22 | const struct stacktrace_ops *ops, void *data) | 43 | const struct stacktrace_ops *ops, void *data) |
23 | { | 44 | { |
45 | const unsigned cpu = get_cpu(); | ||
24 | int graph = 0; | 46 | int graph = 0; |
47 | u32 *prev_esp; | ||
25 | 48 | ||
26 | if (!task) | 49 | if (!task) |
27 | task = current; | 50 | task = current; |
@@ -39,18 +62,31 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, | |||
39 | 62 | ||
40 | for (;;) { | 63 | for (;;) { |
41 | struct thread_info *context; | 64 | struct thread_info *context; |
65 | void *end_stack; | ||
66 | |||
67 | end_stack = is_hardirq_stack(stack, cpu); | ||
68 | if (!end_stack) | ||
69 | end_stack = is_softirq_stack(stack, cpu); | ||
42 | 70 | ||
43 | context = (struct thread_info *) | 71 | context = task_thread_info(task); |
44 | ((unsigned long)stack & (~(THREAD_SIZE - 1))); | 72 | bp = ops->walk_stack(context, stack, bp, ops, data, |
45 | bp = ops->walk_stack(context, stack, bp, ops, data, NULL, &graph); | 73 | end_stack, &graph); |
46 | 74 | ||
47 | stack = (unsigned long *)context->previous_esp; | 75 | /* Stop if not on irq stack */ |
76 | if (!end_stack) | ||
77 | break; | ||
78 | |||
79 | /* The previous esp is saved on the bottom of the stack */ | ||
80 | prev_esp = (u32 *)(end_stack - THREAD_SIZE); | ||
81 | stack = (unsigned long *)*prev_esp; | ||
48 | if (!stack) | 82 | if (!stack) |
49 | break; | 83 | break; |
84 | |||
50 | if (ops->stack(data, "IRQ") < 0) | 85 | if (ops->stack(data, "IRQ") < 0) |
51 | break; | 86 | break; |
52 | touch_nmi_watchdog(); | 87 | touch_nmi_watchdog(); |
53 | } | 88 | } |
89 | put_cpu(); | ||
54 | } | 90 | } |
55 | EXPORT_SYMBOL(dump_trace); | 91 | EXPORT_SYMBOL(dump_trace); |
56 | 92 | ||
diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c index addb207dab92..346b1df2412e 100644 --- a/arch/x86/kernel/dumpstack_64.c +++ b/arch/x86/kernel/dumpstack_64.c | |||
@@ -104,6 +104,45 @@ in_irq_stack(unsigned long *stack, unsigned long *irq_stack, | |||
104 | return (stack >= irq_stack && stack < irq_stack_end); | 104 | return (stack >= irq_stack && stack < irq_stack_end); |
105 | } | 105 | } |
106 | 106 | ||
107 | static const unsigned long irq_stack_size = | ||
108 | (IRQ_STACK_SIZE - 64) / sizeof(unsigned long); | ||
109 | |||
110 | enum stack_type { | ||
111 | STACK_IS_UNKNOWN, | ||
112 | STACK_IS_NORMAL, | ||
113 | STACK_IS_EXCEPTION, | ||
114 | STACK_IS_IRQ, | ||
115 | }; | ||
116 | |||
117 | static enum stack_type | ||
118 | analyze_stack(int cpu, struct task_struct *task, | ||
119 | unsigned long *stack, unsigned long **stack_end, char **id) | ||
120 | { | ||
121 | unsigned long *irq_stack; | ||
122 | unsigned long addr; | ||
123 | unsigned used = 0; | ||
124 | |||
125 | addr = ((unsigned long)stack & (~(THREAD_SIZE - 1))); | ||
126 | if ((unsigned long)task_stack_page(task) == addr) | ||
127 | return STACK_IS_NORMAL; | ||
128 | |||
129 | *stack_end = in_exception_stack(cpu, (unsigned long)stack, | ||
130 | &used, id); | ||
131 | if (*stack_end) | ||
132 | return STACK_IS_EXCEPTION; | ||
133 | |||
134 | *stack_end = (unsigned long *)per_cpu(irq_stack_ptr, cpu); | ||
135 | if (!*stack_end) | ||
136 | return STACK_IS_UNKNOWN; | ||
137 | |||
138 | irq_stack = *stack_end - irq_stack_size; | ||
139 | |||
140 | if (in_irq_stack(stack, irq_stack, *stack_end)) | ||
141 | return STACK_IS_IRQ; | ||
142 | |||
143 | return STACK_IS_UNKNOWN; | ||
144 | } | ||
145 | |||
107 | /* | 146 | /* |
108 | * x86-64 can have up to three kernel stacks: | 147 | * x86-64 can have up to three kernel stacks: |
109 | * process stack | 148 | * process stack |
@@ -116,12 +155,11 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, | |||
116 | const struct stacktrace_ops *ops, void *data) | 155 | const struct stacktrace_ops *ops, void *data) |
117 | { | 156 | { |
118 | const unsigned cpu = get_cpu(); | 157 | const unsigned cpu = get_cpu(); |
119 | unsigned long *irq_stack_end = | ||
120 | (unsigned long *)per_cpu(irq_stack_ptr, cpu); | ||
121 | unsigned used = 0; | ||
122 | struct thread_info *tinfo; | 158 | struct thread_info *tinfo; |
123 | int graph = 0; | 159 | unsigned long *irq_stack; |
124 | unsigned long dummy; | 160 | unsigned long dummy; |
161 | int graph = 0; | ||
162 | int done = 0; | ||
125 | 163 | ||
126 | if (!task) | 164 | if (!task) |
127 | task = current; | 165 | task = current; |
@@ -143,49 +181,60 @@ void dump_trace(struct task_struct *task, struct pt_regs *regs, | |||
143 | * exceptions | 181 | * exceptions |
144 | */ | 182 | */ |
145 | tinfo = task_thread_info(task); | 183 | tinfo = task_thread_info(task); |
146 | for (;;) { | 184 | while (!done) { |
185 | unsigned long *stack_end; | ||
186 | enum stack_type stype; | ||
147 | char *id; | 187 | char *id; |
148 | unsigned long *estack_end; | ||
149 | estack_end = in_exception_stack(cpu, (unsigned long)stack, | ||
150 | &used, &id); | ||
151 | 188 | ||
152 | if (estack_end) { | 189 | stype = analyze_stack(cpu, task, stack, &stack_end, &id); |
190 | |||
191 | /* Default finish unless specified to continue */ | ||
192 | done = 1; | ||
193 | |||
194 | switch (stype) { | ||
195 | |||
196 | /* Break out early if we are on the thread stack */ | ||
197 | case STACK_IS_NORMAL: | ||
198 | break; | ||
199 | |||
200 | case STACK_IS_EXCEPTION: | ||
201 | |||
153 | if (ops->stack(data, id) < 0) | 202 | if (ops->stack(data, id) < 0) |
154 | break; | 203 | break; |
155 | 204 | ||
156 | bp = ops->walk_stack(tinfo, stack, bp, ops, | 205 | bp = ops->walk_stack(tinfo, stack, bp, ops, |
157 | data, estack_end, &graph); | 206 | data, stack_end, &graph); |
158 | ops->stack(data, "<EOE>"); | 207 | ops->stack(data, "<EOE>"); |
159 | /* | 208 | /* |
160 | * We link to the next stack via the | 209 | * We link to the next stack via the |
161 | * second-to-last pointer (index -2 to end) in the | 210 | * second-to-last pointer (index -2 to end) in the |
162 | * exception stack: | 211 | * exception stack: |
163 | */ | 212 | */ |
164 | stack = (unsigned long *) estack_end[-2]; | 213 | stack = (unsigned long *) stack_end[-2]; |
165 | continue; | 214 | done = 0; |
166 | } | 215 | break; |
167 | if (irq_stack_end) { | 216 | |
168 | unsigned long *irq_stack; | 217 | case STACK_IS_IRQ: |
169 | irq_stack = irq_stack_end - | 218 | |
170 | (IRQ_STACK_SIZE - 64) / sizeof(*irq_stack); | 219 | if (ops->stack(data, "IRQ") < 0) |
171 | 220 | break; | |
172 | if (in_irq_stack(stack, irq_stack, irq_stack_end)) { | 221 | bp = ops->walk_stack(tinfo, stack, bp, |
173 | if (ops->stack(data, "IRQ") < 0) | 222 | ops, data, stack_end, &graph); |
174 | break; | 223 | /* |
175 | bp = ops->walk_stack(tinfo, stack, bp, | 224 | * We link to the next stack (which would be |
176 | ops, data, irq_stack_end, &graph); | 225 | * the process stack normally) the last |
177 | /* | 226 | * pointer (index -1 to end) in the IRQ stack: |
178 | * We link to the next stack (which would be | 227 | */ |
179 | * the process stack normally) the last | 228 | stack = (unsigned long *) (stack_end[-1]); |
180 | * pointer (index -1 to end) in the IRQ stack: | 229 | irq_stack = stack_end - irq_stack_size; |
181 | */ | 230 | ops->stack(data, "EOI"); |
182 | stack = (unsigned long *) (irq_stack_end[-1]); | 231 | done = 0; |
183 | irq_stack_end = NULL; | 232 | break; |
184 | ops->stack(data, "EOI"); | 233 | |
185 | continue; | 234 | case STACK_IS_UNKNOWN: |
186 | } | 235 | ops->stack(data, "UNK"); |
236 | break; | ||
187 | } | 237 | } |
188 | break; | ||
189 | } | 238 | } |
190 | 239 | ||
191 | /* | 240 | /* |
diff --git a/arch/x86/kernel/early-quirks.c b/arch/x86/kernel/early-quirks.c index bc4a088f9023..6d7d5a1260a6 100644 --- a/arch/x86/kernel/early-quirks.c +++ b/arch/x86/kernel/early-quirks.c | |||
@@ -203,18 +203,15 @@ static void __init intel_remapping_check(int num, int slot, int func) | |||
203 | revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID); | 203 | revision = read_pci_config_byte(num, slot, func, PCI_REVISION_ID); |
204 | 204 | ||
205 | /* | 205 | /* |
206 | * Revision 13 of all triggering devices id in this quirk have | 206 | * Revision <= 13 of all triggering devices id in this quirk |
207 | * a problem draining interrupts when irq remapping is enabled, | 207 | * have a problem draining interrupts when irq remapping is |
208 | * and should be flagged as broken. Additionally revisions 0x12 | 208 | * enabled, and should be flagged as broken. Additionally |
209 | * and 0x22 of device id 0x3405 has this problem. | 209 | * revision 0x22 of device id 0x3405 has this problem. |
210 | */ | 210 | */ |
211 | if (revision == 0x13) | 211 | if (revision <= 0x13) |
212 | set_irq_remapping_broken(); | 212 | set_irq_remapping_broken(); |
213 | else if ((device == 0x3405) && | 213 | else if (device == 0x3405 && revision == 0x22) |
214 | ((revision == 0x12) || | ||
215 | (revision == 0x22))) | ||
216 | set_irq_remapping_broken(); | 214 | set_irq_remapping_broken(); |
217 | |||
218 | } | 215 | } |
219 | 216 | ||
220 | /* | 217 | /* |
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index da85a8e830a1..014618dbaa7b 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
@@ -521,7 +521,7 @@ static int hpet_setup_irq(struct hpet_dev *dev) | |||
521 | { | 521 | { |
522 | 522 | ||
523 | if (request_irq(dev->irq, hpet_interrupt_handler, | 523 | if (request_irq(dev->irq, hpet_interrupt_handler, |
524 | IRQF_TIMER | IRQF_DISABLED | IRQF_NOBALANCING, | 524 | IRQF_TIMER | IRQF_NOBALANCING, |
525 | dev->name, dev)) | 525 | dev->name, dev)) |
526 | return -1; | 526 | return -1; |
527 | 527 | ||
@@ -699,7 +699,7 @@ static int hpet_cpuhp_notify(struct notifier_block *n, | |||
699 | /* FIXME: add schedule_work_on() */ | 699 | /* FIXME: add schedule_work_on() */ |
700 | schedule_delayed_work_on(cpu, &work.work, 0); | 700 | schedule_delayed_work_on(cpu, &work.work, 0); |
701 | wait_for_completion(&work.complete); | 701 | wait_for_completion(&work.complete); |
702 | destroy_timer_on_stack(&work.work.timer); | 702 | destroy_delayed_work_on_stack(&work.work); |
703 | break; | 703 | break; |
704 | case CPU_DEAD: | 704 | case CPU_DEAD: |
705 | if (hdev) { | 705 | if (hdev) { |
diff --git a/arch/x86/kernel/irq.c b/arch/x86/kernel/irq.c index d99f31d9a750..42805fac0092 100644 --- a/arch/x86/kernel/irq.c +++ b/arch/x86/kernel/irq.c | |||
@@ -125,6 +125,12 @@ int arch_show_interrupts(struct seq_file *p, int prec) | |||
125 | seq_printf(p, "%10u ", per_cpu(mce_poll_count, j)); | 125 | seq_printf(p, "%10u ", per_cpu(mce_poll_count, j)); |
126 | seq_printf(p, " Machine check polls\n"); | 126 | seq_printf(p, " Machine check polls\n"); |
127 | #endif | 127 | #endif |
128 | #if defined(CONFIG_HYPERV) || defined(CONFIG_XEN) | ||
129 | seq_printf(p, "%*s: ", prec, "THR"); | ||
130 | for_each_online_cpu(j) | ||
131 | seq_printf(p, "%10u ", irq_stats(j)->irq_hv_callback_count); | ||
132 | seq_printf(p, " Hypervisor callback interrupts\n"); | ||
133 | #endif | ||
128 | seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count)); | 134 | seq_printf(p, "%*s: %10u\n", prec, "ERR", atomic_read(&irq_err_count)); |
129 | #if defined(CONFIG_X86_IO_APIC) | 135 | #if defined(CONFIG_X86_IO_APIC) |
130 | seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); | 136 | seq_printf(p, "%*s: %10u\n", prec, "MIS", atomic_read(&irq_mis_count)); |
diff --git a/arch/x86/kernel/irq_32.c b/arch/x86/kernel/irq_32.c index d7fcbedc9c43..63ce838e5a54 100644 --- a/arch/x86/kernel/irq_32.c +++ b/arch/x86/kernel/irq_32.c | |||
@@ -55,16 +55,8 @@ static inline int check_stack_overflow(void) { return 0; } | |||
55 | static inline void print_stack_overflow(void) { } | 55 | static inline void print_stack_overflow(void) { } |
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | /* | 58 | DEFINE_PER_CPU(struct irq_stack *, hardirq_stack); |
59 | * per-CPU IRQ handling contexts (thread information and stack) | 59 | DEFINE_PER_CPU(struct irq_stack *, softirq_stack); |
60 | */ | ||
61 | union irq_ctx { | ||
62 | struct thread_info tinfo; | ||
63 | u32 stack[THREAD_SIZE/sizeof(u32)]; | ||
64 | } __attribute__((aligned(THREAD_SIZE))); | ||
65 | |||
66 | static DEFINE_PER_CPU(union irq_ctx *, hardirq_ctx); | ||
67 | static DEFINE_PER_CPU(union irq_ctx *, softirq_ctx); | ||
68 | 60 | ||
69 | static void call_on_stack(void *func, void *stack) | 61 | static void call_on_stack(void *func, void *stack) |
70 | { | 62 | { |
@@ -77,14 +69,26 @@ static void call_on_stack(void *func, void *stack) | |||
77 | : "memory", "cc", "edx", "ecx", "eax"); | 69 | : "memory", "cc", "edx", "ecx", "eax"); |
78 | } | 70 | } |
79 | 71 | ||
72 | /* how to get the current stack pointer from C */ | ||
73 | #define current_stack_pointer ({ \ | ||
74 | unsigned long sp; \ | ||
75 | asm("mov %%esp,%0" : "=g" (sp)); \ | ||
76 | sp; \ | ||
77 | }) | ||
78 | |||
79 | static inline void *current_stack(void) | ||
80 | { | ||
81 | return (void *)(current_stack_pointer & ~(THREAD_SIZE - 1)); | ||
82 | } | ||
83 | |||
80 | static inline int | 84 | static inline int |
81 | execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) | 85 | execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) |
82 | { | 86 | { |
83 | union irq_ctx *curctx, *irqctx; | 87 | struct irq_stack *curstk, *irqstk; |
84 | u32 *isp, arg1, arg2; | 88 | u32 *isp, *prev_esp, arg1, arg2; |
85 | 89 | ||
86 | curctx = (union irq_ctx *) current_thread_info(); | 90 | curstk = (struct irq_stack *) current_stack(); |
87 | irqctx = __this_cpu_read(hardirq_ctx); | 91 | irqstk = __this_cpu_read(hardirq_stack); |
88 | 92 | ||
89 | /* | 93 | /* |
90 | * this is where we switch to the IRQ stack. However, if we are | 94 | * this is where we switch to the IRQ stack. However, if we are |
@@ -92,13 +96,14 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) | |||
92 | * handler) we can't do that and just have to keep using the | 96 | * handler) we can't do that and just have to keep using the |
93 | * current stack (which is the irq stack already after all) | 97 | * current stack (which is the irq stack already after all) |
94 | */ | 98 | */ |
95 | if (unlikely(curctx == irqctx)) | 99 | if (unlikely(curstk == irqstk)) |
96 | return 0; | 100 | return 0; |
97 | 101 | ||
98 | /* build the stack frame on the IRQ stack */ | 102 | isp = (u32 *) ((char *)irqstk + sizeof(*irqstk)); |
99 | isp = (u32 *) ((char *)irqctx + sizeof(*irqctx)); | 103 | |
100 | irqctx->tinfo.task = curctx->tinfo.task; | 104 | /* Save the next esp at the bottom of the stack */ |
101 | irqctx->tinfo.previous_esp = current_stack_pointer; | 105 | prev_esp = (u32 *)irqstk; |
106 | *prev_esp = current_stack_pointer; | ||
102 | 107 | ||
103 | if (unlikely(overflow)) | 108 | if (unlikely(overflow)) |
104 | call_on_stack(print_stack_overflow, isp); | 109 | call_on_stack(print_stack_overflow, isp); |
@@ -118,46 +123,40 @@ execute_on_irq_stack(int overflow, struct irq_desc *desc, int irq) | |||
118 | */ | 123 | */ |
119 | void irq_ctx_init(int cpu) | 124 | void irq_ctx_init(int cpu) |
120 | { | 125 | { |
121 | union irq_ctx *irqctx; | 126 | struct irq_stack *irqstk; |
122 | 127 | ||
123 | if (per_cpu(hardirq_ctx, cpu)) | 128 | if (per_cpu(hardirq_stack, cpu)) |
124 | return; | 129 | return; |
125 | 130 | ||
126 | irqctx = page_address(alloc_pages_node(cpu_to_node(cpu), | 131 | irqstk = page_address(alloc_pages_node(cpu_to_node(cpu), |
127 | THREADINFO_GFP, | 132 | THREADINFO_GFP, |
128 | THREAD_SIZE_ORDER)); | 133 | THREAD_SIZE_ORDER)); |
129 | memset(&irqctx->tinfo, 0, sizeof(struct thread_info)); | 134 | per_cpu(hardirq_stack, cpu) = irqstk; |
130 | irqctx->tinfo.cpu = cpu; | ||
131 | irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); | ||
132 | |||
133 | per_cpu(hardirq_ctx, cpu) = irqctx; | ||
134 | 135 | ||
135 | irqctx = page_address(alloc_pages_node(cpu_to_node(cpu), | 136 | irqstk = page_address(alloc_pages_node(cpu_to_node(cpu), |
136 | THREADINFO_GFP, | 137 | THREADINFO_GFP, |
137 | THREAD_SIZE_ORDER)); | 138 | THREAD_SIZE_ORDER)); |
138 | memset(&irqctx->tinfo, 0, sizeof(struct thread_info)); | 139 | per_cpu(softirq_stack, cpu) = irqstk; |
139 | irqctx->tinfo.cpu = cpu; | ||
140 | irqctx->tinfo.addr_limit = MAKE_MM_SEG(0); | ||
141 | |||
142 | per_cpu(softirq_ctx, cpu) = irqctx; | ||
143 | 140 | ||
144 | printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n", | 141 | printk(KERN_DEBUG "CPU %u irqstacks, hard=%p soft=%p\n", |
145 | cpu, per_cpu(hardirq_ctx, cpu), per_cpu(softirq_ctx, cpu)); | 142 | cpu, per_cpu(hardirq_stack, cpu), per_cpu(softirq_stack, cpu)); |
146 | } | 143 | } |
147 | 144 | ||
148 | void do_softirq_own_stack(void) | 145 | void do_softirq_own_stack(void) |
149 | { | 146 | { |
150 | struct thread_info *curctx; | 147 | struct thread_info *curstk; |
151 | union irq_ctx *irqctx; | 148 | struct irq_stack *irqstk; |
152 | u32 *isp; | 149 | u32 *isp, *prev_esp; |
153 | 150 | ||
154 | curctx = current_thread_info(); | 151 | curstk = current_stack(); |
155 | irqctx = __this_cpu_read(softirq_ctx); | 152 | irqstk = __this_cpu_read(softirq_stack); |
156 | irqctx->tinfo.task = curctx->task; | ||
157 | irqctx->tinfo.previous_esp = current_stack_pointer; | ||
158 | 153 | ||
159 | /* build the stack frame on the softirq stack */ | 154 | /* build the stack frame on the softirq stack */ |
160 | isp = (u32 *) ((char *)irqctx + sizeof(*irqctx)); | 155 | isp = (u32 *) ((char *)irqstk + sizeof(*irqstk)); |
156 | |||
157 | /* Push the previous esp onto the stack */ | ||
158 | prev_esp = (u32 *)irqstk; | ||
159 | *prev_esp = current_stack_pointer; | ||
161 | 160 | ||
162 | call_on_stack(__do_softirq, isp); | 161 | call_on_stack(__do_softirq, isp); |
163 | } | 162 | } |
diff --git a/arch/x86/kernel/process_32.c b/arch/x86/kernel/process_32.c index 0de43e98ce08..7bc86bbe7485 100644 --- a/arch/x86/kernel/process_32.c +++ b/arch/x86/kernel/process_32.c | |||
@@ -314,6 +314,10 @@ __switch_to(struct task_struct *prev_p, struct task_struct *next_p) | |||
314 | */ | 314 | */ |
315 | arch_end_context_switch(next_p); | 315 | arch_end_context_switch(next_p); |
316 | 316 | ||
317 | this_cpu_write(kernel_stack, | ||
318 | (unsigned long)task_stack_page(next_p) + | ||
319 | THREAD_SIZE - KERNEL_STACK_OFFSET); | ||
320 | |||
317 | /* | 321 | /* |
318 | * Restore %gs if needed (which is common) | 322 | * Restore %gs if needed (which is common) |
319 | */ | 323 | */ |
diff --git a/arch/x86/kernel/ptrace.c b/arch/x86/kernel/ptrace.c index 7461f50d5bb1..678c0ada3b3c 100644 --- a/arch/x86/kernel/ptrace.c +++ b/arch/x86/kernel/ptrace.c | |||
@@ -184,14 +184,14 @@ unsigned long kernel_stack_pointer(struct pt_regs *regs) | |||
184 | { | 184 | { |
185 | unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1); | 185 | unsigned long context = (unsigned long)regs & ~(THREAD_SIZE - 1); |
186 | unsigned long sp = (unsigned long)®s->sp; | 186 | unsigned long sp = (unsigned long)®s->sp; |
187 | struct thread_info *tinfo; | 187 | u32 *prev_esp; |
188 | 188 | ||
189 | if (context == (sp & ~(THREAD_SIZE - 1))) | 189 | if (context == (sp & ~(THREAD_SIZE - 1))) |
190 | return sp; | 190 | return sp; |
191 | 191 | ||
192 | tinfo = (struct thread_info *)context; | 192 | prev_esp = (u32 *)(context); |
193 | if (tinfo->previous_esp) | 193 | if (prev_esp) |
194 | return tinfo->previous_esp; | 194 | return (unsigned long)prev_esp; |
195 | 195 | ||
196 | return (unsigned long)regs; | 196 | return (unsigned long)regs; |
197 | } | 197 | } |
diff --git a/arch/x86/kernel/reboot.c b/arch/x86/kernel/reboot.c index c752cb43e52f..654b46574b91 100644 --- a/arch/x86/kernel/reboot.c +++ b/arch/x86/kernel/reboot.c | |||
@@ -464,9 +464,12 @@ void __attribute__((weak)) mach_reboot_fixups(void) | |||
464 | * 2) If still alive, write to the keyboard controller | 464 | * 2) If still alive, write to the keyboard controller |
465 | * 3) If still alive, write to the ACPI reboot register again | 465 | * 3) If still alive, write to the ACPI reboot register again |
466 | * 4) If still alive, write to the keyboard controller again | 466 | * 4) If still alive, write to the keyboard controller again |
467 | * 5) If still alive, call the EFI runtime service to reboot | ||
468 | * 6) If still alive, write to the PCI IO port 0xCF9 to reboot | ||
469 | * 7) If still alive, inform BIOS to do a proper reboot | ||
467 | * | 470 | * |
468 | * If the machine is still alive at this stage, it gives up. We default to | 471 | * If the machine is still alive at this stage, it gives up. We default to |
469 | * following the same pattern, except that if we're still alive after (4) we'll | 472 | * following the same pattern, except that if we're still alive after (7) we'll |
470 | * try to force a triple fault and then cycle between hitting the keyboard | 473 | * try to force a triple fault and then cycle between hitting the keyboard |
471 | * controller and doing that | 474 | * controller and doing that |
472 | */ | 475 | */ |
@@ -502,7 +505,7 @@ static void native_machine_emergency_restart(void) | |||
502 | attempt = 1; | 505 | attempt = 1; |
503 | reboot_type = BOOT_ACPI; | 506 | reboot_type = BOOT_ACPI; |
504 | } else { | 507 | } else { |
505 | reboot_type = BOOT_TRIPLE; | 508 | reboot_type = BOOT_EFI; |
506 | } | 509 | } |
507 | break; | 510 | break; |
508 | 511 | ||
@@ -510,13 +513,15 @@ static void native_machine_emergency_restart(void) | |||
510 | load_idt(&no_idt); | 513 | load_idt(&no_idt); |
511 | __asm__ __volatile__("int3"); | 514 | __asm__ __volatile__("int3"); |
512 | 515 | ||
516 | /* We're probably dead after this, but... */ | ||
513 | reboot_type = BOOT_KBD; | 517 | reboot_type = BOOT_KBD; |
514 | break; | 518 | break; |
515 | 519 | ||
516 | case BOOT_BIOS: | 520 | case BOOT_BIOS: |
517 | machine_real_restart(MRR_BIOS); | 521 | machine_real_restart(MRR_BIOS); |
518 | 522 | ||
519 | reboot_type = BOOT_KBD; | 523 | /* We're probably dead after this, but... */ |
524 | reboot_type = BOOT_TRIPLE; | ||
520 | break; | 525 | break; |
521 | 526 | ||
522 | case BOOT_ACPI: | 527 | case BOOT_ACPI: |
@@ -530,7 +535,7 @@ static void native_machine_emergency_restart(void) | |||
530 | EFI_RESET_WARM : | 535 | EFI_RESET_WARM : |
531 | EFI_RESET_COLD, | 536 | EFI_RESET_COLD, |
532 | EFI_SUCCESS, 0, NULL); | 537 | EFI_SUCCESS, 0, NULL); |
533 | reboot_type = BOOT_KBD; | 538 | reboot_type = BOOT_CF9_COND; |
534 | break; | 539 | break; |
535 | 540 | ||
536 | case BOOT_CF9: | 541 | case BOOT_CF9: |
@@ -548,7 +553,7 @@ static void native_machine_emergency_restart(void) | |||
548 | outb(cf9|reboot_code, 0xcf9); | 553 | outb(cf9|reboot_code, 0xcf9); |
549 | udelay(50); | 554 | udelay(50); |
550 | } | 555 | } |
551 | reboot_type = BOOT_KBD; | 556 | reboot_type = BOOT_BIOS; |
552 | break; | 557 | break; |
553 | } | 558 | } |
554 | } | 559 | } |
diff --git a/arch/x86/kernel/smpboot.c b/arch/x86/kernel/smpboot.c index 60179ec39d4c..34826934d4a7 100644 --- a/arch/x86/kernel/smpboot.c +++ b/arch/x86/kernel/smpboot.c | |||
@@ -766,10 +766,10 @@ static int do_boot_cpu(int apicid, int cpu, struct task_struct *idle) | |||
766 | #else | 766 | #else |
767 | clear_tsk_thread_flag(idle, TIF_FORK); | 767 | clear_tsk_thread_flag(idle, TIF_FORK); |
768 | initial_gs = per_cpu_offset(cpu); | 768 | initial_gs = per_cpu_offset(cpu); |
769 | #endif | ||
769 | per_cpu(kernel_stack, cpu) = | 770 | per_cpu(kernel_stack, cpu) = |
770 | (unsigned long)task_stack_page(idle) - | 771 | (unsigned long)task_stack_page(idle) - |
771 | KERNEL_STACK_OFFSET + THREAD_SIZE; | 772 | KERNEL_STACK_OFFSET + THREAD_SIZE; |
772 | #endif | ||
773 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); | 773 | early_gdt_descr.address = (unsigned long)get_cpu_gdt_table(cpu); |
774 | initial_code = (unsigned long)start_secondary; | 774 | initial_code = (unsigned long)start_secondary; |
775 | stack_start = idle->thread.sp; | 775 | stack_start = idle->thread.sp; |
@@ -1387,7 +1387,7 @@ static inline void mwait_play_dead(void) | |||
1387 | 1387 | ||
1388 | if (!this_cpu_has(X86_FEATURE_MWAIT)) | 1388 | if (!this_cpu_has(X86_FEATURE_MWAIT)) |
1389 | return; | 1389 | return; |
1390 | if (!this_cpu_has(X86_FEATURE_CLFLSH)) | 1390 | if (!this_cpu_has(X86_FEATURE_CLFLUSH)) |
1391 | return; | 1391 | return; |
1392 | if (__this_cpu_read(cpu_info.cpuid_level) < CPUID_MWAIT_LEAF) | 1392 | if (__this_cpu_read(cpu_info.cpuid_level) < CPUID_MWAIT_LEAF) |
1393 | return; | 1393 | return; |
diff --git a/arch/x86/kernel/time.c b/arch/x86/kernel/time.c index 6ec91c00d84d..bf7ef5ce29df 100644 --- a/arch/x86/kernel/time.c +++ b/arch/x86/kernel/time.c | |||
@@ -62,7 +62,7 @@ static irqreturn_t timer_interrupt(int irq, void *dev_id) | |||
62 | 62 | ||
63 | static struct irqaction irq0 = { | 63 | static struct irqaction irq0 = { |
64 | .handler = timer_interrupt, | 64 | .handler = timer_interrupt, |
65 | .flags = IRQF_DISABLED | IRQF_NOBALANCING | IRQF_IRQPOLL | IRQF_TIMER, | 65 | .flags = IRQF_NOBALANCING | IRQF_IRQPOLL | IRQF_TIMER, |
66 | .name = "timer" | 66 | .name = "timer" |
67 | }; | 67 | }; |
68 | 68 | ||