Re: [PATCH v3 1/3] [POWERPC] Move to runtime allocated exception stacks

2008-05-19 Thread Josh Boyer
On Fri, 16 May 2008 14:04:54 -0500 (CDT)
Kumar Gala [EMAIL PROTECTED] wrote:

 For the additonal exception levels (critical, debug, machine check) on
 40x/book-e we were using static allocations of the stack in the
 associated head.S.
 
 Move to a runtime allocation to make the code a bit easier to read as
 we mimic how we handle IRQ stacks.  Its also a bit easier to setup the
 stack with a dummy thread_info in C code.
 
 Signed-off-by: Kumar Gala [EMAIL PROTECTED]
 ---
  arch/powerpc/kernel/head_40x.S   |   14 ++
  arch/powerpc/kernel/head_44x.S   |9 -
  arch/powerpc/kernel/head_booke.h |   29 +++--
  arch/powerpc/kernel/head_fsl_booke.S |9 -
  arch/powerpc/kernel/irq.c|   33 +
  arch/powerpc/kernel/setup_32.c   |   24 
  include/asm-powerpc/irq.h|   13 +
  7 files changed, 83 insertions(+), 48 deletions(-)
 
 diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
 index 8552e67..ca75eaf 100644
 --- a/arch/powerpc/kernel/head_40x.S
 +++ b/arch/powerpc/kernel/head_40x.S
 @@ -148,8 +148,8 @@ _ENTRY(crit_r11)
   mfcrr10;/* save CR in r10 for now  */\
   mfspr   r11,SPRN_SRR3;  /* check whether user or kernel*/\
   andi.   r11,r11,MSR_PR;  \
 - lis r11,[EMAIL PROTECTED];   \
 - ori r11,r11,[EMAIL PROTECTED];   \
 + lis r11,[EMAIL PROTECTED];   \

You need a:

tophys(r11,r11); \

here.  That fixes the hangs I see on my Walnut (PPC405GP) board when
using gdb.  The problem is that we're in real mode at this point, but
using the virtual address of critirq_ctx.  That seems to be a bad idea
when trying to load values out of it... ;)

 + lwz r11,[EMAIL PROTECTED](r11); 
  \
   beq 1f;  \
   /* COMING FROM USER MODE */  \
   mfspr   r11,SPRN_SPRG3; /* if from user, start at top of   */\

josh
___
Linuxppc-dev mailing list
Linuxppc-dev@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-dev


[PATCH v3 1/3] [POWERPC] Move to runtime allocated exception stacks

2008-05-16 Thread Kumar Gala
For the additonal exception levels (critical, debug, machine check) on
40x/book-e we were using static allocations of the stack in the
associated head.S.

Move to a runtime allocation to make the code a bit easier to read as
we mimic how we handle IRQ stacks.  Its also a bit easier to setup the
stack with a dummy thread_info in C code.

Signed-off-by: Kumar Gala [EMAIL PROTECTED]
---
 arch/powerpc/kernel/head_40x.S   |   14 ++
 arch/powerpc/kernel/head_44x.S   |9 -
 arch/powerpc/kernel/head_booke.h |   29 +++--
 arch/powerpc/kernel/head_fsl_booke.S |9 -
 arch/powerpc/kernel/irq.c|   33 +
 arch/powerpc/kernel/setup_32.c   |   24 
 include/asm-powerpc/irq.h|   13 +
 7 files changed, 83 insertions(+), 48 deletions(-)

diff --git a/arch/powerpc/kernel/head_40x.S b/arch/powerpc/kernel/head_40x.S
index 8552e67..ca75eaf 100644
--- a/arch/powerpc/kernel/head_40x.S
+++ b/arch/powerpc/kernel/head_40x.S
@@ -148,8 +148,8 @@ _ENTRY(crit_r11)
mfcrr10;/* save CR in r10 for now  */\
mfspr   r11,SPRN_SRR3;  /* check whether user or kernel*/\
andi.   r11,r11,MSR_PR;  \
-   lis r11,[EMAIL PROTECTED];   \
-   ori r11,r11,[EMAIL PROTECTED];   \
+   lis r11,[EMAIL PROTECTED];   \
+   lwz r11,[EMAIL PROTECTED](r11); 
 \
beq 1f;  \
/* COMING FROM USER MODE */  \
mfspr   r11,SPRN_SPRG3; /* if from user, start at top of   */\
@@ -996,16 +996,6 @@ empty_zero_page:
 swapper_pg_dir:
.space  PGD_TABLE_SIZE

-
-/* Stack for handling critical exceptions from kernel mode */
-   .section .bss
-.align 12
-exception_stack_bottom:
-   .space  4096
-critical_stack_top:
-   .globl  exception_stack_top
-exception_stack_top:
-
 /* Room for two PTE pointers, usually the kernel and current user pointers
  * to their respective root page table.
  */
diff --git a/arch/powerpc/kernel/head_44x.S b/arch/powerpc/kernel/head_44x.S
index c2b9dc4..47ea8af 100644
--- a/arch/powerpc/kernel/head_44x.S
+++ b/arch/powerpc/kernel/head_44x.S
@@ -737,15 +737,6 @@ empty_zero_page:
 swapper_pg_dir:
.space  PGD_TABLE_SIZE

-/* Reserved 4k for the critical exception stack  4k for the machine
- * check stack per CPU for kernel mode exceptions */
-   .section .bss
-.align 12
-exception_stack_bottom:
-   .space  BOOKE_EXCEPTION_STACK_SIZE
-   .globl  exception_stack_top
-exception_stack_top:
-
 /*
  * Room for two PTE pointers, usually the kernel and current user pointers
  * to their respective root page table.
diff --git a/arch/powerpc/kernel/head_booke.h b/arch/powerpc/kernel/head_booke.h
index 721faef..9eacf4c 100644
--- a/arch/powerpc/kernel/head_booke.h
+++ b/arch/powerpc/kernel/head_booke.h
@@ -43,9 +43,7 @@
SAVE_2GPRS(7, r11)

 /* To handle the additional exception priority levels on 40x and Book-E
- * processors we allocate a 4k stack per additional priority level. The various
- * head_xxx.S files allocate space (exception_stack_top) for each priority's
- * stack times the number of CPUs
+ * processors we allocate a stack per additional priority level.
  *
  * On 40x critical is the only additional level
  * On 44x/e500 we have critical and machine check
@@ -61,36 +59,31 @@
  * going to critical or their own debug level we aren't currently
  * providing configurations that micro-optimize space usage.
  */
-#ifdef CONFIG_44x
-#define NUM_EXCEPTION_LVLS 2
-#else
-#define NUM_EXCEPTION_LVLS 3
-#endif
-#define BOOKE_EXCEPTION_STACK_SIZE (4096 * NUM_EXCEPTION_LVLS)

 /* CRIT_SPRG only used in critical exception handling */
 #define CRIT_SPRG  SPRN_SPRG2
 /* MCHECK_SPRG only used in machine check exception handling */
 #define MCHECK_SPRGSPRN_SPRG6W

-#define MCHECK_STACK_TOP   (exception_stack_top - 4096)
-#define CRIT_STACK_TOP (exception_stack_top)
+#define MCHECK_STACK_BASE  mcheckirq_ctx
+#define CRIT_STACK_BASEcritirq_ctx

 /* only on e200 for now */
-#define DEBUG_STACK_TOP(exception_stack_top - 8192)
+#define DEBUG_STACK_BASE   dbgirq_ctx
 #define DEBUG_SPRG SPRN_SPRG6W

 #ifdef CONFIG_SMP
 #define BOOKE_LOAD_EXC_LEVEL_STACK(level)  \
mfspr   r8,SPRN_PIR;\
-   mulli   r8,r8,BOOKE_EXCEPTION_STACK_SIZE;   \
-   neg r8,r8;  \
-   addis   r8,r8,[EMAIL PROTECTED];\
-   addir8,r8,[EMAIL PROTECTED]
+   slwir8,r8,2;