diff options
author | Chris Metcalf <cmetcalf@mellanox.com> | 2016-07-14 16:48:14 -0400 |
---|---|---|
committer | Will Deacon <will.deacon@arm.com> | 2016-08-22 05:00:48 -0400 |
commit | 421dd6fa6709ebee4f888ed89da5c103c77caee1 (patch) | |
tree | 2ee670bc18f5fbe691906340c0a54b42f7f2635a /arch/arm64/kernel/entry.S | |
parent | 0a7d87a7776e2616334473c4209e277b6ca300e5 (diff) |
arm64: factor work_pending state machine to C
Currently ret_fast_syscall, work_pending, and ret_to_user form an ad-hoc
state machine that can be difficult to reason about due to duplicated
code and a large number of branch targets.
This patch factors the common logic out into the existing
do_notify_resume function, converting the code to C in the process,
making the code more legible.
This patch tries to closely mirror the existing behaviour while using
the usual C control flow primitives. As local_irq_{disable,enable} may
be instrumented, we balance exception entry (where we will almost most
likely enable IRQs) with a call to trace_hardirqs_on just before the
return to userspace.
Signed-off-by: Chris Metcalf <cmetcalf@mellanox.com>
Signed-off-by: Will Deacon <will.deacon@arm.com>
Diffstat (limited to 'arch/arm64/kernel/entry.S')
-rw-r--r-- | arch/arm64/kernel/entry.S | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/arch/arm64/kernel/entry.S b/arch/arm64/kernel/entry.S index 441420ca7d08..6a64182822e5 100644 --- a/arch/arm64/kernel/entry.S +++ b/arch/arm64/kernel/entry.S | |||
@@ -707,18 +707,13 @@ ret_fast_syscall_trace: | |||
707 | * Ok, we need to do extra processing, enter the slow path. | 707 | * Ok, we need to do extra processing, enter the slow path. |
708 | */ | 708 | */ |
709 | work_pending: | 709 | work_pending: |
710 | tbnz x1, #TIF_NEED_RESCHED, work_resched | ||
711 | /* TIF_SIGPENDING, TIF_NOTIFY_RESUME or TIF_FOREIGN_FPSTATE case */ | ||
712 | mov x0, sp // 'regs' | 710 | mov x0, sp // 'regs' |
713 | enable_irq // enable interrupts for do_notify_resume() | ||
714 | bl do_notify_resume | 711 | bl do_notify_resume |
715 | b ret_to_user | ||
716 | work_resched: | ||
717 | #ifdef CONFIG_TRACE_IRQFLAGS | 712 | #ifdef CONFIG_TRACE_IRQFLAGS |
718 | bl trace_hardirqs_off // the IRQs are off here, inform the tracing code | 713 | bl trace_hardirqs_on // enabled while in userspace |
719 | #endif | 714 | #endif |
720 | bl schedule | 715 | ldr x1, [tsk, #TI_FLAGS] // re-check for single-step |
721 | 716 | b finish_ret_to_user | |
722 | /* | 717 | /* |
723 | * "slow" syscall return path. | 718 | * "slow" syscall return path. |
724 | */ | 719 | */ |
@@ -727,6 +722,7 @@ ret_to_user: | |||
727 | ldr x1, [tsk, #TI_FLAGS] | 722 | ldr x1, [tsk, #TI_FLAGS] |
728 | and x2, x1, #_TIF_WORK_MASK | 723 | and x2, x1, #_TIF_WORK_MASK |
729 | cbnz x2, work_pending | 724 | cbnz x2, work_pending |
725 | finish_ret_to_user: | ||
730 | enable_step_tsk x1, x2 | 726 | enable_step_tsk x1, x2 |
731 | kernel_exit 0 | 727 | kernel_exit 0 |
732 | ENDPROC(ret_to_user) | 728 | ENDPROC(ret_to_user) |