Skip to content

Commit be72ea0

Browse files
hcahcaAlexander Gordeev
authored andcommitted
s390/vdso: Introduce and use struct stack_frame_vdso_wrapper
Introduce and use struct stack_frame_vdso_wrapper within vdso user wrapper code. With this structure it is possible to automatically generate an asm-offset define which can be used to save and restore the return address of the calling function. Also use STACK_FRAME_USER_OVERHEAD instead of STACK_FRAME_OVERHEAD to document that the code works with user space stack frames with the standard stack frame layout. Fixes: aa44433 ("s390: add USER_STACKTRACE support") Reviewed-by: Jens Remus <[email protected]> Signed-off-by: Heiko Carstens <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent cd58109 commit be72ea0

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

arch/s390/include/asm/stacktrace.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ struct stack_frame_user {
1313
unsigned long empty2[4];
1414
};
1515

16+
struct stack_frame_vdso_wrapper {
17+
struct stack_frame_user sf;
18+
unsigned long return_address;
19+
};
20+
1621
struct perf_callchain_entry_ctx;
1722

1823
void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *cookie,

arch/s390/kernel/asm-offsets.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ int main(void)
6666
OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys);
6767
DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
6868
BLANK();
69+
DEFINE(STACK_FRAME_USER_OVERHEAD, sizeof(struct stack_frame_user));
70+
OFFSET(__SFVDSO_RETURN_ADDRESS, stack_frame_vdso_wrapper, return_address);
71+
DEFINE(STACK_FRAME_VDSO_OVERHEAD, sizeof(struct stack_frame_vdso_wrapper));
72+
BLANK();
6973
/* idle data offsets */
7074
OFFSET(__CLOCK_IDLE_ENTER, s390_idle_data, clock_idle_enter);
7175
OFFSET(__TIMER_IDLE_ENTER, s390_idle_data, timer_idle_enter);

arch/s390/kernel/vdso64/vdso_user_wrapper.S

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
#include <asm/dwarf.h>
77
#include <asm/ptrace.h>
88

9-
#define WRAPPER_FRAME_SIZE (STACK_FRAME_OVERHEAD+8)
10-
119
/*
1210
* Older glibc version called vdso without allocating a stackframe. This wrapper
1311
* is just used to allocate a stackframe. See
@@ -20,16 +18,16 @@
2018
__ALIGN
2119
__kernel_\func:
2220
CFI_STARTPROC
23-
aghi %r15,-WRAPPER_FRAME_SIZE
24-
CFI_DEF_CFA_OFFSET (STACK_FRAME_OVERHEAD + WRAPPER_FRAME_SIZE)
25-
CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD
26-
stg %r14,STACK_FRAME_OVERHEAD(%r15)
27-
CFI_REL_OFFSET 14, STACK_FRAME_OVERHEAD
21+
aghi %r15,-STACK_FRAME_VDSO_OVERHEAD
22+
CFI_DEF_CFA_OFFSET (STACK_FRAME_USER_OVERHEAD + STACK_FRAME_VDSO_OVERHEAD)
23+
CFI_VAL_OFFSET 15,-STACK_FRAME_USER_OVERHEAD
24+
stg %r14,__SFVDSO_RETURN_ADDRESS(%r15)
25+
CFI_REL_OFFSET 14,__SFVDSO_RETURN_ADDRESS
2826
brasl %r14,__s390_vdso_\func
29-
lg %r14,STACK_FRAME_OVERHEAD(%r15)
27+
lg %r14,__SFVDSO_RETURN_ADDRESS(%r15)
3028
CFI_RESTORE 14
31-
aghi %r15,WRAPPER_FRAME_SIZE
32-
CFI_DEF_CFA_OFFSET STACK_FRAME_OVERHEAD
29+
aghi %r15,STACK_FRAME_VDSO_OVERHEAD
30+
CFI_DEF_CFA_OFFSET STACK_FRAME_USER_OVERHEAD
3331
CFI_RESTORE 15
3432
br %r14
3533
CFI_ENDPROC

0 commit comments

Comments
 (0)