Skip to content

Commit 3cb5ed4

Browse files
mrutland-armwilldeacon
authored andcommitted
arm64: entry: prepare ret_to_user for function call
In a subsequent patch ret_to_user will need to make a C function call (in some configurations) which may clobber x0-x18 at the start of the finish_ret_to_user block, before enable_step_tsk consumes the flags loaded into x1. In preparation for this, let's load the flags into x19, which is preserved across C function calls. This avoids a redundant reload of the flags and ensures we operate on a consistent shapshot regardless. There should be no functional change as a result of this patch. At this point of the entry/exit paths we only need to preserve x28 (tsk) and the sp, and x19 is free for this use. Signed-off-by: Mark Rutland <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: James Morse <[email protected]> Cc: Will Deacon <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Will Deacon <[email protected]>
1 parent 2f911d4 commit 3cb5ed4

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

arch/arm64/kernel/entry.S

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -774,13 +774,13 @@ SYM_CODE_END(el0_error)
774774
SYM_CODE_START_LOCAL(ret_to_user)
775775
disable_daif
776776
gic_prio_kentry_setup tmp=x3
777-
ldr x1, [tsk, #TSK_TI_FLAGS]
778-
and x2, x1, #_TIF_WORK_MASK
777+
ldr x19, [tsk, #TSK_TI_FLAGS]
778+
and x2, x19, #_TIF_WORK_MASK
779779
cbnz x2, work_pending
780780
finish_ret_to_user:
781781
/* Ignore asynchronous tag check faults in the uaccess routines */
782782
clear_mte_async_tcf
783-
enable_step_tsk x1, x2
783+
enable_step_tsk x19, x2
784784
#ifdef CONFIG_GCC_PLUGIN_STACKLEAK
785785
bl stackleak_erase
786786
#endif
@@ -791,11 +791,12 @@ finish_ret_to_user:
791791
*/
792792
work_pending:
793793
mov x0, sp // 'regs'
794+
mov x1, x19
794795
bl do_notify_resume
795796
#ifdef CONFIG_TRACE_IRQFLAGS
796797
bl trace_hardirqs_on // enabled while in userspace
797798
#endif
798-
ldr x1, [tsk, #TSK_TI_FLAGS] // re-check for single-step
799+
ldr x19, [tsk, #TSK_TI_FLAGS] // re-check for single-step
799800
b finish_ret_to_user
800801
SYM_CODE_END(ret_to_user)
801802

0 commit comments

Comments
 (0)