Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1187422
| From | Max Filippov <jcmvbkbc@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v2 10/13] xtensa: fix kernel register spilling |
| Date | 2015-07-18 10:40 +0200 |
| Message-ID | <pNvP4-7hz-21@gated-at.bofh.it> (permalink) |
| References | <pNvP3-7hz-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
call12 can't be safely used as the first call in the inline function,
because the compiler does not extend the stack frame of the bounding
function accordingly, which may result in corruption of local variables.
If a call needs to be done, do call8 first followed by call12.
For pure assembly code in _switch_to increase stack frame size of the
bounding function.
Cc: stable@vger.kernel.org
Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
---
arch/xtensa/include/asm/traps.h | 29 +++++++++++++++++++----------
arch/xtensa/kernel/entry.S | 4 ++--
2 files changed, 21 insertions(+), 12 deletions(-)
diff --git a/arch/xtensa/include/asm/traps.h b/arch/xtensa/include/asm/traps.h
index 677bfcf..28f33a8 100644
--- a/arch/xtensa/include/asm/traps.h
+++ b/arch/xtensa/include/asm/traps.h
@@ -25,30 +25,39 @@ static inline void spill_registers(void)
{
#if XCHAL_NUM_AREGS > 16
__asm__ __volatile__ (
- " call12 1f\n"
+ " call8 1f\n"
" _j 2f\n"
" retw\n"
" .align 4\n"
"1:\n"
+#if XCHAL_NUM_AREGS == 32
+ " _entry a1, 32\n"
+ " addi a8, a0, 3\n"
+ " _entry a1, 16\n"
+ " mov a12, a12\n"
+ " retw\n"
+#else
" _entry a1, 48\n"
- " addi a12, a0, 3\n"
-#if XCHAL_NUM_AREGS > 32
- " .rept (" __stringify(XCHAL_NUM_AREGS) " - 32) / 12\n"
+ " call12 1f\n"
+ " retw\n"
+ " .align 4\n"
+ "1:\n"
+ " .rept (" __stringify(XCHAL_NUM_AREGS) " - 16) / 12\n"
" _entry a1, 48\n"
" mov a12, a0\n"
" .endr\n"
-#endif
- " _entry a1, 48\n"
+ " _entry a1, 16\n"
#if XCHAL_NUM_AREGS % 12 == 0
- " mov a8, a8\n"
-#elif XCHAL_NUM_AREGS % 12 == 4
" mov a12, a12\n"
-#elif XCHAL_NUM_AREGS % 12 == 8
+#elif XCHAL_NUM_AREGS % 12 == 4
" mov a4, a4\n"
+#elif XCHAL_NUM_AREGS % 12 == 8
+ " mov a8, a8\n"
#endif
" retw\n"
+#endif
"2:\n"
- : : : "a12", "a13", "memory");
+ : : : "a8", "a9", "memory");
#else
__asm__ __volatile__ (
" mov a12, a12\n"
diff --git a/arch/xtensa/kernel/entry.S b/arch/xtensa/kernel/entry.S
index d060fc2..5771d5c 100644
--- a/arch/xtensa/kernel/entry.S
+++ b/arch/xtensa/kernel/entry.S
@@ -1838,7 +1838,7 @@ ENDPROC(system_call)
mov a12, a0
.endr
#endif
- _entry a1, 48
+ _entry a1, 16
#if XCHAL_NUM_AREGS % 12 == 0
mov a8, a8
#elif XCHAL_NUM_AREGS % 12 == 4
@@ -1862,7 +1862,7 @@ ENDPROC(system_call)
ENTRY(_switch_to)
- entry a1, 16
+ entry a1, 48
mov a11, a3 # and 'next' (a3)
--
1.8.1.4
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v2 00/13] Support hardware perf counters on xtensa Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 10/13] xtensa: fix kernel register spilling Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 12/13] xtensa: implement fake NMI Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 13/13] xtensa: drop unused irq_err_count Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 07/13] xtensa: implement counting and sampling perf events Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 08/13] perf tools: xtensa: add DWARF register names Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200 [PATCH v2 03/13] xtensa: move oprofile stack tracing to stacktrace.c Max Filippov <jcmvbkbc@gmail.com> - 2015-07-18 10:40 +0200
csiph-web