glibc-2.19-remove-vdso.patch 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. unchanged:
  2. --- a/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  3. +++ b/sysdeps/unix/sysv/linux/x86_64/clock_gettime.c
  4. @@ -1,5 +1,6 @@
  5. #include "bits/libc-vdso.h"
  6. +#if 0 /* in Graphene, disallow VDSO calls */
  7. #ifdef SHARED
  8. # define SYSCALL_GETTIME(id, tp) \
  9. ({ long int (*f) (clockid_t, struct timespec *) = __vdso_clock_gettime; \
  10. @@ -16,5 +17,6 @@
  11. PTR_DEMANGLE (f); \
  12. f (id, tp); })
  13. #endif
  14. +#endif
  15. #include "../clock_gettime.c"
  16. unchanged:
  17. --- a/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  18. +++ b/sysdeps/unix/sysv/linux/x86_64/gettimeofday.c
  19. @@ -17,6 +17,7 @@
  20. #include <sys/time.h>
  21. +#if 0 /* In graphene, do not use vsyscall or VDSO call */
  22. #ifdef SHARED
  23. # include <dl-vdso.h>
  24. @@ -42,7 +43,8 @@ asm (".type __gettimeofday, %gnu_indirect_function");
  25. asm (".globl __GI___gettimeofday\n"
  26. "__GI___gettimeofday = __gettimeofday");
  27. -#else
  28. +#endif
  29. +#endif
  30. # include <sysdep.h>
  31. # include <errno.h>
  32. @@ -54,6 +56,5 @@ __gettimeofday (struct timeval *tv, struct timezone *tz)
  33. }
  34. libc_hidden_def (__gettimeofday)
  35. -#endif
  36. weak_alias (__gettimeofday, gettimeofday)
  37. libc_hidden_weak (gettimeofday)
  38. unchanged:
  39. --- a/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S 2019-08-13 16:07:35.878486727 -0700
  40. +++ b/nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S 2019-08-13 16:07:56.166508488 -0700
  41. @@ -485,15 +485,8 @@ __pthread_cond_timedwait:
  42. /* Only clocks 0 and 1 are allowed so far. Both are handled in the
  43. kernel. */
  44. leaq 32(%rsp), %rsi
  45. -# ifdef SHARED
  46. - mov __vdso_clock_gettime@GOTPCREL(%rip), %RAX_LP
  47. - mov (%rax), %RAX_LP
  48. - PTR_DEMANGLE (%RAX_LP)
  49. - call *%rax
  50. -# else
  51. movl $__NR_clock_gettime, %eax
  52. SYSCALLDB
  53. -# endif
  54. /* Compute relative timeout. */
  55. movq (%r13), %rcx
  56. unchanged:
  57. --- a/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S 2019-08-13 16:02:43.550205689 -0700
  58. +++ b/sysdeps/unix/sysv/linux/x86_64/sched_getcpu.S 2019-08-13 16:03:29.282244893 -0700
  59. @@ -30,6 +30,7 @@ ENTRY (sched_getcpu)
  60. sub $0x8, %rsp
  61. cfi_adjust_cfa_offset(8)
  62. +#if 0 /* for Graphene, never do VDSO calls */
  63. movq %rsp, %rdi
  64. xorl %esi, %esi
  65. movl $VGETCPU_CACHE_OFFSET, %edx
  66. @@ -39,16 +40,19 @@ ENTRY (sched_getcpu)
  67. movq __vdso_getcpu(%rip), %rax
  68. PTR_DEMANGLE (%rax)
  69. callq *%rax
  70. -#else
  71. -# ifdef __NR_getcpu
  72. +#endif
  73. +#endif
  74. +
  75. +#ifdef __NR_getcpu
  76. movl $__NR_getcpu, %eax
  77. SYSCALLDB
  78. -# ifndef __ASSUME_GETCPU_SYSCALL
  79. +#endif
  80. +
  81. +#if 0 /* for Graphene, never do vsyscall */
  82. +# ifndef __ASSUME_GETCPU_SYSCALL
  83. cmpq $-ENOSYS, %rax
  84. jne 1f
  85. -# endif
  86. -# endif
  87. -# ifndef __ASSUME_GETCPU_SYSCALL
  88. +
  89. movq $VSYSCALL_ADDR_vgetcpu, %rax
  90. callq *%rax
  91. 1:
  92. unchanged:
  93. --- glibc-2.19-orig/sysdeps/unix/sysv/linux/x86_64/time.c 2014-02-07 01:04:38.000000000 -0800
  94. +++ glibc-2.19-modify/sysdeps/unix/sysv/linux/x86_64/time.c 1969-12-31 16:00:00.000000000 -0800
  95. @@ -1,60 +0,0 @@
  96. -/* Copyright (C) 2001-2014 Free Software Foundation, Inc.
  97. - This file is part of the GNU C Library.
  98. -
  99. - The GNU C Library is free software; you can redistribute it and/or
  100. - modify it under the terms of the GNU Lesser General Public
  101. - License as published by the Free Software Foundation; either
  102. - version 2.1 of the License, or (at your option) any later version.
  103. -
  104. - The GNU C Library is distributed in the hope that it will be useful,
  105. - but WITHOUT ANY WARRANTY; without even the implied warranty of
  106. - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  107. - Lesser General Public License for more details.
  108. -
  109. - You should have received a copy of the GNU Lesser General Public
  110. - License along with the GNU C Library; if not, see
  111. - <http://www.gnu.org/licenses/>. */
  112. -
  113. -#ifdef SHARED
  114. -/* Redefine time so that the compiler won't complain about the type
  115. - mismatch with the IFUNC selector in strong_alias, below. */
  116. -#undef time
  117. -#define time __redirect_time
  118. -#include <time.h>
  119. -
  120. -#include <dl-vdso.h>
  121. -
  122. -#define VSYSCALL_ADDR_vtime 0xffffffffff600400
  123. -
  124. -/* Avoid DWARF definition DIE on ifunc symbol so that GDB can handle
  125. - ifunc symbol properly. */
  126. -extern __typeof (__redirect_time) __libc_time;
  127. -void *time_ifunc (void) __asm__ ("__libc_time");
  128. -
  129. -void *
  130. -time_ifunc (void)
  131. -{
  132. - PREPARE_VERSION (linux26, "LINUX_2.6", 61765110);
  133. -
  134. - /* If the vDSO is not available we fall back on the old vsyscall. */
  135. - return _dl_vdso_vsym ("__vdso_time", &linux26) ?: (void *) VSYSCALL_ADDR_vtime;
  136. -}
  137. -__asm (".type __libc_time, %gnu_indirect_function");
  138. -
  139. -#undef time
  140. -strong_alias (__libc_time, time)
  141. -libc_hidden_ver (__libc_time, time)
  142. -
  143. -#else
  144. -
  145. -# include <time.h>
  146. -# include <sysdep.h>
  147. -
  148. -time_t
  149. -time (time_t *t)
  150. -{
  151. - INTERNAL_SYSCALL_DECL (err);
  152. - return INTERNAL_SYSCALL (time, err, 1, t);
  153. -}
  154. -
  155. -#endif
  156. only in patch2:
  157. unchanged:
  158. --- a/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  159. +++ b/sysdeps/unix/sysv/linux/x86_64/sysdep.h
  160. @@ -252,6 +252,7 @@
  161. # undef INTERNAL_SYSCALL_ERRNO
  162. # define INTERNAL_SYSCALL_ERRNO(val, err) (-(val))
  163. +# if 0 /* for Graphene, never do vsyscall */
  164. # ifdef SHARED
  165. # define INLINE_VSYSCALL(name, nr, args...) \
  166. ({ \
  167. @@ -300,12 +301,13 @@
  168. v_ret; \
  169. })
  170. -# else
  171. -# define INLINE_VSYSCALL(name, nr, args...) \
  172. - INLINE_SYSCALL (name, nr, ##args)
  173. -# define INTERNAL_VSYSCALL(name, err, nr, args...) \
  174. - INTERNAL_SYSCALL (name, err, nr, ##args)
  175. # endif
  176. +# endif
  177. +
  178. +# define INLINE_VSYSCALL(name, nr_args...) \
  179. + INLINE_SYSCALL (name, ##nr_args)
  180. +# define INTERNAL_VSYSCALL(name, err, nr_args...) \
  181. + INTERNAL_SYSCALL (name, err, ##nr_args)
  182. # define LOAD_ARGS_0()
  183. # define LOAD_REGS_0