Skip to content

Commit 29c4dfd

Browse files
committed
[XTENSA] Remove non-rt signal handling
The non-rt signal handling was never really used, so we don't break anything. This patch also cleans up the signal stack-frame to make it independent from the processor configuration. It also improves the method used for controlling single-stepping. We now save and restore the 'icountlevel' register that controls single stepping and set or clear the saved state to enable or disable it. Signed-off-by: Chris Zankel <chris@zankel.net>
1 parent adba09f commit 29c4dfd

8 files changed

Lines changed: 350 additions & 524 deletions

File tree

‎arch/xtensa/kernel/asm-offsets.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ int main(void)
3939
DEFINE(PT_LEND, offsetof (struct pt_regs, lend));
4040
DEFINE(PT_LCOUNT, offsetof (struct pt_regs, lcount));
4141
DEFINE(PT_SAR, offsetof (struct pt_regs, sar));
42+
DEFINE(PT_ICOUNTLEVEL, offsetof (struct pt_regs, icountlevel));
4243
DEFINE(PT_SYSCALL, offsetof (struct pt_regs, syscall));
4344
DEFINE(PT_AREG, offsetof (struct pt_regs, areg[0]));
4445
DEFINE(PT_AREG0, offsetof (struct pt_regs, areg[0]));

‎arch/xtensa/kernel/entry.S‎

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ _user_exception:
125125

126126
movi a2, 0
127127
rsr a3, SAR
128-
wsr a2, ICOUNTLEVEL
128+
xsr a2, ICOUNTLEVEL
129129
s32i a3, a1, PT_SAR
130+
s32i a2, a1, PT_ICOUNTLEVEL
130131

131132
/* Rotate ws so that the current windowbase is at bit0. */
132133
/* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */
@@ -276,8 +277,9 @@ _kernel_exception:
276277

277278
movi a2, 0
278279
rsr a3, SAR
279-
wsr a2, ICOUNTLEVEL
280+
xsr a2, ICOUNTLEVEL
280281
s32i a3, a1, PT_SAR
282+
s32i a2, a1, PT_ICOUNTLEVEL
281283

282284
/* Rotate ws so that the current windowbase is at bit0. */
283285
/* Assume ws = xxwww1yyyy. Rotate ws right, so that a2 = yyyyxxwww1 */
@@ -330,14 +332,16 @@ _kernel_exception:
330332

331333
common_exception:
332334

333-
/* Save EXCVADDR, DEBUGCAUSE, and PC, and clear LCOUNT */
335+
/* Save some registers, disable loops and clear the syscall flag. */
334336

335337
rsr a2, DEBUGCAUSE
336338
rsr a3, EPC_1
337339
s32i a2, a1, PT_DEBUGCAUSE
338340
s32i a3, a1, PT_PC
339341

342+
movi a2, -1
340343
rsr a3, EXCVADDR
344+
s32i a2, a1, PT_SYSCALL
341345
movi a2, 0
342346
s32i a3, a1, PT_EXCVADDR
343347
xsr a2, LCOUNT
@@ -450,27 +454,8 @@ common_exception_return:
450454

451455
/* Restore the state of the task and return from the exception. */
452456

453-
454-
/* If we are returning from a user exception, and the process
455-
* to run next has PT_SINGLESTEP set, we want to setup
456-
* ICOUNT and ICOUNTLEVEL to step one instruction.
457-
* PT_SINGLESTEP is set by sys_ptrace (ptrace.c)
458-
*/
459-
460457
4: /* a2 holds GET_CURRENT(a2,a1) */
461458

462-
l32i a3, a2, TI_TASK
463-
l32i a3, a3, TASK_PTRACE
464-
bbci.l a3, PT_SINGLESTEP_BIT, 1f # jump if single-step flag is not set
465-
466-
movi a3, -2 # PT_SINGLESTEP flag is set,
467-
movi a4, 1 # icountlevel of 1 means it won't
468-
wsr a3, ICOUNT # start counting until after rfe
469-
wsr a4, ICOUNTLEVEL # so setup icount & icountlevel.
470-
isync
471-
472-
1:
473-
474459
#if XCHAL_EXTRA_SA_SIZE
475460

476461
/* For user exceptions, restore the extra state from the user's TCB. */
@@ -665,6 +650,13 @@ common_exception_exit:
665650
wsr a3, LEND
666651
wsr a2, LCOUNT
667652

653+
/* We control single stepping through the ICOUNTLEVEL register. */
654+
655+
l32i a2, a1, PT_ICOUNTLEVEL
656+
movi a3, -2
657+
wsr a2, ICOUNTLEVEL
658+
wsr a3, ICOUNT
659+
668660
/* Check if it was double exception. */
669661

670662
l32i a0, a1, PT_DEPC

0 commit comments

Comments
 (0)