Skip to content

Commit 6bf9891

Browse files
hujun260xiaoxiang781216
authored andcommitted
system/signal: in interrupting the context, regs modify logic error
In the interrupt context, we should first save the interrupt context and modify the interrupt register to execute the signal processing program immediately after exiting the current interrupt Signed-off-by: hujun5 <[email protected]>
1 parent 16fc1b4 commit 6bf9891

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

arch/arm64/src/common/arm64_schedulesigaction.c

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,15 @@
4646
* Public Functions
4747
****************************************************************************/
4848

49-
void arm64_init_signal_process(struct tcb_s *tcb)
49+
void arm64_init_signal_process(struct tcb_s *tcb, struct regs_context *regs)
5050
{
51-
struct regs_context *pctx = (struct regs_context *)tcb->xcp.regs;
51+
/****************************************************************************
52+
* if regs != NULL We are interrupting the context,
53+
* we should modify the regs
54+
****************************************************************************/
55+
56+
struct regs_context *pctx = (regs != NULL) ? regs :
57+
(struct regs_context *)tcb->xcp.regs;
5258
struct regs_context *psigctx;
5359
char *stack_ptr = (char *)pctx->sp_elx;
5460

@@ -162,11 +168,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
162168

163169
/* create signal process context */
164170

165-
tcb->xcp.saved_reg = tcb->xcp.regs;
171+
tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS;
166172
#ifdef CONFIG_ARCH_FPU
167173
tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs;
168174
#endif
169-
arm64_init_signal_process(tcb);
175+
arm64_init_signal_process(tcb,
176+
(struct regs_context *)CURRENT_REGS);
170177

171178
/* trigger switch to signal process */
172179

@@ -193,7 +200,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
193200
/* create signal process context */
194201

195202
tcb->xcp.saved_reg = tcb->xcp.regs;
196-
arm64_init_signal_process(tcb);
203+
arm64_init_signal_process(tcb, NULL);
197204
}
198205
}
199206
}
@@ -276,7 +283,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
276283
/* create signal process context */
277284

278285
tcb->xcp.saved_reg = tcb->xcp.regs;
279-
arm64_init_signal_process(tcb);
286+
arm64_init_signal_process(tcb, NULL);
280287
}
281288
else
282289
{
@@ -292,11 +299,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
292299

293300
/* create signal process context */
294301

295-
tcb->xcp.saved_reg = tcb->xcp.regs;
302+
tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS;
296303
#ifdef CONFIG_ARCH_FPU
297304
tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs;
298305
#endif
299-
arm64_init_signal_process(tcb);
306+
arm64_init_signal_process(tcb,
307+
(struct regs_context *)CURRENT_REGS);
300308

301309
/* trigger switch to signal process */
302310

@@ -347,7 +355,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
347355

348356
/* create signal process context */
349357

350-
arm64_init_signal_process(tcb);
358+
arm64_init_signal_process(tcb, NULL);
351359

352360
/* Increment the IRQ lock count so that when the task is restarted,
353361
* it will hold the IRQ spinlock.

0 commit comments

Comments
 (0)