Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
0004  *
0005  * This vDSO turns all calls into a syscall so that UML can trap them.
0006  */
0007 
0008 
0009 /* Disable profiling for userspace code */
0010 #define DISABLE_BRANCH_PROFILING
0011 
0012 #include <linux/time.h>
0013 #include <linux/getcpu.h>
0014 #include <asm/unistd.h>
0015 
0016 int __vdso_clock_gettime(clockid_t clock, struct __kernel_old_timespec *ts)
0017 {
0018     long ret;
0019 
0020     asm("syscall" : "=a" (ret) :
0021         "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
0022 
0023     return ret;
0024 }
0025 int clock_gettime(clockid_t, struct __kernel_old_timespec *)
0026     __attribute__((weak, alias("__vdso_clock_gettime")));
0027 
0028 int __vdso_gettimeofday(struct __kernel_old_timeval *tv, struct timezone *tz)
0029 {
0030     long ret;
0031 
0032     asm("syscall" : "=a" (ret) :
0033         "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
0034 
0035     return ret;
0036 }
0037 int gettimeofday(struct __kernel_old_timeval *, struct timezone *)
0038     __attribute__((weak, alias("__vdso_gettimeofday")));
0039 
0040 __kernel_old_time_t __vdso_time(__kernel_old_time_t *t)
0041 {
0042     long secs;
0043 
0044     asm volatile("syscall"
0045         : "=a" (secs)
0046         : "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
0047 
0048     return secs;
0049 }
0050 __kernel_old_time_t time(__kernel_old_time_t *t) __attribute__((weak, alias("__vdso_time")));
0051 
0052 long
0053 __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
0054 {
0055     /*
0056      * UML does not support SMP, we can cheat here. :)
0057      */
0058 
0059     if (cpu)
0060         *cpu = 0;
0061     if (node)
0062         *node = 0;
0063 
0064     return 0;
0065 }
0066 
0067 long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
0068     __attribute__((weak, alias("__vdso_getcpu")));