aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r--arch/i386/kernel/acpi/boot.c57
-rw-r--r--arch/i386/kernel/apic.c2
-rw-r--r--arch/i386/kernel/apm.c5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/gx-suspmod.c2
-rw-r--r--arch/i386/kernel/io_apic.c2
-rw-r--r--arch/i386/kernel/kprobes.c133
-rw-r--r--arch/i386/kernel/process.c29
-rw-r--r--arch/i386/kernel/syscall_table.S2
-rw-r--r--arch/i386/kernel/time.c5
-rw-r--r--arch/i386/kernel/timers/timer_cyclone.c4
-rw-r--r--arch/i386/kernel/timers/timer_pit.c4
-rw-r--r--arch/i386/kernel/timers/timer_tsc.c3
12 files changed, 163 insertions, 85 deletions
diff --git a/arch/i386/kernel/acpi/boot.c b/arch/i386/kernel/acpi/boot.c
index 9f63ae0f404b..b7808a89d945 100644
--- a/arch/i386/kernel/acpi/boot.c
+++ b/arch/i386/kernel/acpi/boot.c
@@ -159,9 +159,15 @@ char *__acpi_map_table(unsigned long phys, unsigned long size)
159#endif 159#endif
160 160
161#ifdef CONFIG_PCI_MMCONFIG 161#ifdef CONFIG_PCI_MMCONFIG
162static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size) 162/* The physical address of the MMCONFIG aperture. Set from ACPI tables. */
163struct acpi_table_mcfg_config *pci_mmcfg_config;
164int pci_mmcfg_config_num;
165
166int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
163{ 167{
164 struct acpi_table_mcfg *mcfg; 168 struct acpi_table_mcfg *mcfg;
169 unsigned long i;
170 int config_size;
165 171
166 if (!phys_addr || !size) 172 if (!phys_addr || !size)
167 return -EINVAL; 173 return -EINVAL;
@@ -172,18 +178,38 @@ static int __init acpi_parse_mcfg(unsigned long phys_addr, unsigned long size)
172 return -ENODEV; 178 return -ENODEV;
173 } 179 }
174 180
175 if (mcfg->base_reserved) { 181 /* how many config structures do we have */
176 printk(KERN_ERR PREFIX "MMCONFIG not in low 4GB of memory\n"); 182 pci_mmcfg_config_num = 0;
183 i = size - sizeof(struct acpi_table_mcfg);
184 while (i >= sizeof(struct acpi_table_mcfg_config)) {
185 ++pci_mmcfg_config_num;
186 i -= sizeof(struct acpi_table_mcfg_config);
187 };
188 if (pci_mmcfg_config_num == 0) {
189 printk(KERN_ERR PREFIX "MMCONFIG has no entries\n");
177 return -ENODEV; 190 return -ENODEV;
178 } 191 }
179 192
180 pci_mmcfg_base_addr = mcfg->base_address; 193 config_size = pci_mmcfg_config_num * sizeof(*pci_mmcfg_config);
194 pci_mmcfg_config = kmalloc(config_size, GFP_KERNEL);
195 if (!pci_mmcfg_config) {
196 printk(KERN_WARNING PREFIX
197 "No memory for MCFG config tables\n");
198 return -ENOMEM;
199 }
200
201 memcpy(pci_mmcfg_config, &mcfg->config, config_size);
202 for (i = 0; i < pci_mmcfg_config_num; ++i) {
203 if (mcfg->config[i].base_reserved) {
204 printk(KERN_ERR PREFIX
205 "MMCONFIG not in low 4GB of memory\n");
206 return -ENODEV;
207 }
208 }
181 209
182 return 0; 210 return 0;
183} 211}
184#else 212#endif /* CONFIG_PCI_MMCONFIG */
185#define acpi_parse_mcfg NULL
186#endif /* !CONFIG_PCI_MMCONFIG */
187 213
188#ifdef CONFIG_X86_LOCAL_APIC 214#ifdef CONFIG_X86_LOCAL_APIC
189static int __init 215static int __init
@@ -507,6 +533,22 @@ acpi_unmap_lsapic(int cpu)
507EXPORT_SYMBOL(acpi_unmap_lsapic); 533EXPORT_SYMBOL(acpi_unmap_lsapic);
508#endif /* CONFIG_ACPI_HOTPLUG_CPU */ 534#endif /* CONFIG_ACPI_HOTPLUG_CPU */
509 535
536int
537acpi_register_ioapic(acpi_handle handle, u64 phys_addr, u32 gsi_base)
538{
539 /* TBD */
540 return -EINVAL;
541}
542EXPORT_SYMBOL(acpi_register_ioapic);
543
544int
545acpi_unregister_ioapic(acpi_handle handle, u32 gsi_base)
546{
547 /* TBD */
548 return -EINVAL;
549}
550EXPORT_SYMBOL(acpi_unregister_ioapic);
551
510static unsigned long __init 552static unsigned long __init
511acpi_scan_rsdp ( 553acpi_scan_rsdp (
512 unsigned long start, 554 unsigned long start,
@@ -1123,7 +1165,6 @@ int __init acpi_boot_init(void)
1123 acpi_process_madt(); 1165 acpi_process_madt();
1124 1166
1125 acpi_table_parse(ACPI_HPET, acpi_parse_hpet); 1167 acpi_table_parse(ACPI_HPET, acpi_parse_hpet);
1126 acpi_table_parse(ACPI_MCFG, acpi_parse_mcfg);
1127 1168
1128 return 0; 1169 return 0;
1129} 1170}
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 93df90bbb87e..bd1dbf3bd223 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -35,6 +35,7 @@
35#include <asm/desc.h> 35#include <asm/desc.h>
36#include <asm/arch_hooks.h> 36#include <asm/arch_hooks.h>
37#include <asm/hpet.h> 37#include <asm/hpet.h>
38#include <asm/i8253.h>
38 39
39#include <mach_apic.h> 40#include <mach_apic.h>
40 41
@@ -879,7 +880,6 @@ fake_ioapic_page:
879 */ 880 */
880static unsigned int __devinit get_8254_timer_count(void) 881static unsigned int __devinit get_8254_timer_count(void)
881{ 882{
882 extern spinlock_t i8253_lock;
883 unsigned long flags; 883 unsigned long flags;
884 884
885 unsigned int count; 885 unsigned int count;
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index d48ce9290963..064211d5f41b 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -228,10 +228,10 @@
228#include <asm/system.h> 228#include <asm/system.h>
229#include <asm/uaccess.h> 229#include <asm/uaccess.h>
230#include <asm/desc.h> 230#include <asm/desc.h>
231#include <asm/i8253.h>
231 232
232#include "io_ports.h" 233#include "io_ports.h"
233 234
234extern spinlock_t i8253_lock;
235extern unsigned long get_cmos_time(void); 235extern unsigned long get_cmos_time(void);
236extern void machine_real_restart(unsigned char *, int); 236extern void machine_real_restart(unsigned char *, int);
237 237
@@ -1168,8 +1168,7 @@ static void get_time_diff(void)
1168static void reinit_timer(void) 1168static void reinit_timer(void)
1169{ 1169{
1170#ifdef INIT_TIMER_AFTER_SUSPEND 1170#ifdef INIT_TIMER_AFTER_SUSPEND
1171 unsigned long flags; 1171 unsigned long flags;
1172 extern spinlock_t i8253_lock;
1173 1172
1174 spin_lock_irqsave(&i8253_lock, flags); 1173 spin_lock_irqsave(&i8253_lock, flags);
1175 /* set the clock to 100 Hz */ 1174 /* set the clock to 100 Hz */
diff --git a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
index 1a49adb1f4a6..e86ea486c311 100644
--- a/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
+++ b/arch/i386/kernel/cpu/cpufreq/gx-suspmod.c
@@ -190,7 +190,7 @@ static __init struct pci_dev *gx_detect_chipset(void)
190 190
191 /* detect which companion chip is used */ 191 /* detect which companion chip is used */
192 while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) { 192 while ((gx_pci = pci_get_device(PCI_ANY_ID, PCI_ANY_ID, gx_pci)) != NULL) {
193 if ((pci_match_device (gx_chipset_tbl, gx_pci)) != NULL) { 193 if ((pci_match_id(gx_chipset_tbl, gx_pci)) != NULL) {
194 return gx_pci; 194 return gx_pci;
195 } 195 }
196 } 196 }
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 35eb8e29c485..6578f40bd501 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -37,6 +37,7 @@
37#include <asm/smp.h> 37#include <asm/smp.h>
38#include <asm/desc.h> 38#include <asm/desc.h>
39#include <asm/timer.h> 39#include <asm/timer.h>
40#include <asm/i8259.h>
40 41
41#include <mach_apic.h> 42#include <mach_apic.h>
42 43
@@ -1566,7 +1567,6 @@ void print_all_local_APICs (void)
1566 1567
1567void /*__init*/ print_PIC(void) 1568void /*__init*/ print_PIC(void)
1568{ 1569{
1569 extern spinlock_t i8259A_lock;
1570 unsigned int v; 1570 unsigned int v;
1571 unsigned long flags; 1571 unsigned long flags;
1572 1572
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 3762f6b35ab2..a6d8c45961d3 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -127,48 +127,23 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
127 regs->eip = (unsigned long)&p->ainsn.insn; 127 regs->eip = (unsigned long)&p->ainsn.insn;
128} 128}
129 129
130struct task_struct *arch_get_kprobe_task(void *ptr)
131{
132 return ((struct thread_info *) (((unsigned long) ptr) &
133 (~(THREAD_SIZE -1))))->task;
134}
135
136void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs) 130void arch_prepare_kretprobe(struct kretprobe *rp, struct pt_regs *regs)
137{ 131{
138 unsigned long *sara = (unsigned long *)&regs->esp; 132 unsigned long *sara = (unsigned long *)&regs->esp;
139 struct kretprobe_instance *ri; 133 struct kretprobe_instance *ri;
140 static void *orig_ret_addr; 134
135 if ((ri = get_free_rp_inst(rp)) != NULL) {
136 ri->rp = rp;
137 ri->task = current;
138 ri->ret_addr = (kprobe_opcode_t *) *sara;
141 139
142 /*
143 * Save the return address when the return probe hits
144 * the first time, and use it to populate the (krprobe
145 * instance)->ret_addr for subsequent return probes at
146 * the same addrress since stack address would have
147 * the kretprobe_trampoline by then.
148 */
149 if (((void*) *sara) != kretprobe_trampoline)
150 orig_ret_addr = (void*) *sara;
151
152 if ((ri = get_free_rp_inst(rp)) != NULL) {
153 ri->rp = rp;
154 ri->stack_addr = sara;
155 ri->ret_addr = orig_ret_addr;
156 add_rp_inst(ri);
157 /* Replace the return addr with trampoline addr */ 140 /* Replace the return addr with trampoline addr */
158 *sara = (unsigned long) &kretprobe_trampoline; 141 *sara = (unsigned long) &kretprobe_trampoline;
159 } else {
160 rp->nmissed++;
161 }
162}
163 142
164void arch_kprobe_flush_task(struct task_struct *tk) 143 add_rp_inst(ri);
165{ 144 } else {
166 struct kretprobe_instance *ri; 145 rp->nmissed++;
167 while ((ri = get_rp_inst_tsk(tk)) != NULL) { 146 }
168 *((unsigned long *)(ri->stack_addr)) =
169 (unsigned long) ri->ret_addr;
170 recycle_rp_inst(ri);
171 }
172} 147}
173 148
174/* 149/*
@@ -286,36 +261,59 @@ no_kprobe:
286 */ 261 */
287int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs) 262int trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
288{ 263{
289 struct task_struct *tsk; 264 struct kretprobe_instance *ri = NULL;
290 struct kretprobe_instance *ri; 265 struct hlist_head *head;
291 struct hlist_head *head; 266 struct hlist_node *node, *tmp;
292 struct hlist_node *node; 267 unsigned long orig_ret_address = 0;
293 unsigned long *sara = ((unsigned long *) &regs->esp) - 1; 268 unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
294
295 tsk = arch_get_kprobe_task(sara);
296 head = kretprobe_inst_table_head(tsk);
297
298 hlist_for_each_entry(ri, node, head, hlist) {
299 if (ri->stack_addr == sara && ri->rp) {
300 if (ri->rp->handler)
301 ri->rp->handler(ri, regs);
302 }
303 }
304 return 0;
305}
306 269
307void trampoline_post_handler(struct kprobe *p, struct pt_regs *regs, 270 head = kretprobe_inst_table_head(current);
308 unsigned long flags)
309{
310 struct kretprobe_instance *ri;
311 /* RA already popped */
312 unsigned long *sara = ((unsigned long *)&regs->esp) - 1;
313 271
314 while ((ri = get_rp_inst(sara))) { 272 /*
315 regs->eip = (unsigned long)ri->ret_addr; 273 * It is possible to have multiple instances associated with a given
274 * task either because an multiple functions in the call path
275 * have a return probe installed on them, and/or more then one return
276 * return probe was registered for a target function.
277 *
278 * We can handle this because:
279 * - instances are always inserted at the head of the list
280 * - when multiple return probes are registered for the same
281 * function, the first instance's ret_addr will point to the
282 * real return address, and all the rest will point to
283 * kretprobe_trampoline
284 */
285 hlist_for_each_entry_safe(ri, node, tmp, head, hlist) {
286 if (ri->task != current)
287 /* another task is sharing our hash bucket */
288 continue;
289
290 if (ri->rp && ri->rp->handler)
291 ri->rp->handler(ri, regs);
292
293 orig_ret_address = (unsigned long)ri->ret_addr;
316 recycle_rp_inst(ri); 294 recycle_rp_inst(ri);
295
296 if (orig_ret_address != trampoline_address)
297 /*
298 * This is the real return address. Any other
299 * instances associated with this task are for
300 * other calls deeper on the call stack
301 */
302 break;
317 } 303 }
318 regs->eflags &= ~TF_MASK; 304
305 BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
306 regs->eip = orig_ret_address;
307
308 unlock_kprobes();
309 preempt_enable_no_resched();
310
311 /*
312 * By returning a non-zero value, we are telling
313 * kprobe_handler() that we have handled unlocking
314 * and re-enabling preemption.
315 */
316 return 1;
319} 317}
320 318
321/* 319/*
@@ -403,8 +401,7 @@ static inline int post_kprobe_handler(struct pt_regs *regs)
403 current_kprobe->post_handler(current_kprobe, regs, 0); 401 current_kprobe->post_handler(current_kprobe, regs, 0);
404 } 402 }
405 403
406 if (current_kprobe->post_handler != trampoline_post_handler) 404 resume_execution(current_kprobe, regs);
407 resume_execution(current_kprobe, regs);
408 regs->eflags |= kprobe_saved_eflags; 405 regs->eflags |= kprobe_saved_eflags;
409 406
410 /*Restore back the original saved kprobes variables and continue. */ 407 /*Restore back the original saved kprobes variables and continue. */
@@ -534,3 +531,13 @@ int longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
534 } 531 }
535 return 0; 532 return 0;
536} 533}
534
535static struct kprobe trampoline_p = {
536 .addr = (kprobe_opcode_t *) &kretprobe_trampoline,
537 .pre_handler = trampoline_probe_handler
538};
539
540int __init arch_init_kprobes(void)
541{
542 return register_kprobe(&trampoline_p);
543}
diff --git a/arch/i386/kernel/process.c b/arch/i386/kernel/process.c
index 5f8cfa6b7940..ba243a4cc119 100644
--- a/arch/i386/kernel/process.c
+++ b/arch/i386/kernel/process.c
@@ -617,6 +617,33 @@ handle_io_bitmap(struct thread_struct *next, struct tss_struct *tss)
617} 617}
618 618
619/* 619/*
620 * This function selects if the context switch from prev to next
621 * has to tweak the TSC disable bit in the cr4.
622 */
623static inline void disable_tsc(struct task_struct *prev_p,
624 struct task_struct *next_p)
625{
626 struct thread_info *prev, *next;
627
628 /*
629 * gcc should eliminate the ->thread_info dereference if
630 * has_secure_computing returns 0 at compile time (SECCOMP=n).
631 */
632 prev = prev_p->thread_info;
633 next = next_p->thread_info;
634
635 if (has_secure_computing(prev) || has_secure_computing(next)) {
636 /* slow path here */
637 if (has_secure_computing(prev) &&
638 !has_secure_computing(next)) {
639 write_cr4(read_cr4() & ~X86_CR4_TSD);
640 } else if (!has_secure_computing(prev) &&
641 has_secure_computing(next))
642 write_cr4(read_cr4() | X86_CR4_TSD);
643 }
644}
645
646/*
620 * switch_to(x,yn) should switch tasks from x to y. 647 * switch_to(x,yn) should switch tasks from x to y.
621 * 648 *
622 * We fsave/fwait so that an exception goes off at the right time 649 * We fsave/fwait so that an exception goes off at the right time
@@ -695,6 +722,8 @@ struct task_struct fastcall * __switch_to(struct task_struct *prev_p, struct tas
695 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr)) 722 if (unlikely(prev->io_bitmap_ptr || next->io_bitmap_ptr))
696 handle_io_bitmap(next, tss); 723 handle_io_bitmap(next, tss);
697 724
725 disable_tsc(prev_p, next_p);
726
698 return prev_p; 727 return prev_p;
699} 728}
700 729
diff --git a/arch/i386/kernel/syscall_table.S b/arch/i386/kernel/syscall_table.S
index 442a6e937b19..3db9a04aec6e 100644
--- a/arch/i386/kernel/syscall_table.S
+++ b/arch/i386/kernel/syscall_table.S
@@ -289,3 +289,5 @@ ENTRY(sys_call_table)
289 .long sys_add_key 289 .long sys_add_key
290 .long sys_request_key 290 .long sys_request_key
291 .long sys_keyctl 291 .long sys_keyctl
292 .long sys_ioprio_set
293 .long sys_ioprio_get /* 290 */
diff --git a/arch/i386/kernel/time.c b/arch/i386/kernel/time.c
index e68d9fdb0759..2854c357377f 100644
--- a/arch/i386/kernel/time.c
+++ b/arch/i386/kernel/time.c
@@ -68,7 +68,8 @@
68 68
69#include "io_ports.h" 69#include "io_ports.h"
70 70
71extern spinlock_t i8259A_lock; 71#include <asm/i8259.h>
72
72int pit_latch_buggy; /* extern */ 73int pit_latch_buggy; /* extern */
73 74
74#include "do_timer.h" 75#include "do_timer.h"
@@ -85,6 +86,8 @@ extern unsigned long wall_jiffies;
85DEFINE_SPINLOCK(rtc_lock); 86DEFINE_SPINLOCK(rtc_lock);
86EXPORT_SYMBOL(rtc_lock); 87EXPORT_SYMBOL(rtc_lock);
87 88
89#include <asm/i8253.h>
90
88DEFINE_SPINLOCK(i8253_lock); 91DEFINE_SPINLOCK(i8253_lock);
89EXPORT_SYMBOL(i8253_lock); 92EXPORT_SYMBOL(i8253_lock);
90 93
diff --git a/arch/i386/kernel/timers/timer_cyclone.c b/arch/i386/kernel/timers/timer_cyclone.c
index f6f1206a11bb..13892a65c941 100644
--- a/arch/i386/kernel/timers/timer_cyclone.c
+++ b/arch/i386/kernel/timers/timer_cyclone.c
@@ -17,9 +17,9 @@
17#include <asm/io.h> 17#include <asm/io.h>
18#include <asm/pgtable.h> 18#include <asm/pgtable.h>
19#include <asm/fixmap.h> 19#include <asm/fixmap.h>
20#include "io_ports.h" 20#include <asm/i8253.h>
21 21
22extern spinlock_t i8253_lock; 22#include "io_ports.h"
23 23
24/* Number of usecs that the last interrupt was delayed */ 24/* Number of usecs that the last interrupt was delayed */
25static int delay_at_last_interrupt; 25static int delay_at_last_interrupt;
diff --git a/arch/i386/kernel/timers/timer_pit.c b/arch/i386/kernel/timers/timer_pit.c
index 967d5453cd0e..06de036a820c 100644
--- a/arch/i386/kernel/timers/timer_pit.c
+++ b/arch/i386/kernel/timers/timer_pit.c
@@ -15,9 +15,8 @@
15#include <asm/smp.h> 15#include <asm/smp.h>
16#include <asm/io.h> 16#include <asm/io.h>
17#include <asm/arch_hooks.h> 17#include <asm/arch_hooks.h>
18#include <asm/i8253.h>
18 19
19extern spinlock_t i8259A_lock;
20extern spinlock_t i8253_lock;
21#include "do_timer.h" 20#include "do_timer.h"
22#include "io_ports.h" 21#include "io_ports.h"
23 22
@@ -166,7 +165,6 @@ struct init_timer_opts __initdata timer_pit_init = {
166 165
167void setup_pit_timer(void) 166void setup_pit_timer(void)
168{ 167{
169 extern spinlock_t i8253_lock;
170 unsigned long flags; 168 unsigned long flags;
171 169
172 spin_lock_irqsave(&i8253_lock, flags); 170 spin_lock_irqsave(&i8253_lock, flags);
diff --git a/arch/i386/kernel/timers/timer_tsc.c b/arch/i386/kernel/timers/timer_tsc.c
index f46e625bab67..8f4e4d5bc560 100644
--- a/arch/i386/kernel/timers/timer_tsc.c
+++ b/arch/i386/kernel/timers/timer_tsc.c
@@ -24,6 +24,7 @@
24#include "mach_timer.h" 24#include "mach_timer.h"
25 25
26#include <asm/hpet.h> 26#include <asm/hpet.h>
27#include <asm/i8253.h>
27 28
28#ifdef CONFIG_HPET_TIMER 29#ifdef CONFIG_HPET_TIMER
29static unsigned long hpet_usec_quotient; 30static unsigned long hpet_usec_quotient;
@@ -35,8 +36,6 @@ static inline void cpufreq_delayed_get(void);
35 36
36int tsc_disable __devinitdata = 0; 37int tsc_disable __devinitdata = 0;
37 38
38extern spinlock_t i8253_lock;
39
40static int use_tsc; 39static int use_tsc;
41/* Number of usecs that the last interrupt was delayed */ 40/* Number of usecs that the last interrupt was delayed */
42static int delay_at_last_interrupt; 41static int delay_at_last_interrupt;