linux-stable/arch/m68k
Al Viro 0d20abde98 m68k: Leave stack mangling to asm wrapper of sigreturn()
sigreturn has to deal with an unpleasant problem - exception stack frames
have different sizes, depending upon the exception (and processor model, as
well) and variable-sized part of exception frame may contain information
needed for instruction restart.  So when signal handler terminates and calls
sigreturn to resume the execution at the place where we'd been when we caught
the signal, it has to rearrange the frame at the bottom of kernel stack.
Worse, it might need to open a gap in the kernel stack, shifting pt_regs
towards lower addresses.

Doing that from C is insane - we'd need to shift stack frames (return addresses,
local variables, etc.) of C call chain, right under the nose of compiler and
hope it won't fall apart horribly.  What had been actually done is only slightly
less insane - an inline asm in mangle_kernel_stack() moved the stuff around,
then reset stack pointer and jumped to label in asm glue.

However, we can avoid all that mess if the asm wrapper we have to use anyway
would reserve some space on the stack between switch_stack and the C stack
frame of do_{rt_,}sigreturn().   Then C part can simply memmove() pt_regs +
switch_stack, memcpy() the variable part of exception frame into the opened
gap - all of that without inline asm, buggering C call chain, magical jumps
to asm labels, etc.

Asm wrapper would need to know where the moved switch_stack has ended up -
it might have been shifted into the gap we'd reserved before do_rt_sigreturn()
call.  That's where it needs to set the stack pointer to.  So let the C part
return just that and be done with that.

While we are at it, the call of berr_040cleanup() we need to do when
returning via 68040 bus error exception frame can be moved into C part
as well.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Tested-by: Michael Schmitz <schmitzmic@gmail.com>
Reviewed-by: Michael Schmitz <schmitzmic@gmail.com>
Tested-by: Finn Thain <fthain@linux-m68k.org>
Link: https://lore.kernel.org/r/YP2dTQPm1wGPWFgD@zeniv-ca.linux.org.uk
Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
2021-09-24 13:35:03 +02:00
..
68000 m68k: Leave stack mangling to asm wrapper of sigreturn() 2021-09-24 13:35:03 +02:00
amiga asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
apollo asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
atari m68k/q40: Replace q40ide driver with pata_falcon and falconide 2021-06-10 16:30:12 -06:00
bvme6000 asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
coldfire m68k: Leave stack mangling to asm wrapper of sigreturn() 2021-09-24 13:35:03 +02:00
configs for-5.15/block-2021-08-30 2021-08-30 18:52:11 -07:00
emu TTY / Serial patches for 5.15-rc1 2021-09-01 09:51:16 -07:00
fpsp040 signal/m68k: Use force_sigsegv(SIGSEGV) in fpsp040_die 2021-08-26 09:59:15 -05:00
hp300 asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
ifpsp060 m68k: fpsp040,ifpsp060: Remove meaningless EXTRA_LDFLAGS 2021-04-06 09:33:20 +02:00
include m68k: Leave stack mangling to asm wrapper of sigreturn() 2021-09-24 13:35:03 +02:00
kernel m68k: Leave stack mangling to asm wrapper of sigreturn() 2021-09-24 13:35:03 +02:00
lib
mac m68k/mac: Replace macide driver with generic platform drivers 2021-06-10 16:30:11 -06:00
math-emu
mm m68k: remove support for DISCONTIGMEM 2021-06-29 10:53:55 -07:00
mvme16x m68k: mvme: Remove overdue #warnings in RTC handling 2021-09-13 11:19:05 +02:00
mvme147 m68k: mvme: Remove overdue #warnings in RTC handling 2021-09-13 11:19:05 +02:00
q40 m68k/q40: Replace q40ide driver with pata_falcon and falconide 2021-06-10 16:30:12 -06:00
sun3 m68k: remove timer_interrupt() function 2020-10-30 21:57:06 +01:00
sun3x asm-generic: cross-architecture timer cleanup 2020-12-16 00:07:17 -08:00
tools/amiga
install.sh
Kbuild
Kconfig asm-generic changes for 5.15 2021-09-01 15:13:02 -07:00
Kconfig.bus m68knommu: only set CONFIG_ISA_DMA_API for ColdFire sub-arch 2021-08-23 08:40:05 +10:00
Kconfig.cpu m68k: Fix invalid RMW_INSNS on CPUs that lack CAS 2021-08-09 13:23:50 +02:00
Kconfig.debug
Kconfig.devices
Kconfig.machine m68k/nommu: prevent setting ROMKERNEL when ROM is not set 2021-08-23 08:40:04 +10:00
Makefile Kbuild updates for v5.14 2021-07-10 11:01:38 -07:00