Skip to content

Commit 50722f0

Browse files
committed
xtensa: move fast exception handlers close to vectors
On XIP kernels it makes sense to have exception vectors and fast exception handlers together (in a fast memory). In addition, with MTD XIP support both vectors and fast exception handlers must be outside of the FLASH. Add section .exception.text and move fast exception handlers to it. Put it together with vectors when vectors are outside of the .text. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
1 parent 58bc6c6 commit 50722f0

6 files changed

Lines changed: 38 additions & 13 deletions

File tree

‎arch/xtensa/include/asm/asmmacro.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,6 @@
237237
#error Unsupported Xtensa ABI
238238
#endif
239239

240+
#define __XTENSA_HANDLER .section ".exception.text", "ax"
241+
240242
#endif /* _XTENSA_ASMMACRO_H */

‎arch/xtensa/kernel/coprocessor.S‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,8 @@
5858
.endif; \
5959
.long THREAD_XTREGS_CP##x
6060

61+
__XTENSA_HANDLER
62+
6163
SAVE_CP_REGS(0)
6264
SAVE_CP_REGS(1)
6365
SAVE_CP_REGS(2)
@@ -76,7 +78,6 @@
7678
LOAD_CP_REGS(6)
7779
LOAD_CP_REGS(7)
7880

79-
.section ".rodata", "a"
8081
.align 4
8182
.Lsave_cp_regs_jump_table:
8283
SAVE_CP_REGS_TAB(0)
@@ -98,8 +99,6 @@
9899
LOAD_CP_REGS_TAB(6)
99100
LOAD_CP_REGS_TAB(7)
100101

101-
.previous
102-
103102
/*
104103
* coprocessor_flush(struct thread_info*, index)
105104
* a2 a3

‎arch/xtensa/kernel/entry.S‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -939,6 +939,9 @@ ENDPROC(unrecoverable_exception)
939939

940940
/* -------------------------- FAST EXCEPTION HANDLERS ----------------------- */
941941

942+
__XTENSA_HANDLER
943+
.literal_position
944+
942945
/*
943946
* Fast-handler for alloca exceptions
944947
*
@@ -1024,7 +1027,7 @@ ENDPROC(fast_alloca)
10241027
ENTRY(fast_illegal_instruction_user)
10251028

10261029
rsr a0, ps
1027-
bbsi.l a0, PS_WOE_BIT, user_exception
1030+
bbsi.l a0, PS_WOE_BIT, 1f
10281031
s32i a3, a2, PT_AREG3
10291032
movi a3, PS_WOE_MASK
10301033
or a0, a0, a3
@@ -1033,6 +1036,8 @@ ENTRY(fast_illegal_instruction_user)
10331036
l32i a0, a2, PT_AREG0
10341037
rsr a2, depc
10351038
rfe
1039+
1:
1040+
call0 user_exception
10361041

10371042
ENDPROC(fast_illegal_instruction_user)
10381043
#endif
@@ -1071,7 +1076,7 @@ ENTRY(fast_syscall_user)
10711076
_beqz a0, fast_syscall_spill_registers
10721077
_beqi a0, __NR_xtensa, fast_syscall_xtensa
10731078

1074-
j user_exception
1079+
call0 user_exception
10751080

10761081
ENDPROC(fast_syscall_user)
10771082

@@ -1762,8 +1767,8 @@ ENTRY(fast_second_level_miss)
17621767

17631768
rsr a2, ps
17641769
bbsi.l a2, PS_UM_BIT, 1f
1765-
j _kernel_exception
1766-
1: j _user_exception
1770+
call0 _kernel_exception
1771+
1: call0 _user_exception
17671772

17681773
ENDPROC(fast_second_level_miss)
17691774

@@ -1859,13 +1864,14 @@ ENTRY(fast_store_prohibited)
18591864

18601865
rsr a2, ps
18611866
bbsi.l a2, PS_UM_BIT, 1f
1862-
j _kernel_exception
1863-
1: j _user_exception
1867+
call0 _kernel_exception
1868+
1: call0 _user_exception
18641869

18651870
ENDPROC(fast_store_prohibited)
18661871

18671872
#endif /* CONFIG_MMU */
18681873

1874+
.text
18691875
/*
18701876
* System Calls.
18711877
*

‎arch/xtensa/kernel/setup.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,8 @@ extern char _UserExceptionVector_text_start;
284284
extern char _UserExceptionVector_text_end;
285285
extern char _DoubleExceptionVector_text_start;
286286
extern char _DoubleExceptionVector_text_end;
287+
extern char _exception_text_start;
288+
extern char _exception_text_end;
287289
#if XCHAL_EXCM_LEVEL >= 2
288290
extern char _Level2InterruptVector_text_start;
289291
extern char _Level2InterruptVector_text_end;
@@ -363,6 +365,8 @@ void __init setup_arch(char **cmdline_p)
363365
mem_reserve(__pa(&_DoubleExceptionVector_text_start),
364366
__pa(&_DoubleExceptionVector_text_end));
365367

368+
mem_reserve(__pa(&_exception_text_start),
369+
__pa(&_exception_text_end));
366370
#if XCHAL_EXCM_LEVEL >= 2
367371
mem_reserve(__pa(&_Level2InterruptVector_text_start),
368372
__pa(&_Level2InterruptVector_text_end));

‎arch/xtensa/kernel/vectors.S‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
*/
4444

4545
#include <linux/linkage.h>
46+
#include <asm/asmmacro.h>
4647
#include <asm/ptrace.h>
4748
#include <asm/current.h>
4849
#include <asm/asm-offsets.h>
@@ -477,7 +478,6 @@ _DoubleExceptionVector_handle_exception:
477478

478479
ENDPROC(_DoubleExceptionVector)
479480

480-
.text
481481
/*
482482
* Fixup handler for TLB miss in double exception handler for window owerflow.
483483
* We get here with windowbase set to the window that was being spilled and
@@ -505,6 +505,7 @@ ENDPROC(_DoubleExceptionVector)
505505
* a3: exctable, original value in excsave1
506506
*/
507507

508+
__XTENSA_HANDLER
508509
.literal_position
509510

510511
ENTRY(window_overflow_restore_a0_fixup)

‎arch/xtensa/kernel/vmlinux.lds.S‎

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ SECTIONS
110110
SECTION_VECTOR (.KernelExceptionVector.text, KERNEL_VECTOR_VADDR)
111111
SECTION_VECTOR (.UserExceptionVector.text, USER_VECTOR_VADDR)
112112
SECTION_VECTOR (.DoubleExceptionVector.text, DOUBLEEXC_VECTOR_VADDR)
113+
114+
*(.exception.text)
113115
#endif
114116

115117
IRQENTRY_TEXT
@@ -190,6 +192,8 @@ SECTIONS
190192
.DoubleExceptionVector.text);
191193
RELOCATE_ENTRY(_DebugInterruptVector_text,
192194
.DebugInterruptVector.text);
195+
RELOCATE_ENTRY(_exception_text,
196+
.exception.text);
193197
#endif
194198
#ifdef CONFIG_XIP_KERNEL
195199
RELOCATE_ENTRY(_xip_data, .data);
@@ -282,8 +286,7 @@ SECTIONS
282286
.DoubleExceptionVector.text,
283287
DOUBLEEXC_VECTOR_VADDR,
284288
.UserExceptionVector.text)
285-
286-
. = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;
289+
#define LAST .DoubleExceptionVector.text
287290

288291
#endif
289292
#if !defined(CONFIG_XIP_KERNEL) && defined(CONFIG_SMP)
@@ -292,10 +295,20 @@ SECTIONS
292295
.SecondaryResetVector.text,
293296
RESET_VECTOR1_VADDR,
294297
.DoubleExceptionVector.text)
298+
#undef LAST
299+
#define LAST .SecondaryResetVector.text
295300

296-
. = LOADADDR(.SecondaryResetVector.text)+SIZEOF(.SecondaryResetVector.text);
301+
#endif
302+
#ifdef CONFIG_VECTORS_OFFSET
303+
SECTION_VECTOR (_exception_text,
304+
.exception.text,
305+
,
306+
LAST)
307+
#undef LAST
308+
#define LAST .exception.text
297309

298310
#endif
311+
. = (LOADADDR(LAST) + SIZEOF(LAST) + 3) & ~ 3;
299312

300313
. = ALIGN(PAGE_SIZE);
301314

0 commit comments

Comments
 (0)