1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Userland implementation of gettimeofday() for 32 bits processes in a
4 * s390 kernel for use in the vDSO
6 * Copyright IBM Corp. 2008
7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
10 #include <asm/asm-offsets.h>
11 #include <asm/unistd.h>
12 #include <asm/dwarf.h>
13 #include <asm/ptrace.h>
17 .globl __kernel_gettimeofday
18 .type __kernel_gettimeofday,@function
19 __kernel_gettimeofday:
22 CFI_ADJUST_CFA_OFFSET 16
23 CFI_VAL_OFFSET 15, -STACK_FRAME_OVERHEAD
25 0: al %r5,13f-0b(%r5) /* get &_vdso_data */
26 1: ltr %r3,%r3 /* check if tz is NULL */
28 mvc 0(8,%r3),__VDSO_TIMEZONE(%r5)
29 2: ltr %r2,%r2 /* check if tv is NULL */
31 l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */
32 tml %r4,0x0001 /* pending update ? loop */
34 stcke 0(%r15) /* Store TOD clock */
35 lm %r0,%r1,__VDSO_TS_END(%r5) /* TOD steering end time */
40 14: ltr %r0,%r0 /* past end of steering? */
42 srdl %r0,15 /* 1 per 2^16 */
43 tm __VDSO_TS_DIR+3(%r5),0x01 /* steering direction? */
45 lcr %r0,%r0 /* negative TOD offset */
49 15: a %r0,1(%r15) /* add TOD timestamp */
54 16: lm %r0,%r1,1(%r15) /* load TOD timestamp */
55 17: s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
56 sl %r1,__VDSO_XTIME_STAMP+4(%r5)
59 3: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */
61 l %r0,__VDSO_TK_MULT(%r5)
65 a %r0,__VDSO_TK_MULT(%r5)
67 al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */
68 al %r1,__VDSO_XTIME_NSEC+4(%r5)
71 5: mvc 0(4,%r15),__VDSO_XTIME_SEC+4(%r5)
72 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */
74 l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
75 srdl %r0,0(%r4) /* >> tk->shift */
76 l %r4,0(%r15) /* get tv_sec from stack */
87 8: st %r4,0(%r2) /* store tv->tv_sec */
93 st %r0,4(%r2) /* store tv->tv_usec */
96 CFI_ADJUST_CFA_OFFSET -16
102 13: .long _vdso_data - 0b
103 .size __kernel_gettimeofday,.-__kernel_gettimeofday