Commit da0a4e5c authored by Max Filippov's avatar Max Filippov

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: default avatarMax Filippov <jcmvbkbc@gmail.com>
parent 09af39f6
...@@ -56,6 +56,7 @@ void secondary_trap_init(void); ...@@ -56,6 +56,7 @@ void secondary_trap_init(void);
static inline void spill_registers(void) static inline void spill_registers(void)
{ {
#if defined(__XTENSA_WINDOWED_ABI__)
#if XCHAL_NUM_AREGS > 16 #if XCHAL_NUM_AREGS > 16
__asm__ __volatile__ ( __asm__ __volatile__ (
" call8 1f\n" " call8 1f\n"
...@@ -96,6 +97,7 @@ static inline void spill_registers(void) ...@@ -96,6 +97,7 @@ static inline void spill_registers(void)
" mov a12, a12\n" " mov a12, a12\n"
: : : "memory"); : : : "memory");
#endif #endif
#endif
} }
struct debug_table { struct debug_table {
......
...@@ -969,6 +969,7 @@ ENDPROC(unrecoverable_exception) ...@@ -969,6 +969,7 @@ ENDPROC(unrecoverable_exception)
__XTENSA_HANDLER __XTENSA_HANDLER
.literal_position .literal_position
#ifdef SUPPORT_WINDOWED
/* /*
* Fast-handler for alloca exceptions * Fast-handler for alloca exceptions
* *
...@@ -1032,6 +1033,7 @@ ENTRY(fast_alloca) ...@@ -1032,6 +1033,7 @@ ENTRY(fast_alloca)
8: j _WindowUnderflow8 8: j _WindowUnderflow8
4: j _WindowUnderflow4 4: j _WindowUnderflow4
ENDPROC(fast_alloca) ENDPROC(fast_alloca)
#endif
#ifdef CONFIG_USER_ABI_CALL0_PROBE #ifdef CONFIG_USER_ABI_CALL0_PROBE
/* /*
...@@ -1228,7 +1230,8 @@ ENDPROC(fast_syscall_xtensa) ...@@ -1228,7 +1230,8 @@ ENDPROC(fast_syscall_xtensa)
* Note: We assume the stack pointer is EXC_TABLE_KSTK in the fixup handler. * Note: We assume the stack pointer is EXC_TABLE_KSTK in the fixup handler.
*/ */
#ifdef CONFIG_FAST_SYSCALL_SPILL_REGISTERS #if defined(CONFIG_FAST_SYSCALL_SPILL_REGISTERS) && \
defined(USER_SUPPORT_WINDOWED)
ENTRY(fast_syscall_spill_registers) ENTRY(fast_syscall_spill_registers)
......
...@@ -349,8 +349,10 @@ void __init setup_arch(char **cmdline_p) ...@@ -349,8 +349,10 @@ void __init setup_arch(char **cmdline_p)
#endif #endif
#ifdef CONFIG_VECTORS_ADDR #ifdef CONFIG_VECTORS_ADDR
#ifdef SUPPORT_WINDOWED
mem_reserve(__pa(&_WindowVectors_text_start), mem_reserve(__pa(&_WindowVectors_text_start),
__pa(&_WindowVectors_text_end)); __pa(&_WindowVectors_text_end));
#endif
mem_reserve(__pa(&_DebugInterruptVector_text_start), mem_reserve(__pa(&_DebugInterruptVector_text_start),
__pa(&_DebugInterruptVector_text_end)); __pa(&_DebugInterruptVector_text_end));
......
...@@ -45,12 +45,13 @@ struct rt_sigframe ...@@ -45,12 +45,13 @@ struct rt_sigframe
unsigned int window[4]; unsigned int window[4];
}; };
/* #if defined(USER_SUPPORT_WINDOWED)
/*
* Flush register windows stored in pt_regs to stack. * Flush register windows stored in pt_regs to stack.
* Returns 1 for errors. * Returns 1 for errors.
*/ */
int static int
flush_window_regs_user(struct pt_regs *regs) flush_window_regs_user(struct pt_regs *regs)
{ {
const unsigned long ws = regs->windowstart; const unsigned long ws = regs->windowstart;
...@@ -121,6 +122,13 @@ flush_window_regs_user(struct pt_regs *regs) ...@@ -121,6 +122,13 @@ flush_window_regs_user(struct pt_regs *regs)
errout: errout:
return err; return err;
} }
#else
static int
flush_window_regs_user(struct pt_regs *regs)
{
return 0;
}
#endif
/* /*
* Note: We don't copy double exception 'regs', we have to finish double exc. * Note: We don't copy double exception 'regs', we have to finish double exc.
......
...@@ -97,7 +97,9 @@ static dispatch_init_table_t __initdata dispatch_init_table[] = { ...@@ -97,7 +97,9 @@ static dispatch_init_table_t __initdata dispatch_init_table[] = {
/* EXCCAUSE_INSTRUCTION_FETCH unhandled */ /* EXCCAUSE_INSTRUCTION_FETCH unhandled */
/* EXCCAUSE_LOAD_STORE_ERROR unhandled*/ /* EXCCAUSE_LOAD_STORE_ERROR unhandled*/
{ EXCCAUSE_LEVEL1_INTERRUPT, 0, do_interrupt }, { EXCCAUSE_LEVEL1_INTERRUPT, 0, do_interrupt },
#ifdef SUPPORT_WINDOWED
{ EXCCAUSE_ALLOCA, USER|KRNL, fast_alloca }, { EXCCAUSE_ALLOCA, USER|KRNL, fast_alloca },
#endif
/* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */ /* EXCCAUSE_INTEGER_DIVIDE_BY_ZERO unhandled */
/* EXCCAUSE_PRIVILEGED unhandled */ /* EXCCAUSE_PRIVILEGED unhandled */
#if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION
......
...@@ -226,6 +226,7 @@ ENTRY(_DoubleExceptionVector) ...@@ -226,6 +226,7 @@ ENTRY(_DoubleExceptionVector)
xsr a0, depc # get DEPC, save a0 xsr a0, depc # get DEPC, save a0
#ifdef SUPPORT_WINDOWED
movi a2, WINDOW_VECTORS_VADDR movi a2, WINDOW_VECTORS_VADDR
_bltu a0, a2, .Lfixup _bltu a0, a2, .Lfixup
addi a2, a2, WINDOW_VECTORS_SIZE addi a2, a2, WINDOW_VECTORS_SIZE
...@@ -275,6 +276,10 @@ _DoubleExceptionVector_WindowUnderflow: ...@@ -275,6 +276,10 @@ _DoubleExceptionVector_WindowUnderflow:
l32i a0, a0, EXC_TABLE_FAST_USER l32i a0, a0, EXC_TABLE_FAST_USER
jx a0 jx a0
#else
j .Lfixup
#endif
/* /*
* We only allow the ITLB miss exception if we are in kernel space. * We only allow the ITLB miss exception if we are in kernel space.
* All other exceptions are unexpected and thus unrecoverable! * All other exceptions are unexpected and thus unrecoverable!
...@@ -343,6 +348,7 @@ _DoubleExceptionVector_WindowUnderflow: ...@@ -343,6 +348,7 @@ _DoubleExceptionVector_WindowUnderflow:
l32i a0, a0, EXC_TABLE_FAST_USER l32i a0, a0, EXC_TABLE_FAST_USER
jx a0 jx a0
#ifdef SUPPORT_WINDOWED
/* /*
* Restart window OVERFLOW exception. * Restart window OVERFLOW exception.
* Currently: * Currently:
...@@ -475,9 +481,12 @@ _DoubleExceptionVector_handle_exception: ...@@ -475,9 +481,12 @@ _DoubleExceptionVector_handle_exception:
rsr a0, depc rsr a0, depc
rotw -3 rotw -3
j 1b j 1b
#endif
ENDPROC(_DoubleExceptionVector) ENDPROC(_DoubleExceptionVector)
#ifdef SUPPORT_WINDOWED
/* /*
* Fixup handler for TLB miss in double exception handler for window owerflow. * Fixup handler for TLB miss in double exception handler for window owerflow.
* We get here with windowbase set to the window that was being spilled and * We get here with windowbase set to the window that was being spilled and
...@@ -590,6 +599,8 @@ ENTRY(window_overflow_restore_a0_fixup) ...@@ -590,6 +599,8 @@ ENTRY(window_overflow_restore_a0_fixup)
ENDPROC(window_overflow_restore_a0_fixup) ENDPROC(window_overflow_restore_a0_fixup)
#endif
/* /*
* Debug interrupt vector * Debug interrupt vector
* *
...@@ -687,6 +698,8 @@ _SimulateUserKernelVectorException: ...@@ -687,6 +698,8 @@ _SimulateUserKernelVectorException:
.section .WindowVectors.text, "ax" .section .WindowVectors.text, "ax"
#ifdef SUPPORT_WINDOWED
/* 4-Register Window Overflow Vector (Handler) */ /* 4-Register Window Overflow Vector (Handler) */
ENTRY_ALIGN64(_WindowOverflow4) ENTRY_ALIGN64(_WindowOverflow4)
...@@ -787,4 +800,6 @@ ENTRY_ALIGN64(_WindowUnderflow12) ...@@ -787,4 +800,6 @@ ENTRY_ALIGN64(_WindowUnderflow12)
ENDPROC(_WindowUnderflow12) ENDPROC(_WindowUnderflow12)
#endif
.text .text
...@@ -94,7 +94,9 @@ SECTIONS ...@@ -94,7 +94,9 @@ SECTIONS
. = ALIGN(PAGE_SIZE); . = ALIGN(PAGE_SIZE);
_vecbase = .; _vecbase = .;
#ifdef SUPPORT_WINDOWED
SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR) SECTION_VECTOR2 (.WindowVectors.text, WINDOW_VECTORS_VADDR)
#endif
#if XCHAL_EXCM_LEVEL >= 2 #if XCHAL_EXCM_LEVEL >= 2
SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR) SECTION_VECTOR2 (.Level2InterruptVector.text, INTLEVEL2_VECTOR_VADDR)
#endif #endif
...@@ -166,8 +168,10 @@ SECTIONS ...@@ -166,8 +168,10 @@ SECTIONS
__boot_reloc_table_start = ABSOLUTE(.); __boot_reloc_table_start = ABSOLUTE(.);
#if !MERGED_VECTORS #if !MERGED_VECTORS
#ifdef SUPPORT_WINDOWED
RELOCATE_ENTRY(_WindowVectors_text, RELOCATE_ENTRY(_WindowVectors_text,
.WindowVectors.text); .WindowVectors.text);
#endif
#if XCHAL_EXCM_LEVEL >= 2 #if XCHAL_EXCM_LEVEL >= 2
RELOCATE_ENTRY(_Level2InterruptVector_text, RELOCATE_ENTRY(_Level2InterruptVector_text,
.Level2InterruptVector.text); .Level2InterruptVector.text);
...@@ -229,14 +233,18 @@ SECTIONS ...@@ -229,14 +233,18 @@ SECTIONS
#if !MERGED_VECTORS #if !MERGED_VECTORS
/* The vectors are relocated to the real position at startup time */ /* The vectors are relocated to the real position at startup time */
#ifdef SUPPORT_WINDOWED
SECTION_VECTOR4 (_WindowVectors_text, SECTION_VECTOR4 (_WindowVectors_text,
.WindowVectors.text, .WindowVectors.text,
WINDOW_VECTORS_VADDR, WINDOW_VECTORS_VADDR,
.dummy) LAST)
#undef LAST
#define LAST .WindowVectors.text
#endif
SECTION_VECTOR4 (_DebugInterruptVector_text, SECTION_VECTOR4 (_DebugInterruptVector_text,
.DebugInterruptVector.text, .DebugInterruptVector.text,
DEBUG_VECTOR_VADDR, DEBUG_VECTOR_VADDR,
.WindowVectors.text) LAST)
#undef LAST #undef LAST
#define LAST .DebugInterruptVector.text #define LAST .DebugInterruptVector.text
#if XCHAL_EXCM_LEVEL >= 2 #if XCHAL_EXCM_LEVEL >= 2
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment