1/* SPDX-License-Identifier: GPL-2.0 */ 2/* 3 * Userland implementation of gettimeofday() for 32 bits processes in a 4 * s390 kernel for use in the vDSO 5 * 6 * Copyright IBM Corp. 2008 7 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 8 */ 9#include <asm/vdso.h> 10#include <asm/asm-offsets.h> 11#include <asm/unistd.h> 12#include <asm/dwarf.h> 13 14 .text 15 .align 4 16 .globl __kernel_gettimeofday 17 .type __kernel_gettimeofday,@function 18__kernel_gettimeofday: 19 CFI_STARTPROC 20 ahi %r15,-16 21 CFI_ADJUST_CFA_OFFSET 16 22 CFI_VAL_OFFSET 15, -160 23 basr %r5,0 240: al %r5,13f-0b(%r5) /* get &_vdso_data */ 251: ltr %r3,%r3 /* check if tz is NULL */ 26 je 2f 27 mvc 0(8,%r3),__VDSO_TIMEZONE(%r5) 282: ltr %r2,%r2 /* check if tv is NULL */ 29 je 10f 30 l %r4,__VDSO_UPD_COUNT+4(%r5) /* load update counter */ 31 tml %r4,0x0001 /* pending update ? loop */ 32 jnz 1b 33 stcke 0(%r15) /* Store TOD clock */ 34 lm %r0,%r1,__VDSO_TS_END(%r5) /* TOD steering end time */ 35 s %r0,1(%r15) 36 sl %r1,5(%r15) 37 brc 3,14f 38 ahi %r0,-1 3914: ltr %r0,%r0 /* past end of steering? */ 40 jm 16f 41 srdl %r0,15 /* 1 per 2^16 */ 42 tm __VDSO_TS_DIR+3(%r5),0x01 /* steering direction? */ 43 jz 15f 44 lcr %r0,%r0 /* negative TOD offset */ 45 lcr %r1,%r1 46 je 15f 47 ahi %r0,-1 4815: a %r0,1(%r15) /* add TOD timestamp */ 49 al %r1,5(%r15) 50 brc 12,17f 51 ahi %r0,1 52 j 17f 5316: lm %r0,%r1,1(%r15) /* load TOD timestamp */ 5417: s %r0,__VDSO_XTIME_STAMP(%r5) /* TOD - cycle_last */ 55 sl %r1,__VDSO_XTIME_STAMP+4(%r5) 56 brc 3,3f 57 ahi %r0,-1 583: ms %r0,__VDSO_TK_MULT(%r5) /* * tk->mult */ 59 st %r0,0(%r15) 60 l %r0,__VDSO_TK_MULT(%r5) 61 ltr %r1,%r1 62 mr %r0,%r0 63 jnm 4f 64 a %r0,__VDSO_TK_MULT(%r5) 654: al %r0,0(%r15) 66 al %r0,__VDSO_XTIME_NSEC(%r5) /* + xtime */ 67 al %r1,__VDSO_XTIME_NSEC+4(%r5) 68 brc 12,5f 69 ahi %r0,1 705: mvc 0(4,%r15),__VDSO_XTIME_SEC+4(%r5) 71 cl %r4,__VDSO_UPD_COUNT+4(%r5) /* check update counter */ 72 jne 1b 73 l %r4,__VDSO_TK_SHIFT(%r5) /* Timekeeper shift */ 74 srdl %r0,0(%r4) /* >> tk->shift */ 75 l %r4,0(%r15) /* get tv_sec from stack */ 76 basr %r5,0 776: ltr %r0,%r0 78 jnz 7f 79 cl %r1,11f-6b(%r5) 80 jl 8f 817: ahi %r4,1 82 sl %r1,11f-6b(%r5) 83 brc 3,6b 84 ahi %r0,-1 85 j 6b 868: st %r4,0(%r2) /* store tv->tv_sec */ 87 ltr %r1,%r1 88 m %r0,12f-6b(%r5) 89 jnm 9f 90 al %r0,12f-6b(%r5) 919: srl %r0,6 92 st %r0,4(%r2) /* store tv->tv_usec */ 9310: slr %r2,%r2 94 ahi %r15,16 95 CFI_ADJUST_CFA_OFFSET -16 96 CFI_RESTORE 15 97 br %r14 98 CFI_ENDPROC 9911: .long 1000000000 10012: .long 274877907 10113: .long _vdso_data - 0b 102 .size __kernel_gettimeofday,.-__kernel_gettimeofday 103