vki-amd64-linux.h 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712
  1. /*--------------------------------------------------------------------*/
  2. /*--- AMD64/Linux-specific kernel interface. vki-amd64-linux.h ---*/
  3. /*--------------------------------------------------------------------*/
  4. /*
  5. This file is part of Valgrind, a dynamic binary instrumentation
  6. framework.
  7. Copyright (C) 2000-2017 Julian Seward
  8. jseward@acm.org
  9. This program is free software; you can redistribute it and/or
  10. modify it under the terms of the GNU General Public License as
  11. published by the Free Software Foundation; either version 2 of the
  12. License, or (at your option) any later version.
  13. This program is distributed in the hope that it will be useful, but
  14. WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. General Public License for more details.
  17. You should have received a copy of the GNU General Public License
  18. along with this program; if not, write to the Free Software
  19. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  20. 02111-1307, USA.
  21. The GNU General Public License is contained in the file COPYING.
  22. */
  23. #ifndef __VKI_AMD64_LINUX_H
  24. #define __VKI_AMD64_LINUX_H
  25. // AMD64 is little-endian.
  26. #define VKI_LITTLE_ENDIAN 1
  27. //----------------------------------------------------------------------
  28. // From linux-2.6.9/include/asm-x86_64/types.h
  29. //----------------------------------------------------------------------
  30. typedef unsigned char __vki_u8;
  31. typedef __signed__ short __vki_s16;
  32. typedef unsigned short __vki_u16;
  33. typedef __signed__ int __vki_s32;
  34. typedef unsigned int __vki_u32;
  35. typedef __signed__ long long __vki_s64;
  36. typedef unsigned long long __vki_u64;
  37. typedef unsigned short vki_u16;
  38. typedef unsigned int vki_u32;
  39. //----------------------------------------------------------------------
  40. // From linux-2.6.9/include/asm-x86_64/page.h
  41. //----------------------------------------------------------------------
  42. #define VKI_PAGE_SHIFT 12
  43. #define VKI_PAGE_SIZE (1UL << VKI_PAGE_SHIFT)
  44. #define VKI_MAX_PAGE_SHIFT VKI_PAGE_SHIFT
  45. #define VKI_MAX_PAGE_SIZE VKI_PAGE_SIZE
  46. //----------------------------------------------------------------------
  47. // From linux-2.6.35.4/arch/x86/include/asm/shmparam.h
  48. //----------------------------------------------------------------------
  49. #define VKI_SHMLBA VKI_PAGE_SIZE
  50. //----------------------------------------------------------------------
  51. // From linux-2.6.9/include/asm-x86_64/signal.h
  52. //----------------------------------------------------------------------
  53. #define _VKI_NSIG 64
  54. #define _VKI_NSIG_BPW 64
  55. #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
  56. typedef unsigned long vki_old_sigset_t; /* at least 32 bits */
  57. typedef struct {
  58. unsigned long sig[_VKI_NSIG_WORDS];
  59. } vki_sigset_t;
  60. #define VKI_SIGHUP 1
  61. #define VKI_SIGINT 2
  62. #define VKI_SIGQUIT 3
  63. #define VKI_SIGILL 4
  64. #define VKI_SIGTRAP 5
  65. #define VKI_SIGABRT 6
  66. #define VKI_SIGBUS 7
  67. #define VKI_SIGFPE 8
  68. #define VKI_SIGKILL 9
  69. #define VKI_SIGUSR1 10
  70. #define VKI_SIGSEGV 11
  71. #define VKI_SIGUSR2 12
  72. #define VKI_SIGPIPE 13
  73. #define VKI_SIGALRM 14
  74. #define VKI_SIGTERM 15
  75. #define VKI_SIGSTKFLT 16
  76. #define VKI_SIGCHLD 17
  77. #define VKI_SIGCONT 18
  78. #define VKI_SIGSTOP 19
  79. #define VKI_SIGTSTP 20
  80. #define VKI_SIGTTIN 21
  81. #define VKI_SIGTTOU 22
  82. #define VKI_SIGURG 23
  83. #define VKI_SIGXCPU 24
  84. #define VKI_SIGXFSZ 25
  85. #define VKI_SIGVTALRM 26
  86. #define VKI_SIGPROF 27
  87. #define VKI_SIGWINCH 28
  88. #define VKI_SIGIO 29
  89. #define VKI_SIGPWR 30
  90. #define VKI_SIGSYS 31
  91. #define VKI_SIGUNUSED 31
  92. #define VKI_SIGRTMIN 32
  93. #define VKI_SIGRTMAX _VKI_NSIG
  94. #define VKI_SA_NOCLDSTOP 0x00000001
  95. #define VKI_SA_NOCLDWAIT 0x00000002
  96. #define VKI_SA_SIGINFO 0x00000004
  97. #define VKI_SA_ONSTACK 0x08000000
  98. #define VKI_SA_RESTART 0x10000000
  99. #define VKI_SA_NODEFER 0x40000000
  100. #define VKI_SA_RESETHAND 0x80000000
  101. #define VKI_SA_NOMASK VKI_SA_NODEFER
  102. #define VKI_SA_ONESHOT VKI_SA_RESETHAND
  103. #define VKI_SA_RESTORER 0x04000000
  104. #define VKI_SS_ONSTACK 1
  105. #define VKI_SS_DISABLE 2
  106. #define VKI_MINSIGSTKSZ 2048
  107. #define VKI_SIG_BLOCK 0 /* for blocking signals */
  108. #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
  109. #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
  110. typedef void __vki_signalfn_t(int);
  111. typedef __vki_signalfn_t __user *__vki_sighandler_t;
  112. typedef void __vki_restorefn_t(void);
  113. typedef __vki_restorefn_t __user *__vki_sigrestore_t;
  114. #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
  115. #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
  116. struct vki_sigaction_base {
  117. // [[Nb: a 'k' prefix is added to "sa_handler" because
  118. // bits/sigaction.h (which gets dragged in somehow via signal.h)
  119. // #defines it as something else. Since that is done for glibc's
  120. // purposes, which we don't care about here, we use our own name.]]
  121. __vki_sighandler_t ksa_handler;
  122. unsigned long sa_flags;
  123. __vki_sigrestore_t sa_restorer;
  124. vki_sigset_t sa_mask; /* mask last for extensibility */
  125. };
  126. /* On Linux we use the same type for passing sigactions to
  127. and from the kernel. Hence: */
  128. typedef struct vki_sigaction_base vki_sigaction_toK_t;
  129. typedef struct vki_sigaction_base vki_sigaction_fromK_t;
  130. typedef struct vki_sigaltstack {
  131. void __user *ss_sp;
  132. int ss_flags;
  133. vki_size_t ss_size;
  134. } vki_stack_t;
  135. //----------------------------------------------------------------------
  136. // From linux-2.6.9/include/asm-x86_64/sigcontext.h
  137. //----------------------------------------------------------------------
  138. struct _vki_fpstate {
  139. __vki_u16 cwd;
  140. __vki_u16 swd;
  141. __vki_u16 twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
  142. __vki_u16 fop;
  143. __vki_u64 rip;
  144. __vki_u64 rdp;
  145. __vki_u32 mxcsr;
  146. __vki_u32 mxcsr_mask;
  147. __vki_u32 st_space[32]; /* 8*16 bytes for each FP-reg */
  148. __vki_u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg */
  149. __vki_u32 reserved2[24];
  150. };
  151. struct vki_sigcontext {
  152. unsigned long r8;
  153. unsigned long r9;
  154. unsigned long r10;
  155. unsigned long r11;
  156. unsigned long r12;
  157. unsigned long r13;
  158. unsigned long r14;
  159. unsigned long r15;
  160. unsigned long rdi;
  161. unsigned long rsi;
  162. unsigned long rbp;
  163. unsigned long rbx;
  164. unsigned long rdx;
  165. unsigned long rax;
  166. unsigned long rcx;
  167. unsigned long rsp;
  168. unsigned long rip;
  169. unsigned long eflags; /* RFLAGS */
  170. unsigned short cs;
  171. unsigned short gs;
  172. unsigned short fs;
  173. unsigned short __pad0;
  174. unsigned long err;
  175. unsigned long trapno;
  176. unsigned long oldmask;
  177. unsigned long cr2;
  178. struct _vki_fpstate __user *fpstate; /* zero when no FPU context */
  179. unsigned long reserved1[8];
  180. };
  181. //----------------------------------------------------------------------
  182. // From linux-2.6.9/include/asm-x86_64/mman.h
  183. //----------------------------------------------------------------------
  184. #define VKI_PROT_READ 0x1 /* page can be read */
  185. #define VKI_PROT_WRITE 0x2 /* page can be written */
  186. #define VKI_PROT_EXEC 0x4 /* page can be executed */
  187. #define VKI_PROT_NONE 0x0 /* page can not be accessed */
  188. #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
  189. #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
  190. #define VKI_MAP_SHARED 0x01 /* Share changes */
  191. #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
  192. #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
  193. #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
  194. #define VKI_MAP_32BIT 0x40 /* only give out 32bit addresses */
  195. #define VKI_MAP_NORESERVE 0x4000 /* don't check for reservations */
  196. //----------------------------------------------------------------------
  197. // From linux-2.6.9/include/asm-x86_64/fcntl.h
  198. //----------------------------------------------------------------------
  199. #define VKI_O_ACCMODE 03
  200. #define VKI_O_RDONLY 00
  201. #define VKI_O_WRONLY 01
  202. #define VKI_O_RDWR 02
  203. #define VKI_O_CREAT 0100 /* not fcntl */
  204. #define VKI_O_EXCL 0200 /* not fcntl */
  205. #define VKI_O_TRUNC 01000 /* not fcntl */
  206. #define VKI_O_APPEND 02000
  207. #define VKI_O_NONBLOCK 04000
  208. #define VKI_O_LARGEFILE 0100000
  209. #define VKI_AT_FDCWD -100
  210. #define VKI_F_DUPFD 0 /* dup */
  211. #define VKI_F_GETFD 1 /* get close_on_exec */
  212. #define VKI_F_SETFD 2 /* set/clear close_on_exec */
  213. #define VKI_F_GETFL 3 /* get file->f_flags */
  214. #define VKI_F_SETFL 4 /* set file->f_flags */
  215. #define VKI_F_GETLK 5
  216. #define VKI_F_SETLK 6
  217. #define VKI_F_SETLKW 7
  218. #define VKI_F_SETOWN 8 /* for sockets. */
  219. #define VKI_F_GETOWN 9 /* for sockets. */
  220. #define VKI_F_SETSIG 10 /* for sockets. */
  221. #define VKI_F_GETSIG 11 /* for sockets. */
  222. #define VKI_F_SETOWN_EX 15
  223. #define VKI_F_GETOWN_EX 16
  224. #define VKI_F_OFD_GETLK 36
  225. #define VKI_F_OFD_SETLK 37
  226. #define VKI_F_OFD_SETLKW 38
  227. #define VKI_F_OWNER_TID 0
  228. #define VKI_F_OWNER_PID 1
  229. #define VKI_F_OWNER_PGRP 2
  230. struct vki_f_owner_ex {
  231. int type;
  232. __vki_kernel_pid_t pid;
  233. };
  234. #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
  235. #define VKI_F_LINUX_SPECIFIC_BASE 1024
  236. //----------------------------------------------------------------------
  237. // From linux-2.6.9/include/asm-x86_64/resource.h
  238. //----------------------------------------------------------------------
  239. #define VKI_RLIMIT_DATA 2 /* max data size */
  240. #define VKI_RLIMIT_STACK 3 /* max stack size */
  241. #define VKI_RLIMIT_CORE 4 /* max core file size */
  242. #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
  243. //----------------------------------------------------------------------
  244. // From linux-2.6.9/include/asm-x86_64/socket.h
  245. //----------------------------------------------------------------------
  246. #define VKI_SOL_SOCKET 1
  247. #define VKI_SO_TYPE 3
  248. #define VKI_SO_ATTACH_FILTER 26
  249. //----------------------------------------------------------------------
  250. // From linux-2.6.9/include/asm-x86_64/sockios.h
  251. //----------------------------------------------------------------------
  252. #define VKI_SIOCSPGRP 0x8902
  253. #define VKI_SIOCGPGRP 0x8904
  254. #define VKI_SIOCATMARK 0x8905
  255. #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  256. #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  257. //----------------------------------------------------------------------
  258. // From linux-2.6.9/include/asm-x86_64/stat.h
  259. //----------------------------------------------------------------------
  260. struct vki_stat {
  261. unsigned long st_dev;
  262. unsigned long st_ino;
  263. unsigned long st_nlink;
  264. unsigned int st_mode;
  265. unsigned int st_uid;
  266. unsigned int st_gid;
  267. unsigned int __pad0;
  268. unsigned long st_rdev;
  269. long st_size;
  270. long st_blksize;
  271. long st_blocks; /* Number 512-byte blocks allocated. */
  272. unsigned long st_atime;
  273. unsigned long st_atime_nsec;
  274. unsigned long st_mtime;
  275. unsigned long st_mtime_nsec;
  276. unsigned long st_ctime;
  277. unsigned long st_ctime_nsec;
  278. long __unused0[3];
  279. };
  280. //----------------------------------------------------------------------
  281. // From linux-2.6.9/include/asm-x86_64/statfs.h
  282. //----------------------------------------------------------------------
  283. struct vki_statfs {
  284. long f_type;
  285. long f_bsize;
  286. long f_blocks;
  287. long f_bfree;
  288. long f_bavail;
  289. long f_files;
  290. long f_ffree;
  291. __vki_kernel_fsid_t f_fsid;
  292. long f_namelen;
  293. long f_frsize;
  294. long f_spare[5];
  295. };
  296. //----------------------------------------------------------------------
  297. // From linux-2.6.9/include/asm-x86_64/termios.h
  298. //----------------------------------------------------------------------
  299. struct vki_winsize {
  300. unsigned short ws_row;
  301. unsigned short ws_col;
  302. unsigned short ws_xpixel;
  303. unsigned short ws_ypixel;
  304. };
  305. #define VKI_NCC 8
  306. struct vki_termio {
  307. unsigned short c_iflag; /* input mode flags */
  308. unsigned short c_oflag; /* output mode flags */
  309. unsigned short c_cflag; /* control mode flags */
  310. unsigned short c_lflag; /* local mode flags */
  311. unsigned char c_line; /* line discipline */
  312. unsigned char c_cc[VKI_NCC]; /* control characters */
  313. };
  314. //----------------------------------------------------------------------
  315. // From linux-2.6.9/include/asm-x86_64/termbits.h
  316. //----------------------------------------------------------------------
  317. typedef unsigned char vki_cc_t;
  318. typedef unsigned int vki_tcflag_t;
  319. #define VKI_NCCS 19
  320. struct vki_termios {
  321. vki_tcflag_t c_iflag; /* input mode flags */
  322. vki_tcflag_t c_oflag; /* output mode flags */
  323. vki_tcflag_t c_cflag; /* control mode flags */
  324. vki_tcflag_t c_lflag; /* local mode flags */
  325. vki_cc_t c_line; /* line discipline */
  326. vki_cc_t c_cc[VKI_NCCS]; /* control characters */
  327. };
  328. //----------------------------------------------------------------------
  329. // From linux-2.6.9/include/asm-x86_64/ioctl.h
  330. //----------------------------------------------------------------------
  331. #define _VKI_IOC_NRBITS 8
  332. #define _VKI_IOC_TYPEBITS 8
  333. #define _VKI_IOC_SIZEBITS 14
  334. #define _VKI_IOC_DIRBITS 2
  335. #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
  336. #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
  337. #define _VKI_IOC_NRSHIFT 0
  338. #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
  339. #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
  340. #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
  341. #define _VKI_IOC_NONE 0U
  342. #define _VKI_IOC_WRITE 1U
  343. #define _VKI_IOC_READ 2U
  344. #define _VKI_IOC(dir,type,nr,size) \
  345. (((dir) << _VKI_IOC_DIRSHIFT) | \
  346. ((type) << _VKI_IOC_TYPESHIFT) | \
  347. ((nr) << _VKI_IOC_NRSHIFT) | \
  348. ((size) << _VKI_IOC_SIZESHIFT))
  349. #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
  350. #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),sizeof(size))
  351. #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size))
  352. #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size))
  353. #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
  354. #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
  355. //----------------------------------------------------------------------
  356. // From linux-2.6.9/include/asm-x86_64/ioctls.h
  357. //----------------------------------------------------------------------
  358. #define VKI_TCGETS 0x5401
  359. #define VKI_TCSETS 0x5402
  360. #define VKI_TCSETSW 0x5403
  361. #define VKI_TCSETSF 0x5404
  362. #define VKI_TCGETA 0x5405
  363. #define VKI_TCSETA 0x5406
  364. #define VKI_TCSETAW 0x5407
  365. #define VKI_TCSETAF 0x5408
  366. #define VKI_TCSBRK 0x5409
  367. #define VKI_TCXONC 0x540A
  368. #define VKI_TCFLSH 0x540B
  369. #define VKI_TIOCSCTTY 0x540E
  370. #define VKI_TIOCGPGRP 0x540F
  371. #define VKI_TIOCSPGRP 0x5410
  372. #define VKI_TIOCOUTQ 0x5411
  373. #define VKI_TIOCGWINSZ 0x5413
  374. #define VKI_TIOCSWINSZ 0x5414
  375. #define VKI_TIOCMGET 0x5415
  376. #define VKI_TIOCMBIS 0x5416
  377. #define VKI_TIOCMBIC 0x5417
  378. #define VKI_TIOCMSET 0x5418
  379. #define VKI_FIONREAD 0x541B
  380. #define VKI_TIOCLINUX 0x541C
  381. #define VKI_FIONBIO 0x5421
  382. #define VKI_TIOCNOTTY 0x5422
  383. #define VKI_TCSBRKP 0x5425 /* Needed for POSIX tcsendbreak() */
  384. #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int) /* Get Pty Number (of pty-mux device) */
  385. #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int) /* Lock/unlock Pty */
  386. #define VKI_FIONCLEX 0x5450
  387. #define VKI_FIOCLEX 0x5451
  388. #define VKI_FIOASYNC 0x5452
  389. #define VKI_TIOCSERGETLSR 0x5459 /* Get line status register */
  390. #define VKI_TIOCGICOUNT 0x545D /* read serial port inline interrupt counts */
  391. //----------------------------------------------------------------------
  392. // From linux-2.6.9/include/asm-x86_64/poll.h
  393. //----------------------------------------------------------------------
  394. #define VKI_POLLIN 0x0001
  395. struct vki_pollfd {
  396. int fd;
  397. short events;
  398. short revents;
  399. };
  400. //----------------------------------------------------------------------
  401. // From linux-2.6.9/include/asm-x86_64/user.h
  402. //----------------------------------------------------------------------
  403. struct vki_user_i387_struct {
  404. unsigned short cwd;
  405. unsigned short swd;
  406. unsigned short twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
  407. unsigned short fop;
  408. __vki_u64 rip;
  409. __vki_u64 rdp;
  410. __vki_u32 mxcsr;
  411. __vki_u32 mxcsr_mask;
  412. __vki_u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  413. __vki_u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
  414. __vki_u32 padding[24];
  415. };
  416. struct vki_user_regs_struct {
  417. unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10;
  418. unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax;
  419. unsigned long rip,cs,eflags;
  420. unsigned long rsp,ss;
  421. unsigned long fs_base, gs_base;
  422. unsigned long ds,es,fs,gs;
  423. };
  424. //----------------------------------------------------------------------
  425. // From linux-2.6.9/include/asm-x86_64/elf.h
  426. //----------------------------------------------------------------------
  427. typedef unsigned long vki_elf_greg_t;
  428. #define VKI_ELF_NGREG (sizeof (struct vki_user_regs_struct) / sizeof(vki_elf_greg_t))
  429. typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
  430. typedef struct vki_user_i387_struct vki_elf_fpregset_t;
  431. //----------------------------------------------------------------------
  432. // From linux-2.6.9/include/asm-x86_64/ucontext.h
  433. //----------------------------------------------------------------------
  434. struct vki_ucontext {
  435. unsigned long uc_flags;
  436. struct vki_ucontext *uc_link;
  437. vki_stack_t uc_stack;
  438. struct vki_sigcontext uc_mcontext;
  439. vki_sigset_t uc_sigmask; /* mask last for extensibility */
  440. };
  441. //----------------------------------------------------------------------
  442. // From linux-2.6.9/include/asm-x86_64/segment.h
  443. //----------------------------------------------------------------------
  444. #define VKI_GDT_ENTRY_TLS_ENTRIES 3
  445. #define VKI_GDT_ENTRY_TLS_MIN 11
  446. #define VKI_GDT_ENTRY_TLS_MAX 13
  447. //----------------------------------------------------------------------
  448. // From linux-2.6.11.9/include/asm-x86_64/prctl.h
  449. //----------------------------------------------------------------------
  450. #define VKI_ARCH_SET_GS 0x1001
  451. #define VKI_ARCH_SET_FS 0x1002
  452. #define VKI_ARCH_GET_FS 0x1003
  453. #define VKI_ARCH_GET_GS 0x1004
  454. //----------------------------------------------------------------------
  455. // Originally from linux-2.6.9/include/asm-x86_64/ldt.h
  456. //----------------------------------------------------------------------
  457. // Note that the type here is very slightly different to the
  458. // type for x86 (the final 'lm' field is added).
  459. /* The explanation is: the final bit is not present in 32 bit code running
  460. on 64 bits kernel. The kernel has to assume this value is 0 whenever
  461. user_desc arrives from a 32-bit program.
  462. See /usr/include/asm/ldt.h. */
  463. /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as
  464. to confuse and annoy everyone, this is _not_ the same as an
  465. VgLdtEntry and has to be translated into such. The logic for doing
  466. so, in vg_ldt.c, is copied from the kernel sources.]] */
  467. /* Note also that a comment in ldt.h indicates that the below
  468. contains several fields ignored on 64bit, and that modify_ldt
  469. is rather for 32bit. */
  470. struct vki_user_desc {
  471. unsigned int entry_number;
  472. unsigned int base_addr;
  473. unsigned int limit;
  474. unsigned int seg_32bit:1;
  475. unsigned int contents:2;
  476. unsigned int read_exec_only:1;
  477. unsigned int limit_in_pages:1;
  478. unsigned int seg_not_present:1;
  479. unsigned int useable:1;
  480. unsigned int lm:1;
  481. };
  482. // [[Nb: for our convenience within Valgrind, use a more specific name]]
  483. typedef struct vki_user_desc vki_modify_ldt_t;
  484. //----------------------------------------------------------------------
  485. // From linux-2.6.11.2/include/asm-x86_64/ipcbuf.h
  486. //----------------------------------------------------------------------
  487. struct vki_ipc64_perm
  488. {
  489. __vki_kernel_key_t key;
  490. __vki_kernel_uid32_t uid;
  491. __vki_kernel_gid32_t gid;
  492. __vki_kernel_uid32_t cuid;
  493. __vki_kernel_gid32_t cgid;
  494. __vki_kernel_mode_t mode;
  495. unsigned short __pad1;
  496. unsigned short seq;
  497. unsigned short __pad2;
  498. unsigned long __unused1;
  499. unsigned long __unused2;
  500. };
  501. //----------------------------------------------------------------------
  502. // From linux-2.6.11.2/include/asm-x86_64/sembuf.h
  503. //----------------------------------------------------------------------
  504. struct vki_semid64_ds {
  505. struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */
  506. __vki_kernel_time_t sem_otime; /* last semop time */
  507. unsigned long __unused1;
  508. __vki_kernel_time_t sem_ctime; /* last change time */
  509. unsigned long __unused2;
  510. unsigned long sem_nsems; /* no. of semaphores in array */
  511. unsigned long __unused3;
  512. unsigned long __unused4;
  513. };
  514. //----------------------------------------------------------------------
  515. // From linux-2.6.11.2/include/asm-x86_64/msgbuf.h
  516. //----------------------------------------------------------------------
  517. struct vki_msqid64_ds {
  518. struct vki_ipc64_perm msg_perm;
  519. __vki_kernel_time_t msg_stime; /* last msgsnd time */
  520. __vki_kernel_time_t msg_rtime; /* last msgrcv time */
  521. __vki_kernel_time_t msg_ctime; /* last change time */
  522. unsigned long msg_cbytes; /* current number of bytes on queue */
  523. unsigned long msg_qnum; /* number of messages in queue */
  524. unsigned long msg_qbytes; /* max number of bytes on queue */
  525. __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */
  526. __vki_kernel_pid_t msg_lrpid; /* last receive pid */
  527. unsigned long __unused4;
  528. unsigned long __unused5;
  529. };
  530. //----------------------------------------------------------------------
  531. // From linux-2.6.11.2/include/asm-x86_64/shmbuf.h
  532. //----------------------------------------------------------------------
  533. struct vki_shmid64_ds {
  534. struct vki_ipc64_perm shm_perm; /* operation perms */
  535. vki_size_t shm_segsz; /* size of segment (bytes) */
  536. __vki_kernel_time_t shm_atime; /* last attach time */
  537. __vki_kernel_time_t shm_dtime; /* last detach time */
  538. __vki_kernel_time_t shm_ctime; /* last change time */
  539. __vki_kernel_pid_t shm_cpid; /* pid of creator */
  540. __vki_kernel_pid_t shm_lpid; /* pid of last operator */
  541. unsigned long shm_nattch; /* no. of current attaches */
  542. unsigned long __unused4;
  543. unsigned long __unused5;
  544. };
  545. struct vki_shminfo64 {
  546. unsigned long shmmax;
  547. unsigned long shmmin;
  548. unsigned long shmmni;
  549. unsigned long shmseg;
  550. unsigned long shmall;
  551. unsigned long __unused1;
  552. unsigned long __unused2;
  553. unsigned long __unused3;
  554. unsigned long __unused4;
  555. };
  556. //----------------------------------------------------------------------
  557. // From linux-2.6.12.2/include/asm-x86_64/ptrace.h
  558. //----------------------------------------------------------------------
  559. #define VKI_PTRACE_GETREGS 12
  560. #define VKI_PTRACE_SETREGS 13
  561. #define VKI_PTRACE_GETFPREGS 14
  562. #define VKI_PTRACE_SETFPREGS 15
  563. // From /usr/include/asm/ptrace-abit.h
  564. /* only useful for access 32bit programs / kernels */
  565. #define VKI_PTRACE_GET_THREAD_AREA 25
  566. #define VKI_PTRACE_SET_THREAD_AREA 26
  567. //----------------------------------------------------------------------
  568. // From linux-2.6.8.1/include/asm-generic/errno.h
  569. //----------------------------------------------------------------------
  570. #define VKI_ENOSYS 38 /* Function not implemented */
  571. #define VKI_EOVERFLOW 75 /* Value too large for defined data type */
  572. //----------------------------------------------------------------------
  573. // From linux-3.19.0/include/uapi/asm-generic/ioctls.h
  574. //----------------------------------------------------------------------
  575. #define VKI_TIOCGSERIAL 0x541E
  576. #define VKI_TIOCSSERIAL 0x541F
  577. //----------------------------------------------------------------------
  578. // And that's it!
  579. //----------------------------------------------------------------------
  580. #endif // __VKI_AMD64_LINUX_H
  581. /*--------------------------------------------------------------------*/
  582. /*--- end ---*/
  583. /*--------------------------------------------------------------------*/