arm64: switch to the IRQ stack during ISR execution
Avoid executing ISRs using the thread stack as it might not be sized for that. Plus, we do have IRQ stacks already set up for us. The non-nested IRQ context is still (and has to be) saved on the thread stack as the thread could be preempted. The irq_offload case is never nested and always invoked with the sched_lock held so it can be simplified a bit. Signed-off-by: Nicolas Pitre <npitre@baylibre.com>
This commit is contained in:
parent
6381ee7391
commit
34d425fbe5
2 changed files with 24 additions and 7 deletions
|
@ -38,6 +38,14 @@ SECTION_FUNC(TEXT, _isr_wrapper)
|
|||
add w1, w1, #1
|
||||
str w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
|
||||
/* If not nested: switch to IRQ stack and save current sp on it. */
|
||||
cmp w1, #1
|
||||
bne 1f
|
||||
ldr x1, [x0, #___cpu_t_irq_stack_OFFSET]
|
||||
mov x2, sp
|
||||
mov sp, x1
|
||||
str x2, [sp, #-16]!
|
||||
1:
|
||||
#ifdef CONFIG_SCHED_THREAD_USAGE
|
||||
bl z_sched_usage_stop
|
||||
#endif
|
||||
|
@ -107,6 +115,10 @@ spurious_continue:
|
|||
str w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
bne exit
|
||||
|
||||
/* No more nested: retrieve the task's stack. */
|
||||
ldr x0, [sp]
|
||||
mov sp, x0
|
||||
|
||||
/*
|
||||
* z_arch_get_next_switch_handle() is returning:
|
||||
*
|
||||
|
|
|
@ -147,19 +147,24 @@ SECTION_FUNC(TEXT, z_arm64_sync_exc)
|
|||
beq offload
|
||||
b inv
|
||||
offload:
|
||||
/* ++_current_cpu->nested to be checked by arch_is_in_isr() */
|
||||
/* _current_cpu->nested=1, to be checked by arch_is_in_isr() */
|
||||
get_cpu x0
|
||||
ldr w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
add w1, w1, #1
|
||||
mov w1, #1
|
||||
str w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
/* switch to IRQ stack and save current sp on it. */
|
||||
ldr x1, [x0, #___cpu_t_irq_stack_OFFSET]
|
||||
mov x2, sp
|
||||
mov sp, x1
|
||||
str x2, [sp, #-16]!
|
||||
|
||||
bl z_irq_do_offload
|
||||
|
||||
/* --_current_cpu->nested */
|
||||
/* _current_cpu->nested=0 */
|
||||
get_cpu x0
|
||||
ldr w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
sub w1, w1, #1
|
||||
str w1, [x0, #___cpu_t_nested_OFFSET]
|
||||
str wzr, [x0, #___cpu_t_nested_OFFSET]
|
||||
/* restore original stack pointer. */
|
||||
ldr x1, [sp]
|
||||
mov sp, x1
|
||||
b z_arm64_exit_exc
|
||||
#endif
|
||||
b inv
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue