OpenCloudOS-Kernel/arch/sparc64/kernel
David S. Miller 28e6103665 sparc: Fix debugger syscall restart interactions.
So, forever, we've had this ptrace_signal_deliver implementation
which tries to handle all of the nasties that can occur when the
debugger looks at a process about to take a signal.  It's meant
to address all of these issues inside of the kernel so that the
debugger need not be mindful of such things.

Problem is, this doesn't work.

The idea was that we should do the syscall restart business first, so
that the debugger captures that state.  Otherwise, if the debugger for
example saves the child's state, makes the child execute something
else, then restores the saved state, we won't handle the syscall
restart properly because we lose the "we're in a syscall" state.

The code here worked for most cases, but if the debugger actually
passes the signal through to the child unaltered, it's possible that
we would do a syscall restart when we shouldn't have.

In particular this breaks the case of debugging a process under a gdb
which is being debugged by yet another gdb.  gdb uses sigsuspend
to wait for SIGCHLD of the inferior, but if gdb itself is being
debugged by a top-level gdb we get a ptrace_stop().  The top-level gdb
does a PTRACE_CONT with SIGCHLD to let the inferior gdb see the
signal.  But ptrace_signal_deliver() assumed the debugger would cancel
out the signal and therefore did a syscall restart, because the return
error was ERESTARTNOHAND.

Fix this by simply making ptrace_signal_deliver() a nop, and providing
a way for the debugger to control system call restarting properly:

1) Report a "in syscall" software bit in regs->{tstate,psr}.
   It is set early on in trap entry to a system call and is fully
   visible to the debugger via ptrace() and regsets.

2) Test this bit right before doing a syscall restart.  We have
   to do a final recheck right after get_signal_to_deliver() in
   case the debugger cleared the bit during ptrace_stop().

3) Clear the bit in trap return so we don't accidently try to set
   that bit in the real register.

As a result we also get a ptrace_{is,clear}_syscall() for sparc32 just
like sparc64 has.

M68K has this same exact bug, and is now the only other user of the
ptrace_signal_deliver hook.  It needs to be fixed in the same exact
way as sparc.

Signed-off-by: David S. Miller <davem@davemloft.net>
2008-05-11 02:07:19 -07:00
..
Makefile sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
asm-offsets.c kbuild: frv,m32r,sparc64 introduce fake asm-offsets.h file 2005-09-09 22:47:53 +02:00
audit.c sparc64: Kill CONFIG_SPARC32_COMPAT 2008-04-26 21:41:19 -07:00
auxio.c [SPARC/64]: Move of_platform_driver initialisations: arch/sparc{,64}. 2007-10-13 21:53:12 -07:00
central.c [SPARC64]: __inline__ --> inline 2007-10-27 00:13:04 -07:00
cherrs.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
chmc.c [SPARC64]: Fix memory controller register access when non-SMP. 2007-12-07 01:10:14 -08:00
compat_audit.c [PATCH] add SIGNAL syscall class (v3) 2007-05-11 05:38:25 -04:00
cpu.c [SPARC64]: Fix sparse warnings in arch/sparc64/kernel/{cpu,setup}.c 2008-03-25 21:51:40 -07:00
ds.c [SPARC64]: Use shorter list_splice_init() for brevity. 2008-03-23 22:48:29 -07:00
dtlb_miss.S [SPARC64]: More TLB/TSB handling fixes. 2006-03-20 01:13:34 -08:00
dtlb_prot.S [SPARC64]: Fix boot failures on SunBlade-150 2005-10-12 12:22:46 -07:00
ebus.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
entry.h [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
etrap.S sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
fpu_traps.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
getsetcc.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
head.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
helpers.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
hvapi.c [SPARC64]: Report proper system soft state to the hypervisor. 2007-05-29 02:49:29 -07:00
hvcalls.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
hvtramp.S [SPARC64]: Fix cpu trampoline et al. mismatch warnings. 2008-02-20 22:22:16 -08:00
idprom.c Linux-2.6.12-rc2 2005-04-16 15:20:36 -07:00
init_task.c Remove fs.h from mm.h 2007-07-29 17:09:29 -07:00
iommu.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
iommu_common.h sparc64: remove unused calc_npages() in iommu_common.h 2008-03-28 15:56:01 -07:00
irq.c sparc64: Fix wedged irq regression. 2008-04-26 21:41:15 -07:00
itlb_miss.S [SPARC64]: Fix _PAGE_EXEC_4U check in sun4u I-TLB miss handler. 2007-05-29 02:50:15 -07:00
ivec.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
kgdb.c sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
kprobes.c [SPARC64]: Fix sparse warnings wrt. __show_regs(). 2008-02-19 20:48:58 -08:00
ktlb.S [SPARC64]: Fix build with SPARSEMEM_VMEMMAP disabled. 2008-01-12 21:52:16 -08:00
ldc.c [SPARC64]: Missing mdesc_release() in ldc_init(). 2007-12-05 05:37:55 -08:00
mdesc.c [SPARC64]: Initialize MDESC earlier and use lmb_alloc() 2008-04-23 23:32:12 -07:00
misctrap.S sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
module.c [SPARC]: Remove duplicate includes. 2007-11-06 21:23:11 -08:00
of_device.c sparc64: Do not ignore 'pmu' device ranges. 2008-04-26 21:41:20 -07:00
pci.c sparc64: Stop creating dummy root PCI host controller devices. 2008-05-02 05:22:50 -07:00
pci_common.c sparc64: Stop creating dummy root PCI host controller devices. 2008-05-02 05:22:50 -07:00
pci_fire.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_impl.h sparc64: Stop creating dummy root PCI host controller devices. 2008-05-02 05:22:50 -07:00
pci_msi.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_psycho.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_sabre.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_schizo.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_sun4v.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
pci_sun4v.h [SPARC64]: Add PCI MSI support on Niagara. 2007-02-10 23:50:37 -08:00
pci_sun4v_asm.S [SPARC64]: Add PCI MSI support on Niagara. 2007-02-10 23:50:37 -08:00
power.c [SPARC64]: Fix sparse warnings wrt. machine_alt_power_off(). 2008-02-19 20:39:18 -08:00
process.c sparc: Fix fork/clone/vfork system call restart. 2008-05-07 16:21:28 -07:00
prom.c [SPARC64]: Use lmb_alloc() for PROM device tree. 2008-04-23 23:32:11 -07:00
ptrace.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
rtrap.S sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
sbus.c [SPARC64]: NUMA device infrastructure. 2008-04-23 23:32:16 -07:00
setup.c [SPARC64]: PROM debug console can be CON_ANYTIME. 2008-04-23 23:32:20 -07:00
signal.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
signal32.c sparc: Fix debugger syscall restart interactions. 2008-05-11 02:07:19 -07:00
smp.c Revert "[SPARC64]: Wrap SMP IPIs with irq_enter()/irq_exit()." 2008-05-03 21:00:55 -07:00
sparc64_ksyms.c sparc64: Kill unused local ISA bus layer. 2008-04-26 21:41:23 -07:00
spiterrs.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
sstate.c [SPARC64]: Report proper system soft state to the hypervisor. 2007-05-29 02:49:29 -07:00
stacktrace.c [SPARC64]: Detect trap frames in stack backtraces. 2008-04-24 03:28:52 -07:00
starfire.c [SPARC64]: Kill starfire_cookie from SBUS/PCI. 2006-06-29 16:37:08 -07:00
sun4v_ivec.S [SPARC64]: Use sun4v VIRQ interfaces as intended. 2007-10-13 21:53:16 -07:00
sun4v_tlb_miss.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
sys32.S [SPARC64]: Fix arg passing to compat_sys_ipc(). 2007-04-13 13:27:08 -07:00
sys_sparc.c sparc: Fix mmap VA span checking. 2008-05-07 02:24:28 -07:00
sys_sparc32.c sparc64: use compat_sys_utimes instead of home-grown local copy. 2008-05-05 12:32:39 -07:00
syscalls.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
sysfs.c [SPARC64]: Add NUMA support. 2008-04-23 23:32:17 -07:00
systbls.S sparc64: use compat_sys_utimes instead of home-grown local copy. 2008-05-05 12:32:39 -07:00
systbls.h [SPARC]: Remove SunOS and Solaris binary support. 2008-04-21 15:10:15 -07:00
time.c [SPARC64]: Fix sparse warnings in arch/sparc64/kernel/time.c 2008-03-26 01:11:55 -07:00
trampoline.S [SPARC64]: Remove most limitations to kernel image size. 2008-03-21 17:01:38 -07:00
traps.c [SPARC64]: Detect trap frames in stack backtraces. 2008-04-24 03:28:52 -07:00
tsb.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00
ttable.S sparc: Add kgdb support. 2008-04-29 02:38:50 -07:00
una_asm.S [SPARC64]: Mark __ex_table section correctly. 2006-03-04 23:23:56 -08:00
unaligned.c [SPARC64] arch/sparc64/kernel/unaligned.c: Use time_* macros 2008-02-17 23:24:10 -08:00
us2e_cpufreq.c [CPUFREQ] move policy's governor initialisation out of low-level drivers into cpufreq core 2007-10-04 18:40:57 -04:00
us3_cpufreq.c [SPARC64]: kzalloc() conversion 2006-03-20 01:14:19 -08:00
utrap.S sparc64: Split entry.S up into seperate files. 2008-04-28 00:47:20 -07:00
vio.c [SPARC64]: Fix of section mismatch warnings. 2008-01-21 22:34:30 -08:00
viohs.c viohs: extern on function definition 2007-07-26 11:11:56 -07:00
visemul.c [SPARC64]: Call do_mathemu on illegal instruction traps too. 2006-12-10 02:39:32 -08:00
vmlinux.lds.S all archs: consolidate init and exit sections in vmlinux.lds.h 2008-01-28 23:21:17 +01:00
winfixup.S [SPARC64]: %l6 trap return handling no longer necessary. 2008-04-24 03:15:22 -07:00