s390/vdso: Introduce and use struct stack_frame_vdso_wrapper
authorHeiko Carstens <hca@linux.ibm.com>
Mon, 29 Apr 2024 12:28:47 +0000 (14:28 +0200)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 14 May 2024 11:37:07 +0000 (13:37 +0200)
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: aa44433ac4ee ("s390: add USER_STACKTRACE support")
Reviewed-by: Jens Remus <jremus@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
arch/s390/include/asm/stacktrace.h
arch/s390/kernel/asm-offsets.c
arch/s390/kernel/vdso64/vdso_user_wrapper.S

index 4aefbe32265d8f31b64308350ea3b2b9d8a4d96c..85b6738b826af6f5ce7d2e7d10a4fc97544ee424 100644 (file)
@@ -13,6 +13,11 @@ struct stack_frame_user {
        unsigned long empty2[4];
 };
 
+struct stack_frame_vdso_wrapper {
+       struct stack_frame_user sf;
+       unsigned long return_address;
+};
+
 struct perf_callchain_entry_ctx;
 
 void arch_stack_walk_user_common(stack_trace_consume_fn consume_entry, void *cookie,
index fa5f6885c74aa1f3b5d50b96ad0f633fe393b04a..28017c418442be9e47d091ba53eda128eafbf4ff 100644 (file)
@@ -66,6 +66,10 @@ int main(void)
        OFFSET(__SF_SIE_CONTROL_PHYS, stack_frame, sie_control_block_phys);
        DEFINE(STACK_FRAME_OVERHEAD, sizeof(struct stack_frame));
        BLANK();
+       DEFINE(STACK_FRAME_USER_OVERHEAD, sizeof(struct stack_frame_user));
+       OFFSET(__SFVDSO_RETURN_ADDRESS, stack_frame_vdso_wrapper, return_address);
+       DEFINE(STACK_FRAME_VDSO_OVERHEAD, sizeof(struct stack_frame_vdso_wrapper));
+       BLANK();
        /* idle data offsets */
        OFFSET(__CLOCK_IDLE_ENTER, s390_idle_data, clock_idle_enter);
        OFFSET(__TIMER_IDLE_ENTER, s390_idle_data, timer_idle_enter);
index 85247ef5a41b89a390d3290cefb785c6c5a81ad6..deee8ca9cdbf04eebfceaff8740213f9ebeeefa1 100644 (file)
@@ -6,8 +6,6 @@
 #include <asm/dwarf.h>
 #include <asm/ptrace.h>
 
-#define WRAPPER_FRAME_SIZE (STACK_FRAME_OVERHEAD+8)
-
 /*
  * Older glibc version called vdso without allocating a stackframe. This wrapper
  * is just used to allocate a stackframe. See
        __ALIGN
 __kernel_\func:
        CFI_STARTPROC
-       aghi    %r15,-WRAPPER_FRAME_SIZE
-       CFI_DEF_CFA_OFFSET (STACK_FRAME_OVERHEAD + WRAPPER_FRAME_SIZE)
-       CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD
-       stg     %r14,STACK_FRAME_OVERHEAD(%r15)
-       CFI_REL_OFFSET 14, STACK_FRAME_OVERHEAD
+       aghi    %r15,-STACK_FRAME_VDSO_OVERHEAD
+       CFI_DEF_CFA_OFFSET (STACK_FRAME_USER_OVERHEAD + STACK_FRAME_VDSO_OVERHEAD)
+       CFI_VAL_OFFSET 15,-STACK_FRAME_USER_OVERHEAD
+       stg     %r14,__SFVDSO_RETURN_ADDRESS(%r15)
+       CFI_REL_OFFSET 14,__SFVDSO_RETURN_ADDRESS
        brasl   %r14,__s390_vdso_\func
-       lg      %r14,STACK_FRAME_OVERHEAD(%r15)
+       lg      %r14,__SFVDSO_RETURN_ADDRESS(%r15)
        CFI_RESTORE 14
-       aghi    %r15,WRAPPER_FRAME_SIZE
-       CFI_DEF_CFA_OFFSET STACK_FRAME_OVERHEAD
+       aghi    %r15,STACK_FRAME_VDSO_OVERHEAD
+       CFI_DEF_CFA_OFFSET STACK_FRAME_USER_OVERHEAD
        CFI_RESTORE 15
        br      %r14
        CFI_ENDPROC