xtensa: don't allow overflow/underflow on unaligned stack

Double exceptions that happen during register window overflow/underflow
are handled in the topmost stack frame, as if it was the only exception
that occured. However unaligned access exception handler is special
because it needs to analyze instruction that caused the exception, but
the userspace instruction that triggered window exception is completely
irrelevant. Unaligned data access is rather normal in the generic
userspace code, but stack pointer manipulation must always be done by
architecture-aware code and thus unaligned stack means a serious problem
anyway.
Use the default unaligned access handler that raises SIGBUS in case
of unaligned access in window overflow/underflow handler.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>

Changed files
+10 -7
arch
+1 -4
arch/xtensa/kernel/traps.c
··· 101 101 #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 102 102 #ifdef CONFIG_XTENSA_UNALIGNED_USER 103 103 { EXCCAUSE_UNALIGNED, USER, fast_unaligned }, 104 - #else 105 - { EXCCAUSE_UNALIGNED, 0, do_unaligned_user }, 106 104 #endif 105 + { EXCCAUSE_UNALIGNED, 0, do_unaligned_user }, 107 106 { EXCCAUSE_UNALIGNED, KRNL, fast_unaligned }, 108 107 #endif 109 108 #ifdef CONFIG_MMU ··· 263 264 */ 264 265 265 266 #if XCHAL_UNALIGNED_LOAD_EXCEPTION || XCHAL_UNALIGNED_STORE_EXCEPTION 266 - #ifndef CONFIG_XTENSA_UNALIGNED_USER 267 267 void 268 268 do_unaligned_user (struct pt_regs *regs) 269 269 { ··· 283 285 force_sig_info(SIGSEGV, &info, current); 284 286 285 287 } 286 - #endif 287 288 #endif 288 289 289 290 void
+7 -1
arch/xtensa/kernel/vectors.S
··· 454 454 s32i a0, a2, PT_DEPC 455 455 456 456 _DoubleExceptionVector_handle_exception: 457 + addi a0, a0, -EXCCAUSE_UNALIGNED 458 + beqz a0, 2f 457 459 addx4 a0, a0, a3 458 - l32i a0, a0, EXC_TABLE_FAST_USER 460 + l32i a0, a0, EXC_TABLE_FAST_USER + 4 * EXCCAUSE_UNALIGNED 461 + xsr a3, excsave1 462 + jx a0 463 + 2: 464 + movi a0, user_exception 459 465 xsr a3, excsave1 460 466 jx a0 461 467
+2 -2
arch/xtensa/kernel/vmlinux.lds.S
··· 269 269 .UserExceptionVector.literal) 270 270 SECTION_VECTOR (_DoubleExceptionVector_literal, 271 271 .DoubleExceptionVector.literal, 272 - DOUBLEEXC_VECTOR_VADDR - 40, 272 + DOUBLEEXC_VECTOR_VADDR - 48, 273 273 SIZEOF(.UserExceptionVector.text), 274 274 .UserExceptionVector.text) 275 275 SECTION_VECTOR (_DoubleExceptionVector_text, 276 276 .DoubleExceptionVector.text, 277 277 DOUBLEEXC_VECTOR_VADDR, 278 - 40, 278 + 48, 279 279 .DoubleExceptionVector.literal) 280 280 281 281 . = (LOADADDR( .DoubleExceptionVector.text ) + SIZEOF( .DoubleExceptionVector.text ) + 3) & ~ 3;