Skip to content

Commit da0a4e5

Browse files
committed
xtensa: only build windowed register support code when needed
There's no need in window overflow/underflow/alloca exception handlers or window spill code when neither kernel nor userspace support windowed registers. Don't build or link it. Signed-off-by: Max Filippov <[email protected]>
1 parent 09af39f commit da0a4e5

File tree

7 files changed

+45
-5
lines changed

7 files changed

+45
-5
lines changed

arch/xtensa/include/asm/traps.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ void secondary_trap_init(void);
5656

5757
static inline void spill_registers(void)
5858
{
59+
#if defined(__XTENSA_WINDOWED_ABI__)
5960
#if XCHAL_NUM_AREGS > 16
6061
__asm__ __volatile__ (
6162
" call8 1f\n"
@@ -96,6 +97,7 @@ static inline void spill_registers(void)
9697
" mov a12, a12\n"
9798
: : : "memory");
9899
#endif
100+
#endif
99101
}
100102

101103
struct debug_table {

arch/xtensa/kernel/entry.S

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -969,6 +969,7 @@ ENDPROC(unrecoverable_exception)
969969
__XTENSA_HANDLER
970970
.literal_position
971971

972+
#ifdef SUPPORT_WINDOWED
972973
/*
973974
* Fast-handler for alloca exceptions
974975
*
@@ -1032,6 +1033,7 @@ ENTRY(fast_alloca)
10321033
8: j _WindowUnderflow8
10331034
4: j _WindowUnderflow4
10341035
ENDPROC(fast_alloca)
1036+
#endif
10351037

10361038
#ifdef CONFIG_USER_ABI_CALL0_PROBE
10371039
/*
@@ -1228,7 +1230,8 @@ ENDPROC(fast_syscall_xtensa)
12281230
* Note: We assume the stack pointer is EXC_TABLE_KSTK in the fixup handler.
12291231
*/
12301232

1231-
#ifdef CONFIG_FAST_SYSCALL_SPILL_REGISTERS
1233+
#if defined(CONFIG_FAST_SYSCALL_SPILL_REGISTERS) && \
1234+
defined(USER_SUPPORT_WINDOWED)
12321235

12331236
ENTRY(fast_syscall_spill_registers)
12341237

arch/xtensa/kernel/setup.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,10 @@ void __init setup_arch(char **cmdline_p)
349349
#endif
350350

351351
#ifdef CONFIG_VECTORS_ADDR
352+
#ifdef SUPPORT_WINDOWED
352353
mem_reserve(__pa(&_WindowVectors_text_start),
353354
__pa(&_WindowVectors_text_end));
355+
#endif
354356

355357
mem_reserve(__pa(&_DebugInterruptVector_text_start),
356358
__pa(&_DebugInterruptVector_text_end));

arch/xtensa/kernel/signal.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,13 @@ struct rt_sigframe
4545
unsigned int window[4];
4646
};
4747

48-
/*
48+
#if defined(USER_SUPPORT_WINDOWED)
49+
/*
4950
* Flush register windows stored in pt_regs to stack.
5051
* Returns 1 for errors.
5152
*/
5253

53-
int
54+
static int
5455
flush_window_regs_user(struct pt_regs *regs)
5556
{
5657
const unsigned long ws = regs->windowstart;
@@ -121,6 +122,13 @@ flush_window_regs_user(struct pt_regs *regs)
121122
errout:
122123
return err;
123124
}
125+
#else
126+
static int
127+
flush_window_regs_user(struct pt_regs *regs)
128+
{
129+
return 0;
130+
}
131+
#endif
124132

125133
/*
126134
* Note: We don't copy double exception 'regs', we have to finish double exc.

arch/xtensa/kernel/traps.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ static dispatch_init_table_t __initdata dispatch_init_table[] = {
9797
/* EXCCAUSE_INSTRUCTION_FETCH unhandled */
9898
/* EXCCAUSE_LOAD_STORE_ERROR unhandled*/
9999
{ EXCCAUSE_LEVEL1_INTERRUPT, 0, do_interrupt },
100+
#ifdef SUPPORT_WINDOWED
100101
{ EXCCAUSE_ALLOCA, USER|KRNL, fast_alloca },
102+
#endif
101103
/* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */
102104
/* EXCCAUSE_PRIVILEGED unhandled */
103105
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION

arch/xtensa/kernel/vectors.S

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ ENTRY(_DoubleExceptionVector)
226226

227227
xsr a0, depc # get DEPC, save a0
228228

229+
#ifdef SUPPORT_WINDOWED
229230
movi a2, WINDOW_VECTORS_VADDR
230231
_bltu a0, a2, .Lfixup
231232
addi a2, a2, WINDOW_VECTORS_SIZE
@@ -275,6 +276,10 @@ _DoubleExceptionVector_WindowUnderflow:
275276
l32i a0, a0, EXC_TABLE_FAST_USER
276277
jx a0
277278

279+
#else
280+
j .Lfixup
281+
#endif
282+
278283
/*
279284
* We only allow the ITLB miss exception if we are in kernel space.
280285
* All other exceptions are unexpected and thus unrecoverable!
@@ -343,6 +348,7 @@ _DoubleExceptionVector_WindowUnderflow:
343348
l32i a0, a0, EXC_TABLE_FAST_USER
344349
jx a0
345350

351+
#ifdef SUPPORT_WINDOWED
346352
/*
347353
* Restart window OVERFLOW exception.
348354
* Currently:
@@ -475,9 +481,12 @@ _DoubleExceptionVector_handle_exception:
475481
rsr a0, depc
476482
rotw -3
477483
j 1b
484+
#endif
478485

479486
ENDPROC(_DoubleExceptionVector)
480487

488+
#ifdef SUPPORT_WINDOWED
489+
481490
/*
482491
* Fixup handler for TLB miss in double exception handler for window owerflow.
483492
* We get here with windowbase set to the window that was being spilled and
@@ -590,6 +599,8 @@ ENTRY(window_overflow_restore_a0_fixup)
590599

591600
ENDPROC(window_overflow_restore_a0_fixup)
592601

602+
#endif
603+
593604
/*
594605
* Debug interrupt vector
595606
*
@@ -687,6 +698,8 @@ _SimulateUserKernelVectorException:
687698
.section .WindowVectors.text, "ax"
688699

689700

701+
#ifdef SUPPORT_WINDOWED
702+
690703
/* 4-Register Window Overflow Vector (Handler) */
691704

692705
ENTRY_ALIGN64(_WindowOverflow4)
@@ -787,4 +800,6 @@ ENTRY_ALIGN64(_WindowUnderflow12)
787800

788801
ENDPROC(_WindowUnderflow12)
789802

803+
#endif
804+
790805
.text

arch/xtensa/kernel/vmlinux.lds.S

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ SECTIONS
9494
. = ALIGN(PAGE_SIZE);
9595
_vecbase = .;
9696

97+
#ifdef SUPPORT_WINDOWED
9798
SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR)
99+
#endif
98100
#if XCHAL_EXCM_LEVEL >= 2
99101
SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
100102
#endif
@@ -166,8 +168,10 @@ SECTIONS
166168
__boot_reloc_table_start = ABSOLUTE(.);
167169

168170
#if !MERGED_VECTORS
171+
#ifdef SUPPORT_WINDOWED
169172
RELOCATE_ENTRY(_WindowVectors_text,
170173
.WindowVectors.text);
174+
#endif
171175
#if XCHAL_EXCM_LEVEL >= 2
172176
RELOCATE_ENTRY(_Level2InterruptVector_text,
173177
.Level2InterruptVector.text);
@@ -229,14 +233,18 @@ SECTIONS
229233
#if !MERGED_VECTORS
230234
/* The vectors are relocated to the real position at startup time */
231235

236+
#ifdef SUPPORT_WINDOWED
232237
SECTION_VECTOR4 (_WindowVectors_text,
233238
.WindowVectors.text,
234239
WINDOW_VECTORS_VADDR,
235-
.dummy)
240+
LAST)
241+
#undef LAST
242+
#define LAST .WindowVectors.text
243+
#endif
236244
SECTION_VECTOR4 (_DebugInterruptVector_text,
237245
.DebugInterruptVector.text,
238246
DEBUG_VECTOR_VADDR,
239-
.WindowVectors.text)
247+
LAST)
240248
#undef LAST
241249
#define LAST .DebugInterruptVector.text
242250
#if XCHAL_EXCM_LEVEL >= 2

0 commit comments

Comments
 (0)