aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorKumar Gala <galak@kernel.crashing.org>2008-04-28 02:21:22 -0400
committerPaul Mackerras <paulus@samba.org>2008-04-29 01:57:34 -0400
commit85218827cc4ca900867807f19345418164ffc108 (patch)
tree1813b7fadb7c077acd0ef62f57385b7424ca0121 /arch/powerpc/kernel
parentdd18434ff0b7d9b9ad3d596985fc84b329d2f9a8 (diff)
[POWERPC] Add IRQSTACKS support on ppc32
This makes it possible to use separate stacks for hard and soft IRQs on 32-bit powerpc as well as on 64-bit. The code for 32-bit is just the 32-bit analog of the 64-bit code. * Added allocation and initialization of the irq stacks. We limit the stacks to be in lowmem for ppc32. * Implemented ppc32 versions of call_do_softirq() and call_handle_irq() to switch the stack pointers * Reworked how we do stack overflow detection. We now keep around the limit of the stack in the thread_struct and compare against the limit to see if we've overflowed. We can now use this on ppc64 if desired. [ paulus@samba.org: Fixed bug on 6xx where we need to reload r9 with the thread_info pointer. ] Signed-off-by: Kumar Gala <galak@kernel.crashing.org> Signed-off-by: Paul Mackerras <paulus@samba.org>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/asm-offsets.c1
-rw-r--r--arch/powerpc/kernel/entry_32.S5
-rw-r--r--arch/powerpc/kernel/irq.c10
-rw-r--r--arch/powerpc/kernel/misc_32.S25
-rw-r--r--arch/powerpc/kernel/process.c2
-rw-r--r--arch/powerpc/kernel/setup_32.c21
6 files changed, 60 insertions, 4 deletions
diff --git a/arch/powerpc/kernel/asm-offsets.c b/arch/powerpc/kernel/asm-offsets.c
index 62134845af08..af1d2c894ee1 100644
--- a/arch/powerpc/kernel/asm-offsets.c
+++ b/arch/powerpc/kernel/asm-offsets.c
@@ -67,6 +67,7 @@ int main(void)
67#endif /* CONFIG_PPC64 */ 67#endif /* CONFIG_PPC64 */
68 68
69 DEFINE(KSP, offsetof(struct thread_struct, ksp)); 69 DEFINE(KSP, offsetof(struct thread_struct, ksp));
70 DEFINE(KSP_LIMIT, offsetof(struct thread_struct, ksp_limit));
70 DEFINE(PT_REGS, offsetof(struct thread_struct, regs)); 71 DEFINE(PT_REGS, offsetof(struct thread_struct, regs));
71 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode)); 72 DEFINE(THREAD_FPEXC_MODE, offsetof(struct thread_struct, fpexc_mode));
72 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0])); 73 DEFINE(THREAD_FPR0, offsetof(struct thread_struct, fpr[0]));
diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 84c868633068..0c8614d9875c 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -137,11 +137,12 @@ transfer_to_handler:
1372: /* if from kernel, check interrupted DOZE/NAP mode and 1372: /* if from kernel, check interrupted DOZE/NAP mode and
138 * check for stack overflow 138 * check for stack overflow
139 */ 139 */
140 lwz r9,THREAD_INFO-THREAD(r12) 140 lwz r9,KSP_LIMIT(r12)
141 cmplw r1,r9 /* if r1 <= current->thread_info */ 141 cmplw r1,r9 /* if r1 <= ksp_limit */
142 ble- stack_ovf /* then the kernel stack overflowed */ 142 ble- stack_ovf /* then the kernel stack overflowed */
1435: 1435:
144#ifdef CONFIG_6xx 144#ifdef CONFIG_6xx
145 rlwinm r9,r1,0,0,31-THREAD_SHIFT
145 tophys(r9,r9) /* check local flags */ 146 tophys(r9,r9) /* check local flags */
146 lwz r12,TI_LOCAL_FLAGS(r9) 147 lwz r12,TI_LOCAL_FLAGS(r9)
147 mtcrf 0x01,r12 148 mtcrf 0x01,r12
diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c
index 425616f92d18..2f73f705d564 100644
--- a/arch/powerpc/kernel/irq.c
+++ b/arch/powerpc/kernel/irq.c
@@ -307,6 +307,7 @@ void do_IRQ(struct pt_regs *regs)
307 if (curtp != irqtp) { 307 if (curtp != irqtp) {
308 struct irq_desc *desc = irq_desc + irq; 308 struct irq_desc *desc = irq_desc + irq;
309 void *handler = desc->handle_irq; 309 void *handler = desc->handle_irq;
310 unsigned long saved_sp_limit = current->thread.ksp_limit;
310 if (handler == NULL) 311 if (handler == NULL)
311 handler = &__do_IRQ; 312 handler = &__do_IRQ;
312 irqtp->task = curtp->task; 313 irqtp->task = curtp->task;
@@ -319,7 +320,10 @@ void do_IRQ(struct pt_regs *regs)
319 (irqtp->preempt_count & ~SOFTIRQ_MASK) | 320 (irqtp->preempt_count & ~SOFTIRQ_MASK) |
320 (curtp->preempt_count & SOFTIRQ_MASK); 321 (curtp->preempt_count & SOFTIRQ_MASK);
321 322
323 current->thread.ksp_limit = (unsigned long)irqtp +
324 _ALIGN_UP(sizeof(struct thread_info), 16);
322 call_handle_irq(irq, desc, irqtp, handler); 325 call_handle_irq(irq, desc, irqtp, handler);
326 current->thread.ksp_limit = saved_sp_limit;
323 irqtp->task = NULL; 327 irqtp->task = NULL;
324 328
325 329
@@ -352,9 +356,7 @@ void __init init_IRQ(void)
352{ 356{
353 if (ppc_md.init_IRQ) 357 if (ppc_md.init_IRQ)
354 ppc_md.init_IRQ(); 358 ppc_md.init_IRQ();
355#ifdef CONFIG_PPC64
356 irq_ctx_init(); 359 irq_ctx_init();
357#endif
358} 360}
359 361
360 362
@@ -383,11 +385,15 @@ void irq_ctx_init(void)
383static inline void do_softirq_onstack(void) 385static inline void do_softirq_onstack(void)
384{ 386{
385 struct thread_info *curtp, *irqtp; 387 struct thread_info *curtp, *irqtp;
388 unsigned long saved_sp_limit = current->thread.ksp_limit;
386 389
387 curtp = current_thread_info(); 390 curtp = current_thread_info();
388 irqtp = softirq_ctx[smp_processor_id()]; 391 irqtp = softirq_ctx[smp_processor_id()];
389 irqtp->task = curtp->task; 392 irqtp->task = curtp->task;
393 current->thread.ksp_limit = (unsigned long)irqtp +
394 _ALIGN_UP(sizeof(struct thread_info), 16);
390 call_do_softirq(irqtp); 395 call_do_softirq(irqtp);
396 current->thread.ksp_limit = saved_sp_limit;
391 irqtp->task = NULL; 397 irqtp->task = NULL;
392} 398}
393 399
diff --git a/arch/powerpc/kernel/misc_32.S b/arch/powerpc/kernel/misc_32.S
index 92ccc6fcc5b0..89aaaa6f3561 100644
--- a/arch/powerpc/kernel/misc_32.S
+++ b/arch/powerpc/kernel/misc_32.S
@@ -32,6 +32,31 @@
32 32
33 .text 33 .text
34 34
35#ifdef CONFIG_IRQSTACKS
36_GLOBAL(call_do_softirq)
37 mflr r0
38 stw r0,4(r1)
39 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r3)
40 mr r1,r3
41 bl __do_softirq
42 lwz r1,0(r1)
43 lwz r0,4(r1)
44 mtlr r0
45 blr
46
47_GLOBAL(call_handle_irq)
48 mflr r0
49 stw r0,4(r1)
50 mtctr r6
51 stwu r1,THREAD_SIZE-STACK_FRAME_OVERHEAD(r5)
52 mr r1,r5
53 bctrl
54 lwz r1,0(r1)
55 lwz r0,4(r1)
56 mtlr r0
57 blr
58#endif /* CONFIG_IRQSTACKS */
59
35/* 60/*
36 * This returns the high 64 bits of the product of two 64-bit numbers. 61 * This returns the high 64 bits of the product of two 64-bit numbers.
37 */ 62 */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 6caad17ea72e..7de41c3948ec 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -589,6 +589,8 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long usp,
589 kregs = (struct pt_regs *) sp; 589 kregs = (struct pt_regs *) sp;
590 sp -= STACK_FRAME_OVERHEAD; 590 sp -= STACK_FRAME_OVERHEAD;
591 p->thread.ksp = sp; 591 p->thread.ksp = sp;
592 p->thread.ksp_limit = (unsigned long)task_stack_page(p) +
593 _ALIGN_UP(sizeof(struct thread_info), 16);
592 594
593#ifdef CONFIG_PPC64 595#ifdef CONFIG_PPC64
594 if (cpu_has_feature(CPU_FTR_SLB)) { 596 if (cpu_has_feature(CPU_FTR_SLB)) {
diff --git a/arch/powerpc/kernel/setup_32.c b/arch/powerpc/kernel/setup_32.c
index 36f6779c88d4..5112a4aa801d 100644
--- a/arch/powerpc/kernel/setup_32.c
+++ b/arch/powerpc/kernel/setup_32.c
@@ -16,6 +16,7 @@
16#include <linux/root_dev.h> 16#include <linux/root_dev.h>
17#include <linux/cpu.h> 17#include <linux/cpu.h>
18#include <linux/console.h> 18#include <linux/console.h>
19#include <linux/lmb.h>
19 20
20#include <asm/io.h> 21#include <asm/io.h>
21#include <asm/prom.h> 22#include <asm/prom.h>
@@ -229,6 +230,24 @@ int __init ppc_init(void)
229 230
230arch_initcall(ppc_init); 231arch_initcall(ppc_init);
231 232
233#ifdef CONFIG_IRQSTACKS
234static void __init irqstack_early_init(void)
235{
236 unsigned int i;
237
238 /* interrupt stacks must be in lowmem, we get that for free on ppc32
239 * as the lmb is limited to lowmem by LMB_REAL_LIMIT */
240 for_each_possible_cpu(i) {
241 softirq_ctx[i] = (struct thread_info *)
242 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
243 hardirq_ctx[i] = (struct thread_info *)
244 __va(lmb_alloc(THREAD_SIZE, THREAD_SIZE));
245 }
246}
247#else
248#define irqstack_early_init()
249#endif
250
232/* Warning, IO base is not yet inited */ 251/* Warning, IO base is not yet inited */
233void __init setup_arch(char **cmdline_p) 252void __init setup_arch(char **cmdline_p)
234{ 253{
@@ -286,6 +305,8 @@ void __init setup_arch(char **cmdline_p)
286 init_mm.end_data = (unsigned long) _edata; 305 init_mm.end_data = (unsigned long) _edata;
287 init_mm.brk = klimit; 306 init_mm.brk = klimit;
288 307
308 irqstack_early_init();
309
289 /* set up the bootmem stuff with available memory */ 310 /* set up the bootmem stuff with available memory */
290 do_init_bootmem(); 311 do_init_bootmem();
291 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab); 312 if ( ppc_md.progress ) ppc_md.progress("setup_arch: bootmem", 0x3eab);