powerpc/pseries/vas: Use QoS credits from the userspace
[linux-block.git] / arch / powerpc / kernel / vdso / gettimeofday.S
CommitLineData
2874c5fd 1/* SPDX-License-Identifier: GPL-2.0-or-later */
a7f290da 2/*
f061fb03
CL
3 * Userland implementation of gettimeofday() for processes
4 * for use in the vDSO
a7f290da
BH
5 *
6 * Copyright (C) 2004 Benjamin Herrenschmuidt (benh@kernel.crashing.org,
7 * IBM Corp.
a7f290da 8 */
a7f290da
BH
9#include <asm/processor.h>
10#include <asm/ppc_asm.h>
11#include <asm/vdso.h>
ec0895f0 12#include <asm/vdso_datapage.h>
a7f290da
BH
13#include <asm/asm-offsets.h>
14#include <asm/unistd.h>
692b21d7
CL
15
16/*
17 * The macro sets two stack frames, one for the caller and one for the callee
18 * because there are no requirement for the caller to set a stack frame when
19 * calling VDSO so it may have omitted to set one, especially on PPC64
20 */
21
22.macro cvdso_call funct call_time=0
23 .cfi_startproc
24 PPC_STLU r1, -PPC_MIN_STKFRM(r1)
25 mflr r0
26 .cfi_register lr, r0
27 PPC_STLU r1, -PPC_MIN_STKFRM(r1)
28 PPC_STL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
29#ifdef __powerpc64__
30 PPC_STL r2, PPC_MIN_STKFRM + STK_GOT(r1)
31#endif
32 get_datapage r5
33 .ifeq \call_time
34 addi r5, r5, VDSO_DATA_OFFSET
35 .else
36 addi r4, r5, VDSO_DATA_OFFSET
37 .endif
38 bl DOTSYM(\funct)
39 PPC_LL r0, PPC_MIN_STKFRM + PPC_LR_STKOFF(r1)
40#ifdef __powerpc64__
41 PPC_LL r2, PPC_MIN_STKFRM + STK_GOT(r1)
42#endif
43 .ifeq \call_time
44 cmpwi r3, 0
45 .endif
46 mtlr r0
47 .cfi_restore lr
48 addi r1, r1, 2 * PPC_MIN_STKFRM
49 crclr so
50 .ifeq \call_time
51 beqlr+
52 crset so
53 neg r3, r3
54 .endif
55 blr
56 .cfi_endproc
57.endm
597bc5c0 58
a7f290da
BH
59 .text
60/*
61 * Exact prototype of gettimeofday
62 *
63 * int __kernel_gettimeofday(struct timeval *tv, struct timezone *tz);
64 *
65 */
66V_FUNCTION_BEGIN(__kernel_gettimeofday)
ab037dd8 67 cvdso_call __c_kernel_gettimeofday
a7f290da
BH
68V_FUNCTION_END(__kernel_gettimeofday)
69
70/*
71 * Exact prototype of clock_gettime()
72 *
73 * int __kernel_clock_gettime(clockid_t clock_id, struct timespec *tp);
74 *
75 */
76V_FUNCTION_BEGIN(__kernel_clock_gettime)
ab037dd8 77 cvdso_call __c_kernel_clock_gettime
a7f290da
BH
78V_FUNCTION_END(__kernel_clock_gettime)
79
d0e3fc69
CL
80/*
81 * Exact prototype of clock_gettime64()
82 *
83 * int __kernel_clock_gettime64(clockid_t clock_id, struct __timespec64 *ts);
84 *
85 */
f061fb03 86#ifndef __powerpc64__
d0e3fc69
CL
87V_FUNCTION_BEGIN(__kernel_clock_gettime64)
88 cvdso_call __c_kernel_clock_gettime64
89V_FUNCTION_END(__kernel_clock_gettime64)
f061fb03 90#endif
a7f290da
BH
91
92/*
93 * Exact prototype of clock_getres()
94 *
95 * int __kernel_clock_getres(clockid_t clock_id, struct timespec *res);
96 *
97 */
98V_FUNCTION_BEGIN(__kernel_clock_getres)
ab037dd8 99 cvdso_call __c_kernel_clock_getres
a7f290da
BH
100V_FUNCTION_END(__kernel_clock_getres)
101
102
fcb41a20
AZ
103/*
104 * Exact prototype of time()
105 *
106 * time_t time(time *t);
107 *
108 */
109V_FUNCTION_BEGIN(__kernel_time)
9b97bea9 110 cvdso_call __c_kernel_time call_time=1
fcb41a20 111V_FUNCTION_END(__kernel_time)
08c18b63
CL
112
113/* Routines for restoring integer registers, called by the compiler. */
114/* Called with r11 pointing to the stack header word of the caller of the */
115/* function, just beyond the end of the integer restore area. */
f061fb03 116#ifndef __powerpc64__
08c18b63
CL
117_GLOBAL(_restgpr_31_x)
118_GLOBAL(_rest32gpr_31_x)
119 lwz r0,4(r11)
120 lwz r31,-4(r11)
121 mtlr r0
122 mr r1,r11
123 blr
f061fb03 124#endif