1d2912cb1SThomas Gleixner // SPDX-License-Identifier: GPL-2.0-only
25c48b108SAl Viro /*
35c48b108SAl Viro * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
45c48b108SAl Viro *
55c48b108SAl Viro * This vDSO turns all calls into a syscall so that UML can trap them.
65c48b108SAl Viro */
75c48b108SAl Viro
85c48b108SAl Viro
95c48b108SAl Viro /* Disable profiling for userspace code */
105c48b108SAl Viro #define DISABLE_BRANCH_PROFILING
115c48b108SAl Viro
125c48b108SAl Viro #include <linux/time.h>
135c48b108SAl Viro #include <linux/getcpu.h>
145c48b108SAl Viro #include <asm/unistd.h>
155c48b108SAl Viro
__vdso_clock_gettime(clockid_t clock,struct __kernel_old_timespec * ts)1682210fc7SArnd Bergmann int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
175c48b108SAl Viro {
185c48b108SAl Viro long ret;
195c48b108SAl Viro
20*5541992eSAmmar Faizi asm("syscall"
21*5541992eSAmmar Faizi : "=a" (ret)
22*5541992eSAmmar Faizi : "0" (__NR_clock_gettime), "D" (clock), "S" (ts)
23*5541992eSAmmar Faizi : "rcx", "r11", "memory");
245c48b108SAl Viro
255c48b108SAl Viro return ret;
265c48b108SAl Viro }
2782210fc7SArnd Bergmann int clock_gettime(clockid_t, struct __kernel_old_timespec *)
285c48b108SAl Viro __attribute__((weak, alias("__vdso_clock_gettime")));
295c48b108SAl Viro
__vdso_gettimeofday(struct __kernel_old_timeval * tv,struct timezone * tz)30ddccf40fSArnd Bergmann int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
315c48b108SAl Viro {
325c48b108SAl Viro long ret;
335c48b108SAl Viro
34*5541992eSAmmar Faizi asm("syscall"
35*5541992eSAmmar Faizi : "=a" (ret)
36*5541992eSAmmar Faizi : "0" (__NR_gettimeofday), "D" (tv), "S" (tz)
37*5541992eSAmmar Faizi : "rcx", "r11", "memory");
385c48b108SAl Viro
395c48b108SAl Viro return ret;
405c48b108SAl Viro }
41ddccf40fSArnd Bergmann int gettimeofday(struct __kernel_old_timeval *, struct timezone *)
425c48b108SAl Viro __attribute__((weak, alias("__vdso_gettimeofday")));
435c48b108SAl Viro
__vdso_time(__kernel_old_time_t * t)4421346564SArnd Bergmann __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
455c48b108SAl Viro {
465c48b108SAl Viro long secs;
475c48b108SAl Viro
485c48b108SAl Viro asm volatile("syscall"
495c48b108SAl Viro : "=a" (secs)
505c48b108SAl Viro : "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
515c48b108SAl Viro
525c48b108SAl Viro return secs;
535c48b108SAl Viro }
5421346564SArnd Bergmann __kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
555c48b108SAl Viro
565c48b108SAl Viro long
__vdso_getcpu(unsigned * cpu,unsigned * node,struct getcpu_cache * unused)575c48b108SAl Viro __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
585c48b108SAl Viro {
595c48b108SAl Viro /*
605c48b108SAl Viro * UML does not support SMP, we can cheat here. :)
615c48b108SAl Viro */
625c48b108SAl Viro
635c48b108SAl Viro if (cpu)
645c48b108SAl Viro *cpu = 0;
655c48b108SAl Viro if (node)
665c48b108SAl Viro *node = 0;
675c48b108SAl Viro
685c48b108SAl Viro return 0;
695c48b108SAl Viro }
705c48b108SAl Viro
715c48b108SAl Viro long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
725c48b108SAl Viro __attribute__((weak, alias("__vdso_getcpu")));
73