1 /* SPDX-License-Identifier: GPL-2.0 */
3 * Userland implementation of gettimeofday() for 64 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: ltgr %r3,%r3 /* check if tz is NULL */
27 mvc 0(8,%r3),__VDSO_TIMEZONE(%r5)
28 1: ltgr %r2,%r2 /* check if tv is NULL */
30 lg %r4,__VDSO_UPD_COUNT(%r5) /* load update counter */
31 tmll %r4,0x0001 /* pending update ? loop */
33 stcke 0(%r15) /* Store TOD clock */
35 lg %r0,__VDSO_TS_END(%r5) /* TOD steering end time */
36 slgr %r0,%r1 /* now - ts_steering_end */
37 ltgr %r0,%r0 /* past end of steering ? */
39 srlg %r0,%r0,15 /* 1 per 2^16 */
40 tm __VDSO_TS_DIR+3(%r5),0x01 /* steering direction? */
42 lcgr %r0,%r0 /* negative TOD offset */
43 7: algr %r1,%r0 /* add steering offset */
44 6: sg %r1,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */
45 msgf %r1,__VDSO_TK_MULT(%r5) /* * tk->mult */
46 alg %r1,__VDSO_XTIME_NSEC(%r5) /* + tk->xtime_nsec */
47 lg %r0,__VDSO_XTIME_SEC(%r5) /* tk->xtime_sec */
48 clg %r4,__VDSO_UPD_COUNT(%r5) /* check update counter */
50 lgf %r5,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */
51 srlg %r1,%r1,0(%r5) /* >> tk->shift */
58 3: stg %r0,0(%r2) /* store tv->tv_sec */
59 slgr %r0,%r0 /* tv_nsec -> tv_usec */
62 stg %r0,8(%r2) /* store tv->tv_usec */
65 CFI_ADJUST_CFA_OFFSET -16
71 .size __kernel_gettimeofday,.-__kernel_gettimeofday