summaryrefslogtreecommitdiffstats
path: root/arch/xtensa/kernel/mcount.S
diff options
context:
space:
mode:
authorMax Filippov <jcmvbkbc@gmail.com>2021-05-01 15:32:58 -0700
committerMax Filippov <jcmvbkbc@gmail.com>2021-10-18 22:19:35 -0700
commit0b5372570b1f3fcb35255d28e707846e613c27f2 (patch)
tree7f38b947b50ad051903ec2d251fb51f3c62bc706 /arch/xtensa/kernel/mcount.S
parent5cce39b6aaa02da77e071b2b0880bedfb903330f (diff)
downloadlinux-0b5372570b1f3fcb35255d28e707846e613c27f2.tar.gz
linux-0b5372570b1f3fcb35255d28e707846e613c27f2.tar.bz2
linux-0b5372570b1f3fcb35255d28e707846e613c27f2.zip
xtensa: implement call0 ABI support in assembly
Replace hardcoded register and opcode names with ABI-agnostic macros. Add register save/restore code where necessary. Conditionalize windowed only or call0 only code. Add stack initialization matching _switch_to epilogue to copy_thread. Signed-off-by: Max Filippov <jcmvbkbc@gmail.com>
Diffstat (limited to 'arch/xtensa/kernel/mcount.S')
-rw-r--r--arch/xtensa/kernel/mcount.S38
1 files changed, 36 insertions, 2 deletions
diff --git a/arch/xtensa/kernel/mcount.S b/arch/xtensa/kernel/mcount.S
index 5e4619f52858..51daaf4e0b82 100644
--- a/arch/xtensa/kernel/mcount.S
+++ b/arch/xtensa/kernel/mcount.S
@@ -17,11 +17,16 @@
/*
* Entry condition:
*
- * a2: a0 of the caller
+ * a2: a0 of the caller in windowed ABI
+ * a10: a0 of the caller in call0 ABI
+ *
+ * In call0 ABI the function _mcount is called with the special ABI:
+ * its argument is in a10 and all the usual argument registers (a2 - a7)
+ * must be preserved in addition to callee-saved a12 - a15.
*/
ENTRY(_mcount)
-
+#if defined(__XTENSA_WINDOWED_ABI__)
abi_entry_default
movi a4, ftrace_trace_function
@@ -42,7 +47,36 @@ ENTRY(_mcount)
callx4 a4
abi_ret_default
+#elif defined(__XTENSA_CALL0_ABI__)
+ abi_entry_default
+
+ movi a9, ftrace_trace_function
+ l32i a9, a9, 0
+ movi a11, ftrace_stub
+ bne a9, a11, 1f
+ abi_ret_default
+1: abi_entry(28)
+ s32i a0, sp, 0
+ s32i a2, sp, 4
+ s32i a3, sp, 8
+ s32i a4, sp, 12
+ s32i a5, sp, 16
+ s32i a6, sp, 20
+ s32i a7, sp, 24
+ addi a2, a10, -MCOUNT_INSN_SIZE
+ callx0 a9
+ l32i a0, sp, 0
+ l32i a2, sp, 4
+ l32i a3, sp, 8
+ l32i a4, sp, 12
+ l32i a5, sp, 16
+ l32i a6, sp, 20
+ l32i a7, sp, 24
+ abi_ret(28)
+#else
+#error Unsupported Xtensa ABI
+#endif
ENDPROC(_mcount)
ENTRY(ftrace_stub)