linux/arch/sh
Carl Shaw 2fc742f8d6 sh: Improve unwind info for signals
GCC does not issue unwind information for function epilogues.
Unfortunately we can catch a signal during an epilogue.  The signal
handler writes the current context and signal return code onto the stack
overwriting previous contents.  During unwinding, libgcc can try to
restore registers from the stack and restores corrupted ones. This can
lead to segmentation, misaligned access and sigbus faults.

For example, consider the following code:

    mov.l   r12,@-r15
    mov.l   r14,@-r15
    sts.l   pr,@-r15
    mov     r15,r14

    <do stuff>

    mov r14, r15
    lds.l @r15+, pr
	<<< SIGNAL HERE
    mov.l @r15+, r14
    mov.l @r15+, r12
    rts

Unwind is aware that pr was pushed to stack in prolog, so tries to
restore it.  Unfortunately it restores the last word of the signal
handler code placed on the stack by the kernel.

This patch tries to avoid the problem by adding a guard region on the
stack between where the function pushes data and where the signal handler
pushes its return code.  We probably don't see this problem often because
exception handling unwinding in an epilogue only occurs due to a pthread
cancel signal.  Also the kernel signal stack handler alignment of 8 bytes
could hide the occurance of this problem sometimes as the stack may not
be trampled at a particular required word.

This is not guaranteed to always work.  It relies on a frame pointer
existing for the function (so it can get the correct sp value) which is
not always the case for the SH4.

Modifications will also be made to libgcc for the case where there is no
fp.

Signed-off-by: Carl Shaw <carl.shaw@st.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
2009-08-24 15:07:08 +09:00
..
boards Merge branches 'sh/hwblk' and 'sh/pm-runtime' 2009-08-23 18:04:07 +09:00
boot sh: fix romImage mach dir usage 2009-08-07 03:58:38 +09:00
cchips
configs sh: update kfr2r09 defconfig 2009-08-21 08:32:16 +09:00
drivers sh: Add SH7724 support to NR_ONCHIP_DMA_CHANNELS 2009-08-19 19:28:40 +09:00
include Merge branches 'sh/hwblk' and 'sh/pm-runtime' 2009-08-23 18:04:07 +09:00
kernel sh: Improve unwind info for signals 2009-08-24 15:07:08 +09:00
lib sh: Fix up stack overflow check with ftrace disabled. 2009-07-11 21:06:53 +09:00
lib64 sh: Convert sh64 to use the generic checksum code. 2009-06-15 00:00:42 +09:00
math-emu
mm sh: Add initial support for SH7757 CPU subtype 2009-08-21 17:25:47 +09:00
oprofile sh: oprofile: Kill off dead valid_kernel_stack(). 2009-08-14 04:59:50 +09:00
tools sh: Add mach-types entry for EcoVec board. 2009-08-20 10:14:29 +09:00
Kconfig Merge branches 'sh/hwblk' and 'sh/pm-runtime' 2009-08-23 18:04:07 +09:00
Kconfig.cpu sh: Tidy up SH-4A boot_cpu_data.flags probing. 2009-06-01 19:50:08 +09:00
Kconfig.debug sh: Add initial support for SH7757 CPU subtype 2009-08-21 17:25:47 +09:00
Makefile sh: Add EcoVec (SH7724) board support 2009-08-20 10:13:16 +09:00