Skip to content

Commit e7e9614

Browse files
committed
xtensa: clean up kernel exit assembly code
Don't use numeric labels for complex branching logic. Mark each branch with named local label and use them. Rearrange exit back to kernel mode to avoid conditional label definition. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent e6d423a commit e7e9614

1 file changed

Lines changed: 25 additions & 25 deletions

File tree

arch/xtensa/kernel/entry.S

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -491,9 +491,9 @@ common_exception_return:
491491
l32i abi_tmp0, a1, PT_EXCCAUSE
492492
movi abi_tmp1, EXCCAUSE_MAPPED_NMI
493493
l32i abi_saved1, a1, PT_PS
494-
beq abi_tmp0, abi_tmp1, 4f
494+
beq abi_tmp0, abi_tmp1, .Lrestore_state
495495
#endif
496-
1:
496+
.Ltif_loop:
497497
irq_save a2, a3
498498
#ifdef CONFIG_TRACE_IRQFLAGS
499499
abi_call trace_hardirqs_off
@@ -504,7 +504,7 @@ common_exception_return:
504504
l32i abi_saved1, a1, PT_PS
505505
GET_THREAD_INFO(a2, a1)
506506
l32i a4, a2, TI_FLAGS
507-
_bbci.l abi_saved1, PS_UM_BIT, 6f
507+
_bbci.l abi_saved1, PS_UM_BIT, .Lexit_tif_loop_kernel
508508

509509
/* Specific to a user exception exit:
510510
* We need to check some flags for signal handling and rescheduling,
@@ -513,12 +513,12 @@ common_exception_return:
513513
* Note that we don't disable interrupts here.
514514
*/
515515

516-
_bbsi.l a4, TIF_NEED_RESCHED, 3f
516+
_bbsi.l a4, TIF_NEED_RESCHED, .Lresched
517517
movi a2, _TIF_SIGPENDING | _TIF_NOTIFY_RESUME | _TIF_NOTIFY_SIGNAL
518-
bnone a4, a2, 5f
518+
bnone a4, a2, .Lexit_tif_loop_user
519519

520-
2: l32i a4, a1, PT_DEPC
521-
bgeui a4, VALID_DOUBLE_EXCEPTION_ADDRESS, 4f
520+
l32i a4, a1, PT_DEPC
521+
bgeui a4, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state
522522

523523
/* Call do_signal() */
524524

@@ -528,42 +528,41 @@ common_exception_return:
528528
rsil a2, 0
529529
mov abi_arg0, a1
530530
abi_call do_notify_resume # int do_notify_resume(struct pt_regs*)
531-
j 1b
532-
533-
3: /* Reschedule */
531+
j .Ltif_loop
534532

533+
.Lresched:
535534
#ifdef CONFIG_TRACE_IRQFLAGS
536535
abi_call trace_hardirqs_on
537536
#endif
538537
rsil a2, 0
539538
abi_call schedule # void schedule (void)
540-
j 1b
539+
j .Ltif_loop
541540

541+
.Lexit_tif_loop_kernel:
542542
#ifdef CONFIG_PREEMPTION
543-
6:
544-
_bbci.l a4, TIF_NEED_RESCHED, 4f
543+
_bbci.l a4, TIF_NEED_RESCHED, .Lrestore_state
545544

546545
/* Check current_thread_info->preempt_count */
547546

548547
l32i a4, a2, TI_PRE_COUNT
549-
bnez a4, 4f
548+
bnez a4, .Lrestore_state
550549
abi_call preempt_schedule_irq
551-
j 4f
552550
#endif
551+
j .Lrestore_state
553552

554-
5:
553+
.Lexit_tif_loop_user:
555554
#ifdef CONFIG_HAVE_HW_BREAKPOINT
556-
_bbci.l a4, TIF_DB_DISABLED, 7f
555+
_bbci.l a4, TIF_DB_DISABLED, 1f
557556
abi_call restore_dbreak
558-
7:
557+
1:
559558
#endif
560559
#ifdef CONFIG_DEBUG_TLB_SANITY
561560
l32i a4, a1, PT_DEPC
562-
bgeui a4, VALID_DOUBLE_EXCEPTION_ADDRESS, 4f
561+
bgeui a4, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lrestore_state
563562
abi_call check_tlb_sanity
564563
#endif
565-
6:
566-
4:
564+
565+
.Lrestore_state:
567566
#ifdef CONFIG_TRACE_IRQFLAGS
568567
extui a4, abi_saved1, PS_INTLEVEL_SHIFT, PS_INTLEVEL_WIDTH
569568
bgei a4, LOCKLEVEL, 1f
@@ -601,7 +600,7 @@ user_exception_exit:
601600
rsr a1, depc # restore stack pointer
602601
l32i a2, a1, PT_WMASK # register frames saved (in bits 4...9)
603602
rotw -1 # we restore a4..a7
604-
_bltui a6, 16, 1f # only have to restore current window?
603+
_bltui a6, 16, .Lclear_regs # only have to restore current window?
605604

606605
/* The working registers are a0 and a3. We are restoring to
607606
* a4..a7. Be careful not to destroy what we have just restored.
@@ -613,18 +612,19 @@ user_exception_exit:
613612
mov a2, a6
614613
mov a3, a5
615614

616-
2: rotw -1 # a0..a3 become a4..a7
615+
1: rotw -1 # a0..a3 become a4..a7
617616
addi a3, a7, -4*4 # next iteration
618617
addi a2, a6, -16 # decrementing Y in WMASK
619618
l32i a4, a3, PT_AREG_END + 0
620619
l32i a5, a3, PT_AREG_END + 4
621620
l32i a6, a3, PT_AREG_END + 8
622621
l32i a7, a3, PT_AREG_END + 12
623-
_bgeui a2, 16, 2b
622+
_bgeui a2, 16, 1b
624623

625624
/* Clear unrestored registers (don't leak anything to user-land */
626625

627-
1: rsr a0, windowbase
626+
.Lclear_regs:
627+
rsr a0, windowbase
628628
rsr a3, sar
629629
sub a3, a0, a3
630630
beqz a3, 2f

0 commit comments

Comments
 (0)