“212f2a87b74f1efd645297893c7f3657abd55dcd”上不存在“README.md”
提交 75794257 编写于 作者: V Vasily Gorbik

s390: correct CALL_ON_STACK back_chain saving

Currently CALL_ON_STACK saves r15 as back_chain in the first stack frame of
the stack we about to switch to. But if a function which uses CALL_ON_STACK
calls other function it allocates a stack frame for a callee. In this
case r15 is pointing to a callee stack frame and not a stack frame of
function itself. This results in dummy unwinding entry with random
sp and ip values.

Introduce and utilize current_frame_address macro to get an address of
actual function stack frame.
Reviewed-by: NHeiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: NVasily Gorbik <gor@linux.ibm.com>
上级 103b4cca
...@@ -62,6 +62,17 @@ struct stack_frame { ...@@ -62,6 +62,17 @@ struct stack_frame {
}; };
#endif #endif
/*
* Unlike current_stack_pointer() which simply returns current value of %r15
* current_frame_address() returns function stack frame address, which matches
* %r15 upon function invocation. It may differ from %r15 later if function
* allocates stack for local variables or new stack frame to call other
* functions.
*/
#define current_frame_address() \
((unsigned long)__builtin_frame_address(0) - \
offsetof(struct stack_frame, back_chain))
#define CALL_ARGS_0() \ #define CALL_ARGS_0() \
register unsigned long r2 asm("2") register unsigned long r2 asm("2")
#define CALL_ARGS_1(arg1) \ #define CALL_ARGS_1(arg1) \
...@@ -95,18 +106,20 @@ struct stack_frame { ...@@ -95,18 +106,20 @@ struct stack_frame {
#define CALL_ON_STACK(fn, stack, nr, args...) \ #define CALL_ON_STACK(fn, stack, nr, args...) \
({ \ ({ \
unsigned long frame = current_frame_address(); \
CALL_ARGS_##nr(args); \ CALL_ARGS_##nr(args); \
unsigned long prev; \ unsigned long prev; \
\ \
asm volatile( \ asm volatile( \
" la %[_prev],0(15)\n" \ " la %[_prev],0(15)\n" \
" la 15,0(%[_stack])\n" \ " la 15,0(%[_stack])\n" \
" stg %[_prev],%[_bc](15)\n" \ " stg %[_frame],%[_bc](15)\n" \
" brasl 14,%[_fn]\n" \ " brasl 14,%[_fn]\n" \
" la 15,0(%[_prev])\n" \ " la 15,0(%[_prev])\n" \
: [_prev] "=&a" (prev), CALL_FMT_##nr \ : [_prev] "=&a" (prev), CALL_FMT_##nr \
[_stack] "a" (stack), \ [_stack] "a" (stack), \
[_bc] "i" (offsetof(struct stack_frame, back_chain)), \ [_bc] "i" (offsetof(struct stack_frame, back_chain)), \
[_frame] "d" (frame), \
[_fn] "X" (fn) : CALL_CLOBBER_##nr); \ [_fn] "X" (fn) : CALL_CLOBBER_##nr); \
r2; \ r2; \
}) })
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部