xtensa: introduce spill_registers_kernel macro

Most in-kernel users want registers spilled on the kernel stack and
don't require PS.EXCM to be set. That means that they don't need fixup
routine and could reuse regular window overflow mechanism for that,
which makes spill routine very simple.

Cc: stable@vger.kernel.org
Suggested-by: Chris Zankel <chris@zankel.net>
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: save a4 in spill_registers

Without this fix the value of a0 spilled from the oldest live window is
wrong if the newest window has only 4 live registers, because a4 in the
newest window overlaps a0 in the oldest one.

This may be reproduced by invoking spill syscall after the following
sequence of calls: 4 -> 12 -> 12 -> 4 on configuration with 32 physical
registers.

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: put stack pointer into a1 for call12 spill case

call12 spill procedure starts with the following code:

	s32e    a4, a1, -16     # a1 is valid with an empty spill area
	l32e    a4, a5, -12
	s32e    a8, a4, -48
	mov     a8, a4
	l32e    a4, a1, -16
	j       .Lc12c

a1 is expected to point to the topmost stack frame, but this is almost
never the case after the initial register window rotation. The result is
either stack corruption or infinite attempt to call fixup routine after the
first s32e.

This may be reproduced by invoking spill syscall after the following
sequence of calls: 4 -> 12 -> 12 -> 8 on configuration with 32 physical
registers.

The rest of the patch fixes the caller of _spill_registers, saving/restoring
additional registers across the call.

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: save current register frame in fast_syscall_spill_registers_fixup

We need it saved because it contains a3 where we track which register
windows we still need to spill, and fixup handler may call C exception
handlers. Also fix comments.

Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
xtensa: add register spill code debugging

Introduce new CONFIG_DEBUG_SPILL symbol. When enabled _spill_registers
will always clobber registers it potentially may clobber, making the
kernel more likely crash if not all relevant registers are saved across
the call to _spill_registers.

Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>