linux_dsm_epyc7002/arch/arc/kernel
Vineet Gupta 6914e1e3f6 ARC: SA_SIGINFO ucontext regs off-by-one
The regfile provided to SA_SIGINFO signal handler as ucontext was off by
one due to pt_regs gutter cleanups in 2013.

Before handling signal, user pt_regs are copied onto user_regs_struct and copied
back later. Both structs are binary compatible. This was all fine until
commit 2fa919045b (ARC: pt_regs update #2) which removed the empty stack slot
at top of pt_regs (corresponding to first pad) and made the corresponding
fixup in struct user_regs_struct (the pad in there was moved out of
@scratch - not removed altogether as it is part of ptrace ABI)

 struct user_regs_struct {
+       long pad;
        struct {
-               long pad;
                long bta, lp_start, lp_end,....
        } scratch;
 ...
 }

This meant that now user_regs_struct was off by 1 reg w.r.t pt_regs and
signal code needs to user_regs_struct.scratch to reflect it as pt_regs,
which is what this commit does.

This problem was hidden for 2 years, because both save/restore, despite
using wrong location, were using the same location. Only an interim
inspection (reproducer below) exposed the issue.

     void handle_segv(int signo, siginfo_t *info, void *context)
     {
 	ucontext_t *uc = context;
	struct user_regs_struct *regs = &(uc->uc_mcontext.regs);

	printf("regs %x %x\n",               <=== prints 7 8 (vs. 8 9)
               regs->scratch.r8, regs->scratch.r9);
     }

     int main()
     {
	struct sigaction sa;

	sa.sa_sigaction = handle_segv;
	sa.sa_flags = SA_SIGINFO;
	sigemptyset(&sa.sa_mask);
	sigaction(SIGSEGV, &sa, NULL);

	asm volatile(
	"mov	r7, 7	\n"
	"mov	r8, 8	\n"
	"mov	r9, 9	\n"
	"mov	r10, 10	\n"
	:::"r7","r8","r9","r10");

	*((unsigned int*)0x10) = 0;
     }

Fixes: 2fa919045b "ARC: pt_regs update #2: Remove unused gutter at start of pt_regs"
CC: <stable@vger.kernel.org>
Signed-off-by: Vineet Gupta <vgupta@synopsys.com>
2015-03-26 09:38:00 +05:30
..
.gitignore ARC: Add some .gitignore entries 2013-08-26 09:40:24 +05:30
arc_hostlink.c ARC: Hostlink Pseudo-Driver for Metaware Debugger 2013-02-15 23:16:10 +05:30
arcksyms.c ARC: Build system: Makefiles, Kconfig, Linker script 2013-02-11 20:00:25 +05:30
asm-offsets.c ARC: pt_regs update #5: Use real ECR for pt_regs->event vs. synth values 2013-06-26 14:04:48 +05:30
clk.c ARC: fix typo with clock speed 2013-05-07 13:43:54 +05:30
ctx_sw_asm.S ARC: Fix build breakage for !CONFIG_ARC_DW2_UNWIND 2014-06-26 10:14:02 +05:30
ctx_sw.c ARC: [SMP] Fix build failures for large NR_CPUS 2013-11-06 10:41:46 +05:30
devtree.c ARC: Fix earlycon build breakage 2015-02-04 10:38:15 +05:30
disasm.c ARC: rename kconfig option for unaligned emulation 2014-10-13 14:46:15 +05:30
entry.S ARC: add some more comments to ret_from_fork 2015-02-02 17:08:37 +05:30
fpu.c ARC: Process-creation/scheduling/idle-loop 2013-02-11 20:00:38 +05:30
head.S ARC: RIP @running_on_hw 2014-10-13 14:46:17 +05:30
irq.c ARC: [intc] mask/unmask can be hidden again 2014-07-23 11:22:02 +05:30
kgdb.c ARC: kgdb: generic kgdb_arch_pc() suffices 2014-10-22 16:14:04 -06:00
kprobes.c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/jikos/trivial 2013-11-15 16:47:22 -08:00
Makefile ARC: rename kconfig option for unaligned emulation 2014-10-13 14:46:15 +05:30
module.c ARC: Fix coding style issues 2013-04-09 12:21:14 +05:30
perf_event.c ARC: boot: cpu feature print enhancements 2014-10-13 14:46:22 +05:30
process.c ARC: Fix thread_saved_pc() 2015-02-27 10:59:34 +05:30
ptrace.c ARC: Implement ptrace(PTRACE_GET_THREAD_AREA) 2014-06-26 10:14:08 +05:30
reset.c arc: export symbol for pm_power_off in reset.c 2013-11-06 10:41:44 +05:30
setup.c ARC: fix /proc/cpuinfo for offline cpus 2015-02-02 17:08:37 +05:30
signal.c ARC: SA_SIGINFO ucontext regs off-by-one 2015-03-26 09:38:00 +05:30
smp.c ARC: use ACCESS_ONCE in cmpxchg loop 2015-02-02 17:08:37 +05:30
stacktrace.c ARC: Fix KSTK_ESP() 2015-02-27 10:48:23 +05:30
sys.c ARC: ABIv3: fork/vfork wrappers not needed in "no-legacy-syscall" ABI 2013-03-11 19:01:10 +05:30
time.c ARC: update some comments 2014-07-23 11:17:12 +05:30
traps.c ARC: Reduce #ifdef'ery for unaligned access emulation 2013-11-06 10:41:39 +05:30
troubleshoot.c arc: call find_vma with the mmap_sem held 2014-06-04 16:54:00 -07:00
unaligned.c ARC: perf: Enable generic software events 2015-02-27 10:15:01 +05:30
unwind.c ARC: warn on improper stack unwind FDE entries 2013-06-27 14:37:59 +05:30
vmlinux.lds.S ARC: optimize kernel bss clearing in early boot code 2014-06-26 10:14:05 +05:30