Skip to content

Commit b63a2bb

Browse files
danglin44hdeller
authored andcommitted
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>
1 parent d0c3be8 commit b63a2bb

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

‎arch/parisc/include/asm/assembly.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,6 @@
438438
SAVE_SP (%sr4, PT_SR4 (\regs))
439439
SAVE_SP (%sr5, PT_SR5 (\regs))
440440
SAVE_SP (%sr6, PT_SR6 (\regs))
441-
SAVE_SP (%sr7, PT_SR7 (\regs))
442441

443442
SAVE_CR (%cr17, PT_IASQ0(\regs))
444443
mtctl %r0, %cr17

‎arch/parisc/kernel/entry.S‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,11 @@
6565
rsm PSW_SM_I, %r0 /* barrier for "Relied upon Translation */
6666
mtsp %r0, %sr4
6767
mtsp %r0, %sr5
68-
mfsp %sr7, %r1
69-
or,= %r0,%r1,%r0 /* Only save sr7 in sr3 if sr7 != 0 */
70-
mtsp %r1, %sr3
68+
mtsp %r0, %sr6
7169
tovirt_r1 %r29
7270
load32 KERNEL_PSW, %r1
7371

7472
rsm PSW_SM_QUIET,%r0 /* second "heavy weight" ctl op */
75-
mtsp %r0, %sr6
76-
mtsp %r0, %sr7
7773
mtctl %r0, %cr17 /* Clear IIASQ tail */
7874
mtctl %r0, %cr17 /* Clear IIASQ head */
7975
mtctl %r1, %ipsw
@@ -119,28 +115,33 @@
119115

120116
/* we save the registers in the task struct */
121117

118+
copy %r30, %r17
122119
mfctl %cr30, %r1
120+
ldo THREAD_SZ_ALGN(%r1), %r30
121+
mtsp %r0,%sr7
122+
mtsp %r16,%sr3
123123
tophys %r1,%r9
124124
LDREG TI_TASK(%r9), %r1 /* thread_info -> task_struct */
125125
tophys %r1,%r9
126126
ldo TASK_REGS(%r9),%r9
127-
STREG %r30, PT_GR30(%r9)
127+
STREG %r17,PT_GR30(%r9)
128128
STREG %r29,PT_GR29(%r9)
129129
STREG %r26,PT_GR26(%r9)
130+
STREG %r16,PT_SR7(%r9)
130131
copy %r9,%r29
131-
mfctl %cr30, %r1
132-
ldo THREAD_SZ_ALGN(%r1), %r30
133132
.endm
134133

135134
.macro get_stack_use_r30
136135

137136
/* we put a struct pt_regs on the stack and save the registers there */
138137

139138
tophys %r30,%r9
140-
STREG %r30,PT_GR30(%r9)
139+
copy %r30,%r1
141140
ldo PT_SZ_ALGN(%r30),%r30
141+
STREG %r1,PT_GR30(%r9)
142142
STREG %r29,PT_GR29(%r9)
143143
STREG %r26,PT_GR26(%r9)
144+
STREG %r16,PT_SR7(%r9)
144145
copy %r9,%r29
145146
.endm
146147

0 commit comments

Comments
 (0)