Commit 961c5efb authored by Max Filippov's avatar Max Filippov
Browse files

xtensa: use abi_* register names in the kernel exit code



Using plain register names is prone to errors when code is changed and
new calls are added between the register load and use. Change plain
register names to abi_* names in the call-heavy part of the kernel exit
code to clearly indicate what's supposed to be preserved and what's not.
Re-align code while at it.

Signed-off-by: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent de4415d0
Loading
Loading
Loading
Loading
+42 −40
Original line number Diff line number Diff line
@@ -483,7 +483,7 @@ common_exception_return:
	beq		abi_tmp0, abi_tmp1, .Lrestore_state
#endif
.Ltif_loop:
	irq_save a2, a3
	irq_save	abi_tmp0, abi_tmp1
#ifdef CONFIG_TRACE_IRQFLAGS
	abi_call	trace_hardirqs_off
#endif
@@ -491,8 +491,8 @@ common_exception_return:
	/* Jump if we are returning from kernel exceptions. */

	l32i		abi_saved1, a1, PT_PS
	GET_THREAD_INFO(a2, a1)
	l32i	a4, a2, TI_FLAGS
	GET_THREAD_INFO(abi_tmp0, a1)
	l32i		abi_saved0, abi_tmp0, TI_FLAGS
	_bbci.l		abi_saved1, PS_UM_BIT, .Lexit_tif_loop_kernel

	/* Specific to a user exception exit:
@@ -502,19 +502,19 @@ common_exception_return:
	 * Note that we don't disable interrupts here. 
	 */

	_bbsi.l	a4, TIF_NEED_RESCHED, .Lresched
	movi	a2, _TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL
	bnone	a4, a2, .Lexit_tif_loop_user
	_bbsi.l		abi_saved0, TIF_NEED_RESCHED, .Lresched
	movi		abi_tmp0, _TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL
	bnone		abi_saved0, abi_tmp0, .Lexit_tif_loop_user

	l32i	a4, a1, PT_DEPC
	bgeui	a4, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state
	l32i		abi_tmp0, a1, PT_DEPC
	bgeui		abi_tmp0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state

	/* Call do_signal() */

#ifdef CONFIG_TRACE_IRQFLAGS
	abi_call	trace_hardirqs_on
#endif
	rsil	a2, 0
	rsil		abi_tmp0, 0
	mov		abi_arg0, a1
	abi_call	do_notify_resume	# int do_notify_resume(struct pt_regs*)
	j		.Ltif_loop
@@ -523,53 +523,55 @@ common_exception_return:
#ifdef CONFIG_TRACE_IRQFLAGS
	abi_call	trace_hardirqs_on
#endif
	rsil	a2, 0
	rsil		abi_tmp0, 0
	abi_call	schedule	# void schedule (void)
	j		.Ltif_loop

.Lexit_tif_loop_kernel:
#ifdef CONFIG_PREEMPTION
	_bbci.l	a4, TIF_NEED_RESCHED, .Lrestore_state
	_bbci.l		abi_saved0, TIF_NEED_RESCHED, .Lrestore_state

	/* Check current_thread_info->preempt_count */

	l32i	a4, a2, TI_PRE_COUNT
	bnez	a4, .Lrestore_state
	l32i		abi_tmp1, abi_tmp0, TI_PRE_COUNT
	bnez		abi_tmp1, .Lrestore_state
	abi_call	preempt_schedule_irq
#endif
	j		.Lrestore_state

.Lexit_tif_loop_user:
#ifdef CONFIG_HAVE_HW_BREAKPOINT
	_bbci.l	a4, TIF_DB_DISABLED, 1f
	_bbci.l		abi_saved0, TIF_DB_DISABLED, 1f
	abi_call	restore_dbreak
1:
#endif
#ifdef CONFIG_DEBUG_TLB_SANITY
	l32i	a4, a1, PT_DEPC
	bgeui	a4, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state
	l32i		abi_tmp0, a1, PT_DEPC
	bgeui		abi_tmp0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state
	abi_call	check_tlb_sanity
#endif

.Lrestore_state:
#ifdef CONFIG_TRACE_IRQFLAGS
	extui	a4, abi_saved1, PS_INTLEVEL_SHIFT, PS_INTLEVEL_WIDTH
	bgei	a4, LOCKLEVEL, 1f
	extui		abi_tmp0, abi_saved1, PS_INTLEVEL_SHIFT, PS_INTLEVEL_WIDTH
	bgei		abi_tmp0, LOCKLEVEL, 1f
	abi_call	trace_hardirqs_on
1:
#endif
	/* Restore optional registers. */
	/*
	 * Restore optional registers.
	 * abi_arg* are used as temporary registers here.
	 */

	load_xtregs_opt a1 a2 a4 a5 a6 a7 PT_XTREGS_OPT
	load_xtregs_opt a1 abi_tmp0 abi_arg0 abi_arg1 abi_arg2 abi_arg3 PT_XTREGS_OPT

	/* Restore SCOMPARE1 */

#if XCHAL_HAVE_S32C1I
	l32i    a2, a1, PT_SCOMPARE1
	wsr     a2, scompare1
	l32i		abi_tmp0, a1, PT_SCOMPARE1
	wsr		abi_tmp0, scompare1
#endif
	wsr		abi_saved1, ps		/* disable interrupts */

	_bbci.l		abi_saved1, PS_UM_BIT, kernel_exception_exit

user_exception_exit: