Skip to content

Commit 7f9c974

Browse files
committed
xtensa: clean up labels in the kernel entry assembly
Don't use numeric labels for long jumps, use named local labels instead. Avoid conditional label definition. No functional changes. Signed-off-by: Max Filippov <[email protected]>
1 parent 2a26f4e commit 7f9c974

File tree

1 file changed

+53
-47
lines changed

1 file changed

+53
-47
lines changed

arch/xtensa/kernel/entry.S

Lines changed: 53 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -169,28 +169,26 @@ _user_exception:
169169

170170
/* Save only live registers. */
171171

172-
UABI_W _bbsi.l a2, 1, 1f
172+
UABI_W _bbsi.l a2, 1, .Lsave_window_registers
173173
s32i a4, a1, PT_AREG4
174174
s32i a5, a1, PT_AREG5
175175
s32i a6, a1, PT_AREG6
176176
s32i a7, a1, PT_AREG7
177-
UABI_W _bbsi.l a2, 2, 1f
177+
UABI_W _bbsi.l a2, 2, .Lsave_window_registers
178178
s32i a8, a1, PT_AREG8
179179
s32i a9, a1, PT_AREG9
180180
s32i a10, a1, PT_AREG10
181181
s32i a11, a1, PT_AREG11
182-
UABI_W _bbsi.l a2, 3, 1f
182+
UABI_W _bbsi.l a2, 3, .Lsave_window_registers
183183
s32i a12, a1, PT_AREG12
184184
s32i a13, a1, PT_AREG13
185185
s32i a14, a1, PT_AREG14
186186
s32i a15, a1, PT_AREG15
187187

188188
#if defined(USER_SUPPORT_WINDOWED)
189-
_bnei a2, 1, 1f # only one valid frame?
189+
/* If only one valid frame skip saving regs. */
190190

191-
/* Only one valid frame, skip saving regs. */
192-
193-
j 2f
191+
beqi a2, 1, common_exception
194192

195193
/* Save the remaining registers.
196194
* We have to save all registers up to the first '1' from
@@ -199,8 +197,8 @@ UABI_W _bbsi.l a2, 3, 1f
199197
* All register frames starting from the top field to the marked '1'
200198
* must be saved.
201199
*/
202-
203-
1: addi a3, a2, -1 # eliminate '1' in bit 0: yyyyxxww0
200+
.Lsave_window_registers:
201+
addi a3, a2, -1 # eliminate '1' in bit 0: yyyyxxww0
204202
neg a3, a3 # yyyyxxww0 -> YYYYXXWW1+1
205203
and a3, a3, a2 # max. only one bit is set
206204

@@ -241,7 +239,7 @@ UABI_W _bbsi.l a2, 3, 1f
241239

242240
/* We are back to the original stack pointer (a1) */
243241
#endif
244-
2: /* Now, jump to the common exception handler. */
242+
/* Now, jump to the common exception handler. */
245243

246244
j common_exception
247245

@@ -795,7 +793,7 @@ ENDPROC(kernel_exception)
795793
ENTRY(debug_exception)
796794

797795
rsr a0, SREG_EPS + XCHAL_DEBUGLEVEL
798-
bbsi.l a0, PS_EXCM_BIT, 1f # exception mode
796+
bbsi.l a0, PS_EXCM_BIT, .Ldebug_exception_in_exception # exception mode
799797

800798
/* Set EPC1 and EXCCAUSE */
801799

@@ -814,10 +812,10 @@ ENTRY(debug_exception)
814812

815813
/* Switch to kernel/user stack, restore jump vector, and save a0 */
816814

817-
bbsi.l a2, PS_UM_BIT, 2f # jump if user mode
818-
815+
bbsi.l a2, PS_UM_BIT, .Ldebug_exception_user # jump if user mode
819816
addi a2, a1, -16 - PT_KERNEL_SIZE # assume kernel stack
820-
3:
817+
818+
.Ldebug_exception_continue:
821819
l32i a0, a3, DT_DEBUG_SAVE
822820
s32i a1, a2, PT_AREG1
823821
s32i a0, a2, PT_AREG0
@@ -845,19 +843,21 @@ ENTRY(debug_exception)
845843
bbsi.l a2, PS_UM_BIT, _user_exception
846844
j _kernel_exception
847845

848-
2: rsr a2, excsave1
846+
.Ldebug_exception_user:
847+
rsr a2, excsave1
849848
l32i a2, a2, EXC_TABLE_KSTK # load kernel stack pointer
850-
j 3b
849+
j .Ldebug_exception_continue
851850

851+
.Ldebug_exception_in_exception:
852852
#ifdef CONFIG_HAVE_HW_BREAKPOINT
853853
/* Debug exception while in exception mode. This may happen when
854854
* window overflow/underflow handler or fast exception handler hits
855855
* data breakpoint, in which case save and disable all data
856856
* breakpoints, single-step faulting instruction and restore data
857857
* breakpoints.
858858
*/
859-
1:
860-
bbci.l a0, PS_UM_BIT, 1b # jump if kernel mode
859+
860+
bbci.l a0, PS_UM_BIT, .Ldebug_exception_in_exception # jump if kernel mode
861861

862862
rsr a0, debugcause
863863
bbsi.l a0, DEBUGCAUSE_DBREAK_BIT, .Ldebug_save_dbreak
@@ -901,7 +901,7 @@ ENTRY(debug_exception)
901901
rfi XCHAL_DEBUGLEVEL
902902
#else
903903
/* Debug exception while in exception mode. Should not happen. */
904-
1: j 1b // FIXME!!
904+
j .Ldebug_exception_in_exception // FIXME!!
905905
#endif
906906

907907
ENDPROC(debug_exception)
@@ -1630,12 +1630,13 @@ ENTRY(fast_second_level_miss)
16301630

16311631
GET_CURRENT(a1,a2)
16321632
l32i a0, a1, TASK_MM # tsk->mm
1633-
beqz a0, 9f
1633+
beqz a0, .Lfast_second_level_miss_no_mm
16341634

1635-
8: rsr a3, excvaddr # fault address
1635+
.Lfast_second_level_miss_continue:
1636+
rsr a3, excvaddr # fault address
16361637
_PGD_OFFSET(a0, a3, a1)
16371638
l32i a0, a0, 0 # read pmdval
1638-
beqz a0, 2f
1639+
beqz a0, .Lfast_second_level_miss_no_pmd
16391640

16401641
/* Read ptevaddr and convert to top of page-table page.
16411642
*
@@ -1678,12 +1679,13 @@ ENTRY(fast_second_level_miss)
16781679
addi a3, a3, DTLB_WAY_PGD
16791680
add a1, a1, a3 # ... + way_number
16801681

1681-
3: wdtlb a0, a1
1682+
.Lfast_second_level_miss_wdtlb:
1683+
wdtlb a0, a1
16821684
dsync
16831685

16841686
/* Exit critical section. */
1685-
1686-
4: rsr a3, excsave1
1687+
.Lfast_second_level_miss_skip_wdtlb:
1688+
rsr a3, excsave1
16871689
movi a0, 0
16881690
s32i a0, a3, EXC_TABLE_FIXUP
16891691

@@ -1707,19 +1709,21 @@ ENTRY(fast_second_level_miss)
17071709
esync
17081710
rfde
17091711

1710-
9: l32i a0, a1, TASK_ACTIVE_MM # unlikely case mm == 0
1711-
bnez a0, 8b
1712+
.Lfast_second_level_miss_no_mm:
1713+
l32i a0, a1, TASK_ACTIVE_MM # unlikely case mm == 0
1714+
bnez a0, .Lfast_second_level_miss_continue
17121715

17131716
/* Even more unlikely case active_mm == 0.
17141717
* We can get here with NMI in the middle of context_switch that
17151718
* touches vmalloc area.
17161719
*/
17171720
movi a0, init_mm
1718-
j 8b
1721+
j .Lfast_second_level_miss_continue
17191722

1723+
.Lfast_second_level_miss_no_pmd:
17201724
#if (DCACHE_WAY_SIZE > PAGE_SIZE)
17211725

1722-
2: /* Special case for cache aliasing.
1726+
/* Special case for cache aliasing.
17231727
* We (should) only get here if a clear_user_page, copy_user_page
17241728
* or the aliased cache flush functions got preemptively interrupted
17251729
* by another task. Re-establish temporary mapping to the
@@ -1729,24 +1733,24 @@ ENTRY(fast_second_level_miss)
17291733
/* We shouldn't be in a double exception */
17301734

17311735
l32i a0, a2, PT_DEPC
1732-
bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, 2f
1736+
bgeui a0, VALID_DOUBLE_EXCEPTION_ADDRESS, .Lfast_second_level_miss_slow
17331737

17341738
/* Make sure the exception originated in the special functions */
17351739

