Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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>

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