android_kernel_xiaomi_sdm845/arch/sh/kernel
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
..
cpu Merge branches 'sh/hwblk' and 'sh/pm-runtime' 2009-08-23 18:04:07 +09:00
vsyscall [S390] arch_setup_additional_pages arguments 2008-12-25 13:38:54 +01:00
.gitignore sh: Add an arch/sh/kernel/.gitignore 2008-07-29 08:29:32 +09:00
asm-offsets.c sh: Provide diagnostic kernel stack checks 2009-07-11 10:07:58 +09:00
cpufreq.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2007-10-13 09:49:04 -07:00
crash_dump.c kdump: make elfcorehdr_addr independent of CONFIG_PROC_VMCORE 2008-10-20 08:52:39 -07:00
debugtraps.S sh: unwinder: Use a special bug flag for unwinder traps. 2009-08-22 05:28:25 +09:00
disassemble.c sh: Add a simple code dumper for SUPERH32 show_regs(). 2008-12-22 18:43:49 +09:00
dumpstack.c sh: flag the default unwinder as reliable. 2009-08-15 01:09:03 +09:00
dwarf.c sh: unwinder: cacheline align slab cache objects. 2009-08-22 19:03:25 +09:00
early_printk.c sh: Fix up early printk build error. 2009-08-04 15:54:33 +09:00
entry-common.S sh: Add a few missing irqflags tracing markers. 2009-08-18 11:35:09 +09:00
ftrace.c sh: Function graph tracer support 2009-07-11 10:08:01 +09:00
gpio.c sh: use gpiolib 2009-01-27 14:49:10 +09:00
head_32.S sh: convert to use __HEAD and HEAD_TEXT macros. 2009-04-26 09:20:39 -07:00
head_64.S sh: convert to use __HEAD and HEAD_TEXT macros. 2009-04-26 09:20:39 -07:00
idle.c sh: Provide cpu_idle_wait() to fix up cpuidle/SMP build. 2009-06-23 17:30:17 +09:00
init_task.c mm: consolidate init_mm definition 2009-06-16 19:47:28 -07:00
io_generic.c sh: More I/O routine overhauling. 2008-10-04 05:25:52 +09:00
io_trapped.c sh: Rework irqflags tracing to fix up CONFIG_PROVE_LOCKING. 2009-07-29 23:01:24 +09:00
io.c sh: pci: Consolidate pci_iomap() and use the generic I/O base. 2009-04-20 16:38:00 +09:00
irq.c sh: unwinder: Move initialization to early_initcall() and tidy up locking. 2009-08-17 05:07:38 +09:00
kgdb.c sh: Rename opcode_t to insn_size_t. 2009-05-09 16:02:08 +09:00
kprobes.c sh: kprobes: kretprobe_trampoline needs to be global. 2008-09-09 08:13:28 +09:00
localtimer.c sh: Move dummy clockevents broadcast timer to its new home. 2009-05-03 18:29:27 +09:00
machine_kexec.c sh: disallow kexec virtual entry 2009-03-20 18:56:04 +09:00
machvec.c sh: boot word / mode pin support V2 2009-06-01 15:44:49 +09:00
Makefile sh: Merge the _32/_64 variants of arch/sh/kernel/Makefile. 2009-08-16 03:35:26 +09:00
module.c module: cleanup FIXME comments about trimming exception table entries. 2009-06-12 21:47:05 +09:30
process_32.c sh: Mark __switch_to() as __notrace_funcgraph 2009-07-11 10:08:06 +09:00
process_64.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/lethal/sh-2.6 2009-06-18 14:07:35 -07:00
ptrace_32.c sh: Fix up the CONFIG_FTRACE_SYSCALLS=n build. 2009-08-20 12:07:46 +09:00
ptrace_64.c sh: Provide linux/regset.h interface for SH-5. 2008-12-22 18:44:04 +09:00
relocate_kernel.S sh: add kexec jump support 2009-03-18 18:57:43 +09:00
setup.c sh: Add initial support for SH7757 CPU subtype 2009-08-21 17:25:47 +09:00
sh_bios.c sh: Kill off sh_bios_in_gdb_mode(). 2008-12-22 18:44:44 +09:00
sh_ksyms_32.c sh: Use DECLARE_EXPORT() for mcount symbol export. 2009-07-11 20:32:14 +09:00
sh_ksyms_64.c sh: Convert sh64 to use the generic checksum code. 2009-06-15 00:00:42 +09:00
signal_32.c sh: Improve unwind info for signals 2009-08-24 15:07:08 +09:00
signal_64.c sh: Fix up spurious syscall restarting. 2009-01-29 11:56:03 +09:00
smp.c cpumask: Use accessors for cpu_*_mask: sh 2009-06-14 18:24:16 +09:00
stacktrace.c sh: stacktrace: Properly terminate the trace entry buffer. 2009-08-15 01:11:37 +09:00
swsusp.c sh: hibernation support 2009-03-10 12:55:40 +09:00
sys_sh32.c [CVE-2009-0029] Remove __attribute__((weak)) from sys_pipe/sys_pipe2 2009-01-14 14:15:15 +01:00
sys_sh64.c unified (weak) sys_pipe implementation 2008-05-03 13:50:33 -07:00
sys_sh.c sh: remove stray markers. 2009-06-18 13:38:26 +09:00
syscalls_32.S sh: Wire up sys_perf_counter_open. 2009-06-12 01:33:22 +03:00
syscalls_64.S sh: Wire up sys_perf_counter_open. 2009-06-12 01:33:22 +03:00
time.c Revert "sh: Bump the earlytimer bits back to time_init()." 2009-07-29 22:43:58 +09:00
topology.c sh: replace remaining __FUNCTION__ occurrences 2008-03-06 11:18:22 +09:00
traps_32.c sh: cleanup of do_address_error() 2009-08-24 15:01:10 +09:00
traps_64.c sh: Always fixup unaligned userspace accesses on sh64. 2009-05-08 20:32:56 +09:00
traps.c sh: unwinder: Use a special bug flag for unwinder traps. 2009-08-22 05:28:25 +09:00
unwinder.c sh: unwinder: Use a special bug flag for unwinder traps. 2009-08-22 05:28:25 +09:00
vmlinux.lds.S sh: dwarf unwinder support. 2009-08-14 01:58:43 +09:00