aboutsummaryrefslogtreecommitdiffstats
path: root/arch/i386/kernel
diff options
context:
space:
mode:
Diffstat (limited to 'arch/i386/kernel')
-rw-r--r--arch/i386/kernel/apic.c10
-rw-r--r--arch/i386/kernel/apm.c5
-rw-r--r--arch/i386/kernel/cpu/common.c5
-rw-r--r--arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c2
-rw-r--r--arch/i386/kernel/cpu/mcheck/k7.c2
-rw-r--r--arch/i386/kernel/cpu/mcheck/mce.c4
-rw-r--r--arch/i386/kernel/cpu/mcheck/p4.c4
-rw-r--r--arch/i386/kernel/cpu/mcheck/p5.c2
-rw-r--r--arch/i386/kernel/cpu/mcheck/p6.c2
-rw-r--r--arch/i386/kernel/cpu/mcheck/winchip.c2
-rw-r--r--arch/i386/kernel/kprobes.c180
-rw-r--r--arch/i386/kernel/ldt.c1
-rw-r--r--arch/i386/kernel/mca.c2
-rw-r--r--arch/i386/kernel/ptrace.c44
-rw-r--r--arch/i386/kernel/reboot_fixups.c3
-rw-r--r--arch/i386/kernel/scx200.c1
-rw-r--r--arch/i386/kernel/smpboot.c4
17 files changed, 123 insertions, 150 deletions
diff --git a/arch/i386/kernel/apic.c b/arch/i386/kernel/apic.c
index 7c724ffa08bb..496a2c9909fe 100644
--- a/arch/i386/kernel/apic.c
+++ b/arch/i386/kernel/apic.c
@@ -559,14 +559,20 @@ void __devinit setup_local_APIC(void)
559 * If Linux enabled the LAPIC against the BIOS default 559 * If Linux enabled the LAPIC against the BIOS default
560 * disable it down before re-entering the BIOS on shutdown. 560 * disable it down before re-entering the BIOS on shutdown.
561 * Otherwise the BIOS may get confused and not power-off. 561 * Otherwise the BIOS may get confused and not power-off.
562 * Additionally clear all LVT entries before disable_local_APIC
563 * for the case where Linux didn't enable the LAPIC.
562 */ 564 */
563void lapic_shutdown(void) 565void lapic_shutdown(void)
564{ 566{
565 if (!cpu_has_apic || !enabled_via_apicbase) 567 if (!cpu_has_apic)
566 return; 568 return;
567 569
568 local_irq_disable(); 570 local_irq_disable();
569 disable_local_APIC(); 571 clear_local_APIC();
572
573 if (enabled_via_apicbase)
574 disable_local_APIC();
575
570 local_irq_enable(); 576 local_irq_enable();
571} 577}
572 578
diff --git a/arch/i386/kernel/apm.c b/arch/i386/kernel/apm.c
index d2ef0c2aa93e..86e80c551478 100644
--- a/arch/i386/kernel/apm.c
+++ b/arch/i386/kernel/apm.c
@@ -447,8 +447,7 @@ static char * apm_event_name[] = {
447 "system standby resume", 447 "system standby resume",
448 "capabilities change" 448 "capabilities change"
449}; 449};
450#define NR_APM_EVENT_NAME \ 450#define NR_APM_EVENT_NAME ARRAY_SIZE(apm_event_name)
451 (sizeof(apm_event_name) / sizeof(apm_event_name[0]))
452 451
453typedef struct lookup_t { 452typedef struct lookup_t {
454 int key; 453 int key;
@@ -479,7 +478,7 @@ static const lookup_t error_table[] = {
479 { APM_NO_ERROR, "BIOS did not set a return code" }, 478 { APM_NO_ERROR, "BIOS did not set a return code" },
480 { APM_NOT_PRESENT, "No APM present" } 479 { APM_NOT_PRESENT, "No APM present" }
481}; 480};
482#define ERROR_COUNT (sizeof(error_table)/sizeof(lookup_t)) 481#define ERROR_COUNT ARRAY_SIZE(error_table)
483 482
484/** 483/**
485 * apm_error - display an APM error 484 * apm_error - display an APM error
diff --git a/arch/i386/kernel/cpu/common.c b/arch/i386/kernel/cpu/common.c
index 74145a33cb0f..c145fb30002e 100644
--- a/arch/i386/kernel/cpu/common.c
+++ b/arch/i386/kernel/cpu/common.c
@@ -30,8 +30,6 @@ static int disable_x86_serial_nr __devinitdata = 1;
30 30
31struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {}; 31struct cpu_dev * cpu_devs[X86_VENDOR_NUM] = {};
32 32
33extern void mcheck_init(struct cpuinfo_x86 *c);
34
35extern int disable_pse; 33extern int disable_pse;
36 34
37static void default_init(struct cpuinfo_x86 * c) 35static void default_init(struct cpuinfo_x86 * c)
@@ -429,9 +427,8 @@ void __devinit identify_cpu(struct cpuinfo_x86 *c)
429 } 427 }
430 428
431 /* Init Machine Check Exception if available. */ 429 /* Init Machine Check Exception if available. */
432#ifdef CONFIG_X86_MCE
433 mcheck_init(c); 430 mcheck_init(c);
434#endif 431
435 if (c == &boot_cpu_data) 432 if (c == &boot_cpu_data)
436 sysenter_setup(); 433 sysenter_setup();
437 enable_sep_cpu(); 434 enable_sep_cpu();
diff --git a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
index 1465974256c9..0ea010a7afb1 100644
--- a/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
+++ b/arch/i386/kernel/cpu/cpufreq/speedstep-centrino.c
@@ -67,7 +67,7 @@ static const struct cpu_id cpu_ids[] = {
67 [CPU_MP4HT_D0] = {15, 3, 4 }, 67 [CPU_MP4HT_D0] = {15, 3, 4 },
68 [CPU_MP4HT_E0] = {15, 4, 1 }, 68 [CPU_MP4HT_E0] = {15, 4, 1 },
69}; 69};
70#define N_IDS (sizeof(cpu_ids)/sizeof(cpu_ids[0])) 70#define N_IDS ARRAY_SIZE(cpu_ids)
71 71
72struct cpu_model 72struct cpu_model
73{ 73{
diff --git a/arch/i386/kernel/cpu/mcheck/k7.c b/arch/i386/kernel/cpu/mcheck/k7.c
index 7c6b9c73522f..fc5d5215e23d 100644
--- a/arch/i386/kernel/cpu/mcheck/k7.c
+++ b/arch/i386/kernel/cpu/mcheck/k7.c
@@ -68,7 +68,7 @@ static fastcall void k7_machine_check(struct pt_regs * regs, long error_code)
68 68
69 69
70/* AMD K7 machine check is Intel like */ 70/* AMD K7 machine check is Intel like */
71void __devinit amd_mcheck_init(struct cpuinfo_x86 *c) 71void amd_mcheck_init(struct cpuinfo_x86 *c)
72{ 72{
73 u32 l, h; 73 u32 l, h;
74 int i; 74 int i;
diff --git a/arch/i386/kernel/cpu/mcheck/mce.c b/arch/i386/kernel/cpu/mcheck/mce.c
index 2cf25d2ba0f1..6170af3c271a 100644
--- a/arch/i386/kernel/cpu/mcheck/mce.c
+++ b/arch/i386/kernel/cpu/mcheck/mce.c
@@ -16,7 +16,7 @@
16 16
17#include "mce.h" 17#include "mce.h"
18 18
19int mce_disabled __devinitdata = 0; 19int mce_disabled = 0;
20int nr_mce_banks; 20int nr_mce_banks;
21 21
22EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */ 22EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */
@@ -31,7 +31,7 @@ static fastcall void unexpected_machine_check(struct pt_regs * regs, long error_
31void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check; 31void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
32 32
33/* This has to be run for each processor */ 33/* This has to be run for each processor */
34void __devinit mcheck_init(struct cpuinfo_x86 *c) 34void mcheck_init(struct cpuinfo_x86 *c)
35{ 35{
36 if (mce_disabled==1) 36 if (mce_disabled==1)
37 return; 37 return;
diff --git a/arch/i386/kernel/cpu/mcheck/p4.c b/arch/i386/kernel/cpu/mcheck/p4.c
index 1d1e885f500a..fd2c459a31ef 100644
--- a/arch/i386/kernel/cpu/mcheck/p4.c
+++ b/arch/i386/kernel/cpu/mcheck/p4.c
@@ -77,7 +77,7 @@ fastcall void smp_thermal_interrupt(struct pt_regs *regs)
77} 77}
78 78
79/* P4/Xeon Thermal regulation detect and init */ 79/* P4/Xeon Thermal regulation detect and init */
80static void __devinit intel_init_thermal(struct cpuinfo_x86 *c) 80static void intel_init_thermal(struct cpuinfo_x86 *c)
81{ 81{
82 u32 l, h; 82 u32 l, h;
83 unsigned int cpu = smp_processor_id(); 83 unsigned int cpu = smp_processor_id();
@@ -231,7 +231,7 @@ static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
231} 231}
232 232
233 233
234void __devinit intel_p4_mcheck_init(struct cpuinfo_x86 *c) 234void intel_p4_mcheck_init(struct cpuinfo_x86 *c)
235{ 235{
236 u32 l, h; 236 u32 l, h;
237 int i; 237 int i;
diff --git a/arch/i386/kernel/cpu/mcheck/p5.c b/arch/i386/kernel/cpu/mcheck/p5.c
index 3a2e24baddc7..94bc43d950cf 100644
--- a/arch/i386/kernel/cpu/mcheck/p5.c
+++ b/arch/i386/kernel/cpu/mcheck/p5.c
@@ -28,7 +28,7 @@ static fastcall void pentium_machine_check(struct pt_regs * regs, long error_cod
28} 28}
29 29
30/* Set up machine check reporting for processors with Intel style MCE */ 30/* Set up machine check reporting for processors with Intel style MCE */
31void __devinit intel_p5_mcheck_init(struct cpuinfo_x86 *c) 31void intel_p5_mcheck_init(struct cpuinfo_x86 *c)
32{ 32{
33 u32 l, h; 33 u32 l, h;
34 34
diff --git a/arch/i386/kernel/cpu/mcheck/p6.c b/arch/i386/kernel/cpu/mcheck/p6.c
index 979b18bc95c1..deeae42ce199 100644
--- a/arch/i386/kernel/cpu/mcheck/p6.c
+++ b/arch/i386/kernel/cpu/mcheck/p6.c
@@ -79,7 +79,7 @@ static fastcall void intel_machine_check(struct pt_regs * regs, long error_code)
79} 79}
80 80
81/* Set up machine check reporting for processors with Intel style MCE */ 81/* Set up machine check reporting for processors with Intel style MCE */
82void __devinit intel_p6_mcheck_init(struct cpuinfo_x86 *c) 82void intel_p6_mcheck_init(struct cpuinfo_x86 *c)
83{ 83{
84 u32 l, h; 84 u32 l, h;
85 int i; 85 int i;
diff --git a/arch/i386/kernel/cpu/mcheck/winchip.c b/arch/i386/kernel/cpu/mcheck/winchip.c
index 5b9d2dd411d3..9e424b6c293d 100644
--- a/arch/i386/kernel/cpu/mcheck/winchip.c
+++ b/arch/i386/kernel/cpu/mcheck/winchip.c
@@ -22,7 +22,7 @@ static fastcall void winchip_machine_check(struct pt_regs * regs, long error_cod
22} 22}
23 23
24/* Set up machine check reporting on the Winchip C6 series */ 24/* Set up machine check reporting on the Winchip C6 series */
25void __devinit winchip_mcheck_init(struct cpuinfo_x86 *c) 25void winchip_mcheck_init(struct cpuinfo_x86 *c)
26{ 26{
27 u32 lo, hi; 27 u32 lo, hi;
28 machine_check_vector = winchip_machine_check; 28 machine_check_vector = winchip_machine_check;
diff --git a/arch/i386/kernel/kprobes.c b/arch/i386/kernel/kprobes.c
index 6345b430b105..32b0c24ab9a6 100644
--- a/arch/i386/kernel/kprobes.c
+++ b/arch/i386/kernel/kprobes.c
@@ -31,22 +31,16 @@
31#include <linux/config.h> 31#include <linux/config.h>
32#include <linux/kprobes.h> 32#include <linux/kprobes.h>
33#include <linux/ptrace.h> 33#include <linux/ptrace.h>
34#include <linux/spinlock.h>
35#include <linux/preempt.h> 34#include <linux/preempt.h>
36#include <asm/cacheflush.h> 35#include <asm/cacheflush.h>
37#include <asm/kdebug.h> 36#include <asm/kdebug.h>
38#include <asm/desc.h> 37#include <asm/desc.h>
39 38
40static struct kprobe *current_kprobe;
41static unsigned long kprobe_status, kprobe_old_eflags, kprobe_saved_eflags;
42static struct kprobe *kprobe_prev;
43static unsigned long kprobe_status_prev, kprobe_old_eflags_prev, kprobe_saved_eflags_prev;
44static struct pt_regs jprobe_saved_regs;
45static long *jprobe_saved_esp;
46/* copy of the kernel stack at the probe fire time */
47static kprobe_opcode_t jprobes_stack[MAX_STACK_SIZE];
48void jprobe_return_end(void); 39void jprobe_return_end(void);
49 40
41DEFINE_PER_CPU(struct kprobe *, current_kprobe) = NULL;
42DEFINE_PER_CPU(struct kprobe_ctlblk, kprobe_ctlblk);
43
50/* 44/*
51 * returns non-zero if opcode modifies the interrupt flag. 45 * returns non-zero if opcode modifies the interrupt flag.
52 */ 46 */
@@ -91,29 +85,30 @@ void __kprobes arch_remove_kprobe(struct kprobe *p)
91{ 85{
92} 86}
93 87
94static inline void save_previous_kprobe(void) 88static inline void save_previous_kprobe(struct kprobe_ctlblk *kcb)
95{ 89{
96 kprobe_prev = current_kprobe; 90 kcb->prev_kprobe.kp = kprobe_running();
97 kprobe_status_prev = kprobe_status; 91 kcb->prev_kprobe.status = kcb->kprobe_status;
98 kprobe_old_eflags_prev = kprobe_old_eflags; 92 kcb->prev_kprobe.old_eflags = kcb->kprobe_old_eflags;
99 kprobe_saved_eflags_prev = kprobe_saved_eflags; 93 kcb->prev_kprobe.saved_eflags = kcb->kprobe_saved_eflags;
100} 94}
101 95
102static inline void restore_previous_kprobe(void) 96static inline void restore_previous_kprobe(struct kprobe_ctlblk *kcb)
103{ 97{
104 current_kprobe = kprobe_prev; 98 __get_cpu_var(current_kprobe) = kcb->prev_kprobe.kp;
105 kprobe_status = kprobe_status_prev; 99 kcb->kprobe_status = kcb->prev_kprobe.status;
106 kprobe_old_eflags = kprobe_old_eflags_prev; 100 kcb->kprobe_old_eflags = kcb->prev_kprobe.old_eflags;
107 kprobe_saved_eflags = kprobe_saved_eflags_prev; 101 kcb->kprobe_saved_eflags = kcb->prev_kprobe.saved_eflags;
108} 102}
109 103
110static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs) 104static inline void set_current_kprobe(struct kprobe *p, struct pt_regs *regs,
105 struct kprobe_ctlblk *kcb)
111{ 106{
112 current_kprobe = p; 107 __get_cpu_var(current_kprobe) = p;
113 kprobe_saved_eflags = kprobe_old_eflags 108 kcb->kprobe_saved_eflags = kcb->kprobe_old_eflags
114 = (regs->eflags & (TF_MASK | IF_MASK)); 109 = (regs->eflags & (TF_MASK | IF_MASK));
115 if (is_IF_modifier(p->opcode)) 110 if (is_IF_modifier(p->opcode))
116 kprobe_saved_eflags &= ~IF_MASK; 111 kcb->kprobe_saved_eflags &= ~IF_MASK;
117} 112}
118 113
119static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs) 114static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
@@ -127,6 +122,7 @@ static inline void prepare_singlestep(struct kprobe *p, struct pt_regs *regs)
127 regs->eip = (unsigned long)&p->ainsn.insn; 122 regs->eip = (unsigned long)&p->ainsn.insn;
128} 123}
129 124
125/* Called with kretprobe_lock held */
130void __kprobes arch_prepare_kretprobe(struct kretprobe *rp, 126void __kprobes arch_prepare_kretprobe(struct kretprobe *rp,
131 struct pt_regs *regs) 127 struct pt_regs *regs)
132{ 128{
@@ -157,9 +153,15 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
157 int ret = 0; 153 int ret = 0;
158 kprobe_opcode_t *addr = NULL; 154 kprobe_opcode_t *addr = NULL;
159 unsigned long *lp; 155 unsigned long *lp;
156 struct kprobe_ctlblk *kcb;
160 157
161 /* We're in an interrupt, but this is clear and BUG()-safe. */ 158 /*
159 * We don't want to be preempted for the entire
160 * duration of kprobe processing
161 */
162 preempt_disable(); 162 preempt_disable();
163 kcb = get_kprobe_ctlblk();
164
163 /* Check if the application is using LDT entry for its code segment and 165 /* Check if the application is using LDT entry for its code segment and
164 * calculate the address by reading the base address from the LDT entry. 166 * calculate the address by reading the base address from the LDT entry.
165 */ 167 */
@@ -173,15 +175,12 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
173 } 175 }
174 /* Check we're not actually recursing */ 176 /* Check we're not actually recursing */
175 if (kprobe_running()) { 177 if (kprobe_running()) {
176 /* We *are* holding lock here, so this is safe.
177 Disarm the probe we just hit, and ignore it. */
178 p = get_kprobe(addr); 178 p = get_kprobe(addr);
179 if (p) { 179 if (p) {
180 if (kprobe_status == KPROBE_HIT_SS && 180 if (kcb->kprobe_status == KPROBE_HIT_SS &&
181 *p->ainsn.insn == BREAKPOINT_INSTRUCTION) { 181 *p->ainsn.insn == BREAKPOINT_INSTRUCTION) {
182 regs->eflags &= ~TF_MASK; 182 regs->eflags &= ~TF_MASK;
183 regs->eflags |= kprobe_saved_eflags; 183 regs->eflags |= kcb->kprobe_saved_eflags;
184 unlock_kprobes();
185 goto no_kprobe; 184 goto no_kprobe;
186 } 185 }
187 /* We have reentered the kprobe_handler(), since 186 /* We have reentered the kprobe_handler(), since
@@ -190,26 +189,23 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
190 * just single step on the instruction of the new probe 189 * just single step on the instruction of the new probe
191 * without calling any user handlers. 190 * without calling any user handlers.
192 */ 191 */
193 save_previous_kprobe(); 192 save_previous_kprobe(kcb);
194 set_current_kprobe(p, regs); 193 set_current_kprobe(p, regs, kcb);
195 p->nmissed++; 194 p->nmissed++;
196 prepare_singlestep(p, regs); 195 prepare_singlestep(p, regs);
197 kprobe_status = KPROBE_REENTER; 196 kcb->kprobe_status = KPROBE_REENTER;
198 return 1; 197 return 1;
199 } else { 198 } else {
200 p = current_kprobe; 199 p = __get_cpu_var(current_kprobe);
201 if (p->break_handler && p->break_handler(p, regs)) { 200 if (p->break_handler && p->break_handler(p, regs)) {
202 goto ss_probe; 201 goto ss_probe;
203 } 202 }
204 } 203 }
205 /* If it's not ours, can't be delete race, (we hold lock). */
206 goto no_kprobe; 204 goto no_kprobe;
207 } 205 }
208 206
209 lock_kprobes();
210 p = get_kprobe(addr); 207 p = get_kprobe(addr);
211 if (!p) { 208 if (!p) {
212 unlock_kprobes();
213 if (regs->eflags & VM_MASK) { 209 if (regs->eflags & VM_MASK) {
214 /* We are in virtual-8086 mode. Return 0 */ 210 /* We are in virtual-8086 mode. Return 0 */
215 goto no_kprobe; 211 goto no_kprobe;
@@ -232,8 +228,8 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
232 goto no_kprobe; 228 goto no_kprobe;
233 } 229 }
234 230
235 kprobe_status = KPROBE_HIT_ACTIVE; 231 set_current_kprobe(p, regs, kcb);
236 set_current_kprobe(p, regs); 232 kcb->kprobe_status = KPROBE_HIT_ACTIVE;
237 233
238 if (p->pre_handler && p->pre_handler(p, regs)) 234 if (p->pre_handler && p->pre_handler(p, regs))
239 /* handler has already set things up, so skip ss setup */ 235 /* handler has already set things up, so skip ss setup */
@@ -241,7 +237,7 @@ static int __kprobes kprobe_handler(struct pt_regs *regs)
241 237
242ss_probe: 238ss_probe:
243 prepare_singlestep(p, regs); 239 prepare_singlestep(p, regs);
244 kprobe_status = KPROBE_HIT_SS; 240 kcb->kprobe_status = KPROBE_HIT_SS;
245 return 1; 241 return 1;
246 242
247no_kprobe: 243no_kprobe:
@@ -269,9 +265,10 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
269 struct kretprobe_instance *ri = NULL; 265 struct kretprobe_instance *ri = NULL;
270 struct hlist_head *head; 266 struct hlist_head *head;
271 struct hlist_node *node, *tmp; 267 struct hlist_node *node, *tmp;
272 unsigned long orig_ret_address = 0; 268 unsigned long flags, orig_ret_address = 0;
273 unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline; 269 unsigned long trampoline_address =(unsigned long)&kretprobe_trampoline;
274 270
271 spin_lock_irqsave(&kretprobe_lock, flags);
275 head = kretprobe_inst_table_head(current); 272 head = kretprobe_inst_table_head(current);
276 273
277 /* 274 /*
@@ -310,14 +307,15 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
310 BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address)); 307 BUG_ON(!orig_ret_address || (orig_ret_address == trampoline_address));
311 regs->eip = orig_ret_address; 308 regs->eip = orig_ret_address;
312 309
313 unlock_kprobes(); 310 reset_current_kprobe();
311 spin_unlock_irqrestore(&kretprobe_lock, flags);
314 preempt_enable_no_resched(); 312 preempt_enable_no_resched();
315 313
316 /* 314 /*
317 * By returning a non-zero value, we are telling 315 * By returning a non-zero value, we are telling
318 * kprobe_handler() that we have handled unlocking 316 * kprobe_handler() that we don't want the post_handler
319 * and re-enabling preemption. 317 * to run (and have re-enabled preemption)
320 */ 318 */
321 return 1; 319 return 1;
322} 320}
323 321
@@ -343,7 +341,8 @@ int __kprobes trampoline_probe_handler(struct kprobe *p, struct pt_regs *regs)
343 * that is atop the stack is the address following the copied instruction. 341 * that is atop the stack is the address following the copied instruction.
344 * We need to make it the address following the original instruction. 342 * We need to make it the address following the original instruction.
345 */ 343 */
346static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs) 344static void __kprobes resume_execution(struct kprobe *p,
345 struct pt_regs *regs, struct kprobe_ctlblk *kcb)
347{ 346{
348 unsigned long *tos = (unsigned long *)&regs->esp; 347 unsigned long *tos = (unsigned long *)&regs->esp;
349 unsigned long next_eip = 0; 348 unsigned long next_eip = 0;
@@ -353,7 +352,7 @@ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
353 switch (p->ainsn.insn[0]) { 352 switch (p->ainsn.insn[0]) {
354 case 0x9c: /* pushfl */ 353 case 0x9c: /* pushfl */
355 *tos &= ~(TF_MASK | IF_MASK); 354 *tos &= ~(TF_MASK | IF_MASK);
356 *tos |= kprobe_old_eflags; 355 *tos |= kcb->kprobe_old_eflags;
357 break; 356 break;
358 case 0xc3: /* ret/lret */ 357 case 0xc3: /* ret/lret */
359 case 0xcb: 358 case 0xcb:
@@ -394,27 +393,30 @@ static void __kprobes resume_execution(struct kprobe *p, struct pt_regs *regs)
394 393
395/* 394/*
396 * Interrupts are disabled on entry as trap1 is an interrupt gate and they 395 * Interrupts are disabled on entry as trap1 is an interrupt gate and they
397 * remain disabled thoroughout this function. And we hold kprobe lock. 396 * remain disabled thoroughout this function.
398 */ 397 */
399static inline int post_kprobe_handler(struct pt_regs *regs) 398static inline int post_kprobe_handler(struct pt_regs *regs)
400{ 399{
401 if (!kprobe_running()) 400 struct kprobe *cur = kprobe_running();
401 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
402
403 if (!cur)
402 return 0; 404 return 0;
403 405
404 if ((kprobe_status != KPROBE_REENTER) && current_kprobe->post_handler) { 406 if ((kcb->kprobe_status != KPROBE_REENTER) && cur->post_handler) {
405 kprobe_status = KPROBE_HIT_SSDONE; 407 kcb->kprobe_status = KPROBE_HIT_SSDONE;
406 current_kprobe->post_handler(current_kprobe, regs, 0); 408 cur->post_handler(cur, regs, 0);
407 } 409 }
408 410
409 resume_execution(current_kprobe, regs); 411 resume_execution(cur, regs, kcb);
410 regs->eflags |= kprobe_saved_eflags; 412 regs->eflags |= kcb->kprobe_saved_eflags;
411 413
412 /*Restore back the original saved kprobes variables and continue. */ 414 /*Restore back the original saved kprobes variables and continue. */
413 if (kprobe_status == KPROBE_REENTER) { 415 if (kcb->kprobe_status == KPROBE_REENTER) {
414 restore_previous_kprobe(); 416 restore_previous_kprobe(kcb);
415 goto out; 417 goto out;
416 } 418 }
417 unlock_kprobes(); 419 reset_current_kprobe();
418out: 420out:
419 preempt_enable_no_resched(); 421 preempt_enable_no_resched();
420 422
@@ -429,18 +431,19 @@ out:
429 return 1; 431 return 1;
430} 432}
431 433
432/* Interrupts disabled, kprobe_lock held. */
433static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr) 434static inline int kprobe_fault_handler(struct pt_regs *regs, int trapnr)
434{ 435{
435 if (current_kprobe->fault_handler 436 struct kprobe *cur = kprobe_running();
436 && current_kprobe->fault_handler(current_kprobe, regs, trapnr)) 437 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
438
439 if (cur->fault_handler && cur->fault_handler(cur, regs, trapnr))
437 return 1; 440 return 1;
438 441
439 if (kprobe_status & KPROBE_HIT_SS) { 442 if (kcb->kprobe_status & KPROBE_HIT_SS) {
440 resume_execution(current_kprobe, regs); 443 resume_execution(cur, regs, kcb);
441 regs->eflags |= kprobe_old_eflags; 444 regs->eflags |= kcb->kprobe_old_eflags;
442 445
443 unlock_kprobes(); 446 reset_current_kprobe();
444 preempt_enable_no_resched(); 447 preempt_enable_no_resched();
445 } 448 }
446 return 0; 449 return 0;
@@ -453,39 +456,41 @@ int __kprobes kprobe_exceptions_notify(struct notifier_block *self,
453 unsigned long val, void *data) 456 unsigned long val, void *data)
454{ 457{
455 struct die_args *args = (struct die_args *)data; 458 struct die_args *args = (struct die_args *)data;
459 int ret = NOTIFY_DONE;
460
456 switch (val) { 461 switch (val) {
457 case DIE_INT3: 462 case DIE_INT3:
458 if (kprobe_handler(args->regs)) 463 if (kprobe_handler(args->regs))
459 return NOTIFY_STOP; 464 ret = NOTIFY_STOP;
460 break; 465 break;
461 case DIE_DEBUG: 466 case DIE_DEBUG:
462 if (post_kprobe_handler(args->regs)) 467 if (post_kprobe_handler(args->regs))
463 return NOTIFY_STOP; 468 ret = NOTIFY_STOP;
464 break; 469 break;
465 case DIE_GPF: 470 case DIE_GPF:
466 if (kprobe_running() &&
467 kprobe_fault_handler(args->regs, args->trapnr))
468 return NOTIFY_STOP;
469 break;
470 case DIE_PAGE_FAULT: 471 case DIE_PAGE_FAULT:
472 /* kprobe_running() needs smp_processor_id() */
473 preempt_disable();
471 if (kprobe_running() && 474 if (kprobe_running() &&
472 kprobe_fault_handler(args->regs, args->trapnr)) 475 kprobe_fault_handler(args->regs, args->trapnr))
473 return NOTIFY_STOP; 476 ret = NOTIFY_STOP;
477 preempt_enable();
474 break; 478 break;
475 default: 479 default:
476 break; 480 break;
477 } 481 }
478 return NOTIFY_DONE; 482 return ret;
479} 483}
480 484
481int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs) 485int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
482{ 486{
483 struct jprobe *jp = container_of(p, struct jprobe, kp); 487 struct jprobe *jp = container_of(p, struct jprobe, kp);
484 unsigned long addr; 488 unsigned long addr;
489 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
485 490
486 jprobe_saved_regs = *regs; 491 kcb->jprobe_saved_regs = *regs;
487 jprobe_saved_esp = &regs->esp; 492 kcb->jprobe_saved_esp = &regs->esp;
488 addr = (unsigned long)jprobe_saved_esp; 493 addr = (unsigned long)(kcb->jprobe_saved_esp);
489 494
490 /* 495 /*
491 * TBD: As Linus pointed out, gcc assumes that the callee 496 * TBD: As Linus pointed out, gcc assumes that the callee
@@ -494,7 +499,8 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
494 * we also save and restore enough stack bytes to cover 499 * we also save and restore enough stack bytes to cover
495 * the argument area. 500 * the argument area.
496 */ 501 */
497 memcpy(jprobes_stack, (kprobe_opcode_t *) addr, MIN_STACK_SIZE(addr)); 502 memcpy(kcb->jprobes_stack, (kprobe_opcode_t *)addr,
503 MIN_STACK_SIZE(addr));
498 regs->eflags &= ~IF_MASK; 504 regs->eflags &= ~IF_MASK;
499 regs->eip = (unsigned long)(jp->entry); 505 regs->eip = (unsigned long)(jp->entry);
500 return 1; 506 return 1;
@@ -502,36 +508,40 @@ int __kprobes setjmp_pre_handler(struct kprobe *p, struct pt_regs *regs)
502 508
503void __kprobes jprobe_return(void) 509void __kprobes jprobe_return(void)
504{ 510{
505 preempt_enable_no_resched(); 511 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
512
506 asm volatile (" xchgl %%ebx,%%esp \n" 513 asm volatile (" xchgl %%ebx,%%esp \n"
507 " int3 \n" 514 " int3 \n"
508 " .globl jprobe_return_end \n" 515 " .globl jprobe_return_end \n"
509 " jprobe_return_end: \n" 516 " jprobe_return_end: \n"
510 " nop \n"::"b" 517 " nop \n"::"b"
511 (jprobe_saved_esp):"memory"); 518 (kcb->jprobe_saved_esp):"memory");
512} 519}
513 520
514int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs) 521int __kprobes longjmp_break_handler(struct kprobe *p, struct pt_regs *regs)
515{ 522{
523 struct kprobe_ctlblk *kcb = get_kprobe_ctlblk();
516 u8 *addr = (u8 *) (regs->eip - 1); 524 u8 *addr = (u8 *) (regs->eip - 1);
517 unsigned long stack_addr = (unsigned long)jprobe_saved_esp; 525 unsigned long stack_addr = (unsigned long)(kcb->jprobe_saved_esp);
518 struct jprobe *jp = container_of(p, struct jprobe, kp); 526 struct jprobe *jp = container_of(p, struct jprobe, kp);
519 527
520 if ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) { 528 if ((addr > (u8 *) jprobe_return) && (addr < (u8 *) jprobe_return_end)) {
521 if (&regs->esp != jprobe_saved_esp) { 529 if (&regs->esp != kcb->jprobe_saved_esp) {
522 struct pt_regs *saved_regs = 530 struct pt_regs *saved_regs =
523 container_of(jprobe_saved_esp, struct pt_regs, esp); 531 container_of(kcb->jprobe_saved_esp,
532 struct pt_regs, esp);
524 printk("current esp %p does not match saved esp %p\n", 533 printk("current esp %p does not match saved esp %p\n",
525 &regs->esp, jprobe_saved_esp); 534 &regs->esp, kcb->jprobe_saved_esp);
526 printk("Saved registers for jprobe %p\n", jp); 535 printk("Saved registers for jprobe %p\n", jp);
527 show_registers(saved_regs); 536 show_registers(saved_regs);
528 printk("Current registers\n"); 537 printk("Current registers\n");
529 show_registers(regs); 538 show_registers(regs);
530 BUG(); 539 BUG();
531 } 540 }
532 *regs = jprobe_saved_regs; 541 *regs = kcb->jprobe_saved_regs;
533 memcpy((kprobe_opcode_t *) stack_addr, jprobes_stack, 542 memcpy((kprobe_opcode_t *) stack_addr, kcb->jprobes_stack,
534 MIN_STACK_SIZE(stack_addr)); 543 MIN_STACK_SIZE(stack_addr));
544 preempt_enable_no_resched();
535 return 1; 545 return 1;
536 } 546 }
537 return 0; 547 return 0;
diff --git a/arch/i386/kernel/ldt.c b/arch/i386/kernel/ldt.c
index fe1ffa55587d..983f95707e11 100644
--- a/arch/i386/kernel/ldt.c
+++ b/arch/i386/kernel/ldt.c
@@ -18,6 +18,7 @@
18#include <asm/system.h> 18#include <asm/system.h>
19#include <asm/ldt.h> 19#include <asm/ldt.h>
20#include <asm/desc.h> 20#include <asm/desc.h>
21#include <asm/mmu_context.h>
21 22
22#ifdef CONFIG_SMP /* avoids "defined but not used" warnig */ 23#ifdef CONFIG_SMP /* avoids "defined but not used" warnig */
23static void flush_ldt(void *null) 24static void flush_ldt(void *null)
diff --git a/arch/i386/kernel/mca.c b/arch/i386/kernel/mca.c
index 8600faeea29d..558bb207720f 100644
--- a/arch/i386/kernel/mca.c
+++ b/arch/i386/kernel/mca.c
@@ -132,7 +132,7 @@ static struct resource mca_standard_resources[] = {
132 { .start = 0x100, .end = 0x107, .name = "POS (MCA)" } 132 { .start = 0x100, .end = 0x107, .name = "POS (MCA)" }
133}; 133};
134 134
135#define MCA_STANDARD_RESOURCES (sizeof(mca_standard_resources)/sizeof(struct resource)) 135#define MCA_STANDARD_RESOURCES ARRAY_SIZE(mca_standard_resources)
136 136
137/** 137/**
138 * mca_read_and_store_pos - read the POS registers into a memory buffer 138 * mca_read_and_store_pos - read the POS registers into a memory buffer
diff --git a/arch/i386/kernel/ptrace.c b/arch/i386/kernel/ptrace.c
index efd11f09c996..5ffbb4b7ad05 100644
--- a/arch/i386/kernel/ptrace.c
+++ b/arch/i386/kernel/ptrace.c
@@ -354,49 +354,12 @@ ptrace_set_thread_area(struct task_struct *child,
354 return 0; 354 return 0;
355} 355}
356 356
357asmlinkage long sys_ptrace(long request, long pid, long addr, long data) 357long arch_ptrace(struct task_struct *child, long request, long addr, long data)
358{ 358{
359 struct task_struct *child;
360 struct user * dummy = NULL; 359 struct user * dummy = NULL;
361 int i, ret; 360 int i, ret;
362 unsigned long __user *datap = (unsigned long __user *)data; 361 unsigned long __user *datap = (unsigned long __user *)data;
363 362
364 lock_kernel();
365 ret = -EPERM;
366 if (request == PTRACE_TRACEME) {
367 /* are we already being traced? */
368 if (current->ptrace & PT_PTRACED)
369 goto out;
370 ret = security_ptrace(current->parent, current);
371 if (ret)
372 goto out;
373 /* set the ptrace bit in the process flags. */
374 current->ptrace |= PT_PTRACED;
375 ret = 0;
376 goto out;
377 }
378 ret = -ESRCH;
379 read_lock(&tasklist_lock);
380 child = find_task_by_pid(pid);
381 if (child)
382 get_task_struct(child);
383 read_unlock(&tasklist_lock);
384 if (!child)
385 goto out;
386
387 ret = -EPERM;
388 if (pid == 1) /* you may not mess with init */
389 goto out_tsk;
390
391 if (request == PTRACE_ATTACH) {
392 ret = ptrace_attach(child);
393 goto out_tsk;
394 }
395
396 ret = ptrace_check_attach(child, request == PTRACE_KILL);
397 if (ret < 0)
398 goto out_tsk;
399
400 switch (request) { 363 switch (request) {
401 /* when I and D space are separate, these will need to be fixed. */ 364 /* when I and D space are separate, these will need to be fixed. */
402 case PTRACE_PEEKTEXT: /* read word at location addr. */ 365 case PTRACE_PEEKTEXT: /* read word at location addr. */
@@ -663,10 +626,7 @@ asmlinkage long sys_ptrace(long request, long pid, long addr, long data)
663 ret = ptrace_request(child, request, addr, data); 626 ret = ptrace_request(child, request, addr, data);
664 break; 627 break;
665 } 628 }
666out_tsk: 629 out_tsk:
667 put_task_struct(child);
668out:
669 unlock_kernel();
670 return ret; 630 return ret;
671} 631}
672 632
diff --git a/arch/i386/kernel/reboot_fixups.c b/arch/i386/kernel/reboot_fixups.c
index c9b87330aeea..10e21a4773dd 100644
--- a/arch/i386/kernel/reboot_fixups.c
+++ b/arch/i386/kernel/reboot_fixups.c
@@ -10,6 +10,7 @@
10 10
11#include <asm/delay.h> 11#include <asm/delay.h>
12#include <linux/pci.h> 12#include <linux/pci.h>
13#include <linux/reboot_fixups.h>
13 14
14static void cs5530a_warm_reset(struct pci_dev *dev) 15static void cs5530a_warm_reset(struct pci_dev *dev)
15{ 16{
@@ -42,7 +43,7 @@ void mach_reboot_fixups(void)
42 struct pci_dev *dev; 43 struct pci_dev *dev;
43 int i; 44 int i;
44 45
45 for (i=0; i < (sizeof(fixups_table)/sizeof(fixups_table[0])); i++) { 46 for (i=0; i < ARRAY_SIZE(fixups_table); i++) {
46 cur = &(fixups_table[i]); 47 cur = &(fixups_table[i]);
47 dev = pci_get_device(cur->vendor, cur->device, NULL); 48 dev = pci_get_device(cur->vendor, cur->device, NULL);
48 if (!dev) 49 if (!dev)
diff --git a/arch/i386/kernel/scx200.c b/arch/i386/kernel/scx200.c
index 69e203a0d330..9c968ae67c43 100644
--- a/arch/i386/kernel/scx200.c
+++ b/arch/i386/kernel/scx200.c
@@ -12,6 +12,7 @@
12#include <linux/pci.h> 12#include <linux/pci.h>
13 13
14#include <linux/scx200.h> 14#include <linux/scx200.h>
15#include <linux/scx200_gpio.h>
15 16
16/* Verify that the configuration block really is there */ 17/* Verify that the configuration block really is there */
17#define scx200_cb_probe(base) (inw((base) + SCx200_CBA) == (base)) 18#define scx200_cb_probe(base) (inw((base) + SCx200_CBA) == (base))
diff --git a/arch/i386/kernel/smpboot.c b/arch/i386/kernel/smpboot.c
index 01b618e73ecd..47ec76794d02 100644
--- a/arch/i386/kernel/smpboot.c
+++ b/arch/i386/kernel/smpboot.c
@@ -68,11 +68,9 @@ EXPORT_SYMBOL(smp_num_siblings);
68 68
69/* Package ID of each logical CPU */ 69/* Package ID of each logical CPU */
70int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; 70int phys_proc_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
71EXPORT_SYMBOL(phys_proc_id);
72 71
73/* Core ID of each logical CPU */ 72/* Core ID of each logical CPU */
74int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID}; 73int cpu_core_id[NR_CPUS] __read_mostly = {[0 ... NR_CPUS-1] = BAD_APICID};
75EXPORT_SYMBOL(cpu_core_id);
76 74
77cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly; 75cpumask_t cpu_sibling_map[NR_CPUS] __read_mostly;
78EXPORT_SYMBOL(cpu_sibling_map); 76EXPORT_SYMBOL(cpu_sibling_map);
@@ -612,7 +610,7 @@ static inline void __inquire_remote_apic(int apicid)
612 610
613 printk("Inquiring remote APIC #%d...\n", apicid); 611 printk("Inquiring remote APIC #%d...\n", apicid);
614 612
615 for (i = 0; i < sizeof(regs) / sizeof(*regs); i++) { 613 for (i = 0; i < ARRAY_SIZE(regs); i++) {
616 printk("... APIC #%d %s: ", apicid, names[i]); 614 printk("... APIC #%d %s: ", apicid, names[i]);
617 615
618 /* 616 /*