um_vdso.c 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright (C) 2011 Richard Weinberger <richrd@nod.at>
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License version 2 as
  6. * published by the Free Software Foundation.
  7. *
  8. * This vDSO turns all calls into a syscall so that UML can trap them.
  9. */
  10. /* Disable profiling for userspace code */
  11. #define DISABLE_BRANCH_PROFILING
  12. #include <linux/time.h>
  13. #include <linux/getcpu.h>
  14. #include <asm/unistd.h>
  15. int __vdso_clock_gettime(clockid_t clock, struct timespec *ts)
  16. {
  17. long ret;
  18. asm("syscall" : "=a" (ret) :
  19. "0" (__NR_clock_gettime), "D" (clock), "S" (ts) : "memory");
  20. return ret;
  21. }
  22. int clock_gettime(clockid_t, struct timespec *)
  23. __attribute__((weak, alias("__vdso_clock_gettime")));
  24. int __vdso_gettimeofday(struct timeval *tv, struct timezone *tz)
  25. {
  26. long ret;
  27. asm("syscall" : "=a" (ret) :
  28. "0" (__NR_gettimeofday), "D" (tv), "S" (tz) : "memory");
  29. return ret;
  30. }
  31. int gettimeofday(struct timeval *, struct timezone *)
  32. __attribute__((weak, alias("__vdso_gettimeofday")));
  33. time_t __vdso_time(time_t *t)
  34. {
  35. long secs;
  36. asm volatile("syscall"
  37. : "=a" (secs)
  38. : "0" (__NR_time), "D" (t) : "cc", "r11", "cx", "memory");
  39. return secs;
  40. }
  41. int time(time_t *t) __attribute__((weak, alias("__vdso_time")));
  42. long
  43. __vdso_getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *unused)
  44. {
  45. /*
  46. * UML does not support SMP, we can cheat here. :)
  47. */
  48. if (cpu)
  49. *cpu = 0;
  50. if (node)
  51. *node = 0;
  52. return 0;
  53. }
  54. long getcpu(unsigned *cpu, unsigned *node, struct getcpu_cache *tcache)
  55. __attribute__((weak, alias("__vdso_getcpu")));