aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn David Anglin <dave.anglin@bell.net>2013-05-20 12:42:53 -0400
committerHelge Deller <deller@gmx.de>2013-05-24 16:35:36 -0400
commitb63a2bbc0b9b106a93e11952ab057e2408f2eb02 (patch)
tree28dfb7722a7c974f9872a566905b441cf7f18190
parentd0c3be806a3fe7f4abdb0f7e7287addb55e73f35 (diff)
parisc: make interrupt and interruption stack allocation reentrant
The get_stack_use_cr30 and get_stack_use_r30 macros allocate a stack frame for external interrupts and interruptions requiring a stack frame. They are currently not reentrant in that they save register context before the stack is set or adjusted. I have observed a number of system crashes where there was clear evidence of stack corruption during interrupt processing, and as a result register corruption. Some interruptions can still occur during interruption processing, however external interrupts are disabled and data TLB misses don't occur for absolute accesses. So, it's not entirely clear what triggers this issue. Also, if an interruption occurs when Q=0, it is generally not possible to recover as the shadowed registers are not copied. The attached patch reworks the get_stack_use_cr30 and get_stack_use_r30 macros to allocate stack before doing register saves. The new code is a couple of instructions shorter than the old implementation. Thus, it's an improvement even if it doesn't fully resolve the stack corruption issue. Based on limited testing, it improves SMP system stability. Signed-off-by: John David Anglin <dave.anglin@bell.net> Signed-off-by: Helge Deller <deller@gmx.de>
-rw-r--r--arch/parisc/include/asm/assembly.h1
-rw-r--r--arch/parisc/kernel/entry.S19
2 files changed, 10 insertions, 10 deletions
diff --git a/arch/parisc/include/asm/assembly.h b/arch/parisc/include/asm/assembly.h
index 89fb40005e3f..0da848232344 100644
--- a/arch/parisc/include/asm/assembly.h
+++ b/arch/parisc/include/asm/assembly.h
@@ -438,7 +438,6 @@
438 SAVE_SP (%sr4, PT_SR4 (\regs)) 438 SAVE_SP (%sr4, PT_SR4 (\regs))
439 SAVE_SP (%sr5, PT_SR5 (\regs)) 439 SAVE_SP (%sr5, PT_SR5 (\regs))
440 SAVE_SP (%sr6, PT_SR6 (\regs)) 440 SAVE_SP (%sr6, PT_SR6 (\regs))
441 SAVE_SP (%sr7, PT_SR7 (\regs))
442 441
443 SAVE_CR (%cr17, PT_IASQ0(\regs)) 442 SAVE_CR (%cr17, PT_IASQ0(\regs))
444 mtctl %r0, %cr17 443 mtctl %r0, %cr17
diff --git a/arch/parisc/kernel/entry.S b/arch/parisc/kernel/entry.S
index ae27cb6ce19a..e8f07dd28401 100644
--- a/arch/parisc/kernel/entry.S
+++ b/arch/parisc/kernel/entry.S
@@ -65,15 +65,11 @@
65 rsm PSW_SM_I, %r0 /* barrier for "Relied upon Translation */ 65 rsm PSW_SM_I, %r0 /* barrier for "Relied upon Translation */
66 mtsp %r0, %sr4 66 mtsp %r0, %sr4
67 mtsp %r0, %sr5 67 mtsp %r0, %sr5
68 mfsp %sr7, %r1 68 mtsp %r0, %sr6
69 or,= %r0,%r1,%r0 /* Only save sr7 in sr3 if sr7 != 0 */
70 mtsp %r1, %sr3
71 tovirt_r1 %r29 69 tovirt_r1 %r29
72 load32 KERNEL_PSW, %r1 70 load32 KERNEL_PSW, %r1
73 71
74 rsm PSW_SM_QUIET,%r0 /* second "heavy weight" ctl op */ 72 rsm PSW_SM_QUIET,%r0 /* second "heavy weight" ctl op */
75 mtsp %r0, %sr6
76 mtsp %r0, %sr7
77 mtctl %r0, %cr17 /* Clear IIASQ tail */ 73 mtctl %r0, %cr17 /* Clear IIASQ tail */
78 mtctl %r0, %cr17 /* Clear IIASQ head */ 74 mtctl %r0, %cr17 /* Clear IIASQ head */
79 mtctl %r1, %ipsw 75 mtctl %r1, %ipsw
@@ -119,17 +115,20 @@
119 115
120 /* we save the registers in the task struct */ 116 /* we save the registers in the task struct */
121 117
118 copy %r30, %r17
122 mfctl %cr30, %r1 119 mfctl %cr30, %r1
120 ldo THREAD_SZ_ALGN(%r1), %r30
121 mtsp %r0,%sr7
122 mtsp %r16,%sr3
123 tophys %r1,%r9 123 tophys %r1,%r9
124 LDREG TI_TASK(%r9), %r1 /* thread_info -> task_struct */ 124 LDREG TI_TASK(%r9), %r1 /* thread_info -> task_struct */
125 tophys %r1,%r9 125 tophys %r1,%r9
126 ldo TASK_REGS(%r9),%r9 126 ldo TASK_REGS(%r9),%r9
127 STREG %r30, PT_GR30(%r9) 127 STREG %r17,PT_GR30(%r9)
128 STREG %r29,PT_GR29(%r9) 128 STREG %r29,PT_GR29(%r9)
129 STREG %r26,PT_GR26(%r9) 129 STREG %r26,PT_GR26(%r9)
130 STREG %r16,PT_SR7(%r9)
130 copy %r9,%r29 131 copy %r9,%r29
131 mfctl %cr30, %r1
132 ldo THREAD_SZ_ALGN(%r1), %r30
133 .endm 132 .endm
134 133
135 .macro get_stack_use_r30 134 .macro get_stack_use_r30
@@ -137,10 +136,12 @@
137 /* we put a struct pt_regs on the stack and save the registers there */ 136 /* we put a struct pt_regs on the stack and save the registers there */
138 137
139 tophys %r30,%r9 138 tophys %r30,%r9
140 STREG %r30,PT_GR30(%r9) 139 copy %r30,%r1
141 ldo PT_SZ_ALGN(%r30),%r30 140 ldo PT_SZ_ALGN(%r30),%r30
141 STREG %r1,PT_GR30(%r9)
142 STREG %r29,PT_GR29(%r9) 142 STREG %r29,PT_GR29(%r9)
143 STREG %r26,PT_GR26(%r9) 143 STREG %r26,PT_GR26(%r9)
144 STREG %r16,PT_SR7(%r9)
144 copy %r9,%r29 145 copy %r9,%r29
145 .endm 146 .endm
146 147