17361740
movi a0, __tlbtemp_mapping_start
17371741
rsr a3, epc1
1738-
bltu a3, a0, 2f
1742+
bltu a3, a0, .Lfast_second_level_miss_slow
17391743
movi a0, __tlbtemp_mapping_end
1740-
bgeu a3, a0, 2f
1744+
bgeu a3, a0, .Lfast_second_level_miss_slow
17411745

17421746
/* Check if excvaddr was in one of the TLBTEMP_BASE areas. */
17431747

17441748
movi a3, TLBTEMP_BASE_1
17451749
rsr a0, excvaddr
1746-
bltu a0, a3, 2f
1750+
bltu a0, a3, .Lfast_second_level_miss_slow
17471751

17481752
addi a1, a0, -TLBTEMP_SIZE
1749-
bgeu a1, a3, 2f
1753+
bgeu a1, a3, .Lfast_second_level_miss_slow
17501754

17511755
/* Check if we have to restore an ITLB mapping. */
17521756

@@ -1772,19 +1776,19 @@ ENTRY(fast_second_level_miss)
17721776

17731777
mov a0, a6
17741778
movnez a0, a7, a3
1775-
j 3b
1779+
j .Lfast_second_level_miss_wdtlb
17761780

17771781
/* ITLB entry. We only use dst in a6. */
17781782

17791783
1: witlb a6, a1
17801784
isync
1781-
j 4b
1785+
j .Lfast_second_level_miss_skip_wdtlb
17821786

17831787

17841788
#endif // DCACHE_WAY_SIZE > PAGE_SIZE
17851789

1786-
1787-
2: /* Invalid PGD, default exception handling */
1790+
/* Invalid PGD, default exception handling */
1791+
.Lfast_second_level_miss_slow:
17881792

17891793
rsr a1, depc
17901794
s32i a1, a2, PT_AREG2
@@ -1824,12 +1828,13 @@ ENTRY(fast_store_prohibited)
18241828

18251829
GET_CURRENT(a1,a2)
18261830
l32i a0, a1, TASK_MM # tsk->mm
1827-
beqz a0, 9f
1831+
beqz a0, .Lfast_store_no_mm
18281832

1829-
8: rsr a1, excvaddr # fault address
1833+
.Lfast_store_continue:
1834+
rsr a1, excvaddr # fault address
18301835
_PGD_OFFSET(a0, a1, a3)
18311836
l32i a0, a0, 0
1832-
beqz a0, 2f
1837+
beqz a0, .Lfast_store_slow
18331838

18341839
/*
18351840
* Note that we test _PAGE_WRITABLE_BIT only if PTE is present
@@ -1839,8 +1844,8 @@ ENTRY(fast_store_prohibited)
18391844
_PTE_OFFSET(a0, a1, a3)
18401845
l32i a3, a0, 0 # read pteval
18411846
movi a1, _PAGE_CA_INVALID
1842-
ball a3, a1, 2f
1843-
bbci.l a3, _PAGE_WRITABLE_BIT, 2f
1847+
ball a3, a1, .Lfast_store_slow
1848+
bbci.l a3, _PAGE_WRITABLE_BIT, .Lfast_store_slow
18441849

18451850
movi a1, _PAGE_ACCESSED | _PAGE_DIRTY | _PAGE_HW_WRITE
18461851
or a3, a3, a1
@@ -1868,7 +1873,6 @@ ENTRY(fast_store_prohibited)
18681873
l32i a2, a2, PT_DEPC
18691874

18701875
bgeui a2, VALID_DOUBLE_EXCEPTION_ADDRESS, 1f
1871-
18721876
rsr a2, depc
18731877
rfe
18741878

@@ -1878,10 +1882,12 @@ ENTRY(fast_store_prohibited)
18781882
esync
18791883
rfde
18801884

1881-
9: l32i a0, a1, TASK_ACTIVE_MM # unlikely case mm == 0
1882-
j 8b
1885+
.Lfast_store_no_mm:
1886+
l32i a0, a1, TASK_ACTIVE_MM # unlikely case mm == 0
1887+
j .Lfast_store_continue
18831888

1884-
2: /* If there was a problem, handle fault in C */
1889+
/* If there was a problem, handle fault in C */
1890+
.Lfast_store_slow:
18851891
rsr a1, excvaddr
18861892
pdtlb a0, a1
18871893
bbci.l a0, DTLB_HIT_BIT, 1f

0 commit comments

Comments
 (0)