vki-arm64-linux.h 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  1. /*--------------------------------------------------------------------*/
  2. /*--- ARM64/Linux-specific kernel interface. vki-arm64-linux.h ---*/
  3. /*--------------------------------------------------------------------*/
  4. /*
  5. This file is part of Valgrind, a dynamic binary instrumentation
  6. framework.
  7. Copyright (C) 2013-2017 OpenWorks
  8. info@open-works.net
  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_ARM64_LINUX_H
  24. #define __VKI_ARM64_LINUX_H
  25. // ARM64 is little-endian.
  26. #define VKI_LITTLE_ENDIAN 1
  27. //----------------------------------------------------------------------
  28. // From linux-3.9.9/include/uapi/asm-generic/int-ll64.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-3.9.9/arch/arm64/include/asm/page.h
  41. //----------------------------------------------------------------------
  42. /* Looks like arm64 can do both 4k and 64k pages, so we
  43. use the at-startup detection scheme that ppc32/64 do. */
  44. extern UWord VKI_PAGE_SHIFT;
  45. extern UWord VKI_PAGE_SIZE;
  46. #define VKI_MAX_PAGE_SHIFT 16
  47. #define VKI_MAX_PAGE_SIZE (1UL << VKI_MAX_PAGE_SHIFT)
  48. //----------------------------------------------------------------------
  49. // From linux-3.10.5/arch/arm64/include/asm/shmparam.h
  50. //----------------------------------------------------------------------
  51. // Trying to make sense of this .. it seems as if, for doing
  52. // shared memory with 64 bit processes, VKI_PAGE_SIZE is good
  53. // enough. But if sharing with a 32 bit process then we need
  54. // the old-style 16k value (4 * VKI_PAGE_SIZE) to be safe.
  55. // (From reading between the lines of arch/arm64/include/asm/shmparam.h)
  56. #define VKI_SHMLBA (4 * VKI_PAGE_SIZE)
  57. //----------------------------------------------------------------------
  58. // From linux-3.10.5/include/uapi/asm-generic/signal.h
  59. //----------------------------------------------------------------------
  60. #define _VKI_NSIG 64
  61. #define _VKI_NSIG_BPW 64
  62. #define _VKI_NSIG_WORDS (_VKI_NSIG / _VKI_NSIG_BPW)
  63. typedef unsigned long vki_old_sigset_t;
  64. typedef struct {
  65. unsigned long sig[_VKI_NSIG_WORDS];
  66. } vki_sigset_t;
  67. #define VKI_SIGHUP 1
  68. #define VKI_SIGINT 2
  69. #define VKI_SIGQUIT 3
  70. #define VKI_SIGILL 4
  71. #define VKI_SIGTRAP 5
  72. #define VKI_SIGABRT 6
  73. #define VKI_SIGBUS 7
  74. #define VKI_SIGFPE 8
  75. #define VKI_SIGKILL 9
  76. #define VKI_SIGUSR1 10
  77. #define VKI_SIGSEGV 11
  78. #define VKI_SIGUSR2 12
  79. #define VKI_SIGPIPE 13
  80. #define VKI_SIGALRM 14
  81. #define VKI_SIGTERM 15
  82. #define VKI_SIGSTKFLT 16
  83. #define VKI_SIGCHLD 17
  84. #define VKI_SIGCONT 18
  85. #define VKI_SIGSTOP 19
  86. #define VKI_SIGTSTP 20
  87. #define VKI_SIGTTIN 21
  88. #define VKI_SIGTTOU 22
  89. #define VKI_SIGURG 23
  90. #define VKI_SIGXCPU 24
  91. #define VKI_SIGXFSZ 25
  92. #define VKI_SIGVTALRM 26
  93. #define VKI_SIGPROF 27
  94. #define VKI_SIGWINCH 28
  95. #define VKI_SIGIO 29
  96. #define VKI_SIGPWR 30
  97. #define VKI_SIGSYS 31
  98. #define VKI_SIGUNUSED 31
  99. #define VKI_SIGRTMIN 32
  100. #define VKI_SIGRTMAX _VKI_NSIG
  101. #define VKI_SA_NOCLDSTOP 0x00000001
  102. #define VKI_SA_NOCLDWAIT 0x00000002
  103. #define VKI_SA_SIGINFO 0x00000004
  104. #define VKI_SA_ONSTACK 0x08000000
  105. #define VKI_SA_RESTART 0x10000000
  106. #define VKI_SA_NODEFER 0x40000000
  107. #define VKI_SA_RESETHAND 0x80000000
  108. #define VKI_SA_NOMASK VKI_SA_NODEFER
  109. #define VKI_SA_ONESHOT VKI_SA_RESETHAND
  110. // This is obsolete and should not be defined for new archs
  111. #define VKI_SA_RESTORER 0x04000000
  112. #define VKI_SS_ONSTACK 1
  113. #define VKI_SS_DISABLE 2
  114. #define VKI_MINSIGSTKSZ 2048
  115. #define VKI_SIG_BLOCK 0 /* for blocking signals */
  116. #define VKI_SIG_UNBLOCK 1 /* for unblocking signals */
  117. #define VKI_SIG_SETMASK 2 /* for setting the signal mask */
  118. typedef void __vki_signalfn_t(int);
  119. typedef __vki_signalfn_t __user *__vki_sighandler_t;
  120. typedef void __vki_restorefn_t(void);
  121. typedef __vki_restorefn_t __user *__vki_sigrestore_t;
  122. #define VKI_SIG_DFL ((__vki_sighandler_t)0) /* default signal handling */
  123. #define VKI_SIG_IGN ((__vki_sighandler_t)1) /* ignore signal */
  124. struct vki_sigaction_base {
  125. // [[Nb: a 'k' prefix is added to "sa_handler" because
  126. // bits/sigaction.h (which gets dragged in somehow via signal.h)
  127. // #defines it as something else. Since that is done for glibc's
  128. // purposes, which we don't care about here, we use our own name.]]
  129. __vki_sighandler_t ksa_handler;
  130. unsigned long sa_flags;
  131. __vki_sigrestore_t sa_restorer; // I don't think arm64 has this
  132. vki_sigset_t sa_mask; /* mask last for extensibility */
  133. };
  134. /* On Linux we use the same type for passing sigactions to
  135. and from the kernel. Hence: */
  136. typedef struct vki_sigaction_base vki_sigaction_toK_t;
  137. typedef struct vki_sigaction_base vki_sigaction_fromK_t;
  138. typedef struct vki_sigaltstack {
  139. void __user *ss_sp;
  140. int ss_flags;
  141. vki_size_t ss_size;
  142. } vki_stack_t;
  143. //----------------------------------------------------------------------
  144. // From linux-3.10.5/arch/arm64/include/uapi/asm/sigcontext.h
  145. //----------------------------------------------------------------------
  146. struct vki_sigcontext {
  147. __vki_u64 fault_address;
  148. /* AArch64 registers */
  149. __vki_u64 regs[31];
  150. __vki_u64 sp;
  151. __vki_u64 pc;
  152. __vki_u64 pstate;
  153. /* 4K reserved for FP/SIMD state and future expansion */
  154. __vki_u8 __reserved[4096] __attribute__((__aligned__(16)));
  155. };
  156. //----------------------------------------------------------------------
  157. // From linux-3.10.5/uapi/include/asm-generic/mman-common.h
  158. //----------------------------------------------------------------------
  159. #define VKI_PROT_READ 0x1 /* page can be read */
  160. #define VKI_PROT_WRITE 0x2 /* page can be written */
  161. #define VKI_PROT_EXEC 0x4 /* page can be executed */
  162. #define VKI_PROT_NONE 0x0 /* page can not be accessed */
  163. #define VKI_PROT_GROWSDOWN 0x01000000 /* mprotect flag: extend change to start of growsdown vma */
  164. #define VKI_PROT_GROWSUP 0x02000000 /* mprotect flag: extend change to end of growsup vma */
  165. #define VKI_MAP_SHARED 0x01 /* Share changes */
  166. #define VKI_MAP_PRIVATE 0x02 /* Changes are private */
  167. #define VKI_MAP_FIXED 0x10 /* Interpret addr exactly */
  168. #define VKI_MAP_ANONYMOUS 0x20 /* don't use a file */
  169. #define VKI_MAP_NORESERVE 0x4000 /* don't check for reservations */
  170. //----------------------------------------------------------------------
  171. // From linux-3.10.5/uapi/include/asm-generic/fcntl.h
  172. //----------------------------------------------------------------------
  173. #define VKI_O_ACCMODE 03
  174. #define VKI_O_RDONLY 00
  175. #define VKI_O_WRONLY 01
  176. #define VKI_O_RDWR 02
  177. #define VKI_O_CREAT 0100 /* not fcntl */
  178. #define VKI_O_EXCL 0200 /* not fcntl */
  179. #define VKI_O_TRUNC 01000 /* not fcntl */
  180. #define VKI_O_APPEND 02000
  181. #define VKI_O_NONBLOCK 04000
  182. #define VKI_O_LARGEFILE 0100000
  183. #define VKI_AT_FDCWD -100
  184. #define VKI_F_DUPFD 0 /* dup */
  185. #define VKI_F_GETFD 1 /* get close_on_exec */
  186. #define VKI_F_SETFD 2 /* set/clear close_on_exec */
  187. #define VKI_F_GETFL 3 /* get file->f_flags */
  188. #define VKI_F_SETFL 4 /* set file->f_flags */
  189. #define VKI_F_GETLK 5
  190. #define VKI_F_SETLK 6
  191. #define VKI_F_SETLKW 7
  192. #define VKI_F_SETOWN 8 /* for sockets. */
  193. #define VKI_F_GETOWN 9 /* for sockets. */
  194. #define VKI_F_SETSIG 10 /* for sockets. */
  195. #define VKI_F_GETSIG 11 /* for sockets. */
  196. #define VKI_F_SETOWN_EX 15
  197. #define VKI_F_GETOWN_EX 16
  198. #define VKI_F_OFD_GETLK 36
  199. #define VKI_F_OFD_SETLK 37
  200. #define VKI_F_OFD_SETLKW 38
  201. #define VKI_F_OWNER_TID 0
  202. #define VKI_F_OWNER_PID 1
  203. #define VKI_F_OWNER_PGRP 2
  204. struct vki_f_owner_ex {
  205. int type;
  206. __vki_kernel_pid_t pid;
  207. };
  208. #define VKI_FD_CLOEXEC 1 /* actually anything with low bit set goes */
  209. #define VKI_F_LINUX_SPECIFIC_BASE 1024
  210. //----------------------------------------------------------------------
  211. // From linux-3.10.5/include/uapi/asm-generic/resource.h
  212. //----------------------------------------------------------------------
  213. #define VKI_RLIMIT_DATA 2 /* max data size */
  214. #define VKI_RLIMIT_STACK 3 /* max stack size */
  215. #define VKI_RLIMIT_CORE 4 /* max core file size */
  216. #define VKI_RLIMIT_NOFILE 7 /* max number of open files */
  217. //----------------------------------------------------------------------
  218. // From linux-3.10.5/include/uapi/asm-generic/socket.h
  219. //----------------------------------------------------------------------
  220. #define VKI_SOL_SOCKET 1
  221. #define VKI_SO_TYPE 3
  222. #define VKI_SO_ATTACH_FILTER 26
  223. //----------------------------------------------------------------------
  224. // From linux-3.10.5/include/uapi/asm-generic/sockios.h
  225. //----------------------------------------------------------------------
  226. #define VKI_SIOCSPGRP 0x8902
  227. #define VKI_SIOCGPGRP 0x8904
  228. #define VKI_SIOCATMARK 0x8905
  229. #define VKI_SIOCGSTAMP 0x8906 /* Get stamp (timeval) */
  230. #define VKI_SIOCGSTAMPNS 0x8907 /* Get stamp (timespec) */
  231. //----------------------------------------------------------------------
  232. // From linux-3.10.5/include/uapi/asm-generic/stat.h
  233. //----------------------------------------------------------------------
  234. struct vki_stat {
  235. unsigned long st_dev;
  236. unsigned long st_ino;
  237. unsigned int st_mode;
  238. unsigned int st_nlink;
  239. unsigned int st_uid;
  240. unsigned int st_gid;
  241. unsigned long st_rdev;
  242. unsigned long __pad1;
  243. long st_size;
  244. int st_blksize;
  245. int __pad2;
  246. long st_blocks;
  247. long st_atime;
  248. unsigned long st_atime_nsec;
  249. long st_mtime;
  250. unsigned long st_mtime_nsec;
  251. long st_ctime;
  252. unsigned long st_ctime_nsec;
  253. unsigned int __unused4;
  254. unsigned int __unused5;
  255. };
  256. //----------------------------------------------------------------------
  257. // From linux-3.10.5/include/uapi/asm-generic/statfs.h
  258. //----------------------------------------------------------------------
  259. struct vki_statfs {
  260. long f_type;
  261. long f_bsize;
  262. long f_blocks;
  263. long f_bfree;
  264. long f_bavail;
  265. long f_files;
  266. long f_ffree;
  267. __vki_kernel_fsid_t f_fsid;
  268. long f_namelen;
  269. long f_frsize;
  270. long f_flags;
  271. long f_spare[4];
  272. };
  273. //----------------------------------------------------------------------
  274. // From linux-3.10.5/include/uapi/asm-generic/termios.h
  275. //----------------------------------------------------------------------
  276. struct vki_winsize {
  277. unsigned short ws_row;
  278. unsigned short ws_col;
  279. unsigned short ws_xpixel;
  280. unsigned short ws_ypixel;
  281. };
  282. #define VKI_NCC 8
  283. struct vki_termio {
  284. unsigned short c_iflag; /* input mode flags */
  285. unsigned short c_oflag; /* output mode flags */
  286. unsigned short c_cflag; /* control mode flags */
  287. unsigned short c_lflag; /* local mode flags */
  288. unsigned char c_line; /* line discipline */
  289. unsigned char c_cc[VKI_NCC]; /* control characters */
  290. };
  291. //----------------------------------------------------------------------
  292. // From linux-3.10.5/include/uapi/asm-generic/termbits.h
  293. //----------------------------------------------------------------------
  294. typedef unsigned char vki_cc_t;
  295. typedef unsigned int vki_tcflag_t;
  296. #define VKI_NCCS 19
  297. struct vki_termios {
  298. vki_tcflag_t c_iflag; /* input mode flags */
  299. vki_tcflag_t c_oflag; /* output mode flags */
  300. vki_tcflag_t c_cflag; /* control mode flags */
  301. vki_tcflag_t c_lflag; /* local mode flags */
  302. vki_cc_t c_line; /* line discipline */
  303. vki_cc_t c_cc[VKI_NCCS]; /* control characters */
  304. };
  305. //----------------------------------------------------------------------
  306. // From linux-3.9.9/include/uapi/asm-generic/ioctl.h
  307. //----------------------------------------------------------------------
  308. #define _VKI_IOC_NRBITS 8
  309. #define _VKI_IOC_TYPEBITS 8
  310. #define _VKI_IOC_SIZEBITS 14
  311. #define _VKI_IOC_DIRBITS 2
  312. #define _VKI_IOC_SIZEMASK ((1 << _VKI_IOC_SIZEBITS)-1)
  313. #define _VKI_IOC_DIRMASK ((1 << _VKI_IOC_DIRBITS)-1)
  314. #define _VKI_IOC_NRSHIFT 0
  315. #define _VKI_IOC_TYPESHIFT (_VKI_IOC_NRSHIFT+_VKI_IOC_NRBITS)
  316. #define _VKI_IOC_SIZESHIFT (_VKI_IOC_TYPESHIFT+_VKI_IOC_TYPEBITS)
  317. #define _VKI_IOC_DIRSHIFT (_VKI_IOC_SIZESHIFT+_VKI_IOC_SIZEBITS)
  318. #define _VKI_IOC_NONE 0U
  319. #define _VKI_IOC_WRITE 1U
  320. #define _VKI_IOC_READ 2U
  321. #define _VKI_IOC(dir,type,nr,size) \
  322. (((dir) << _VKI_IOC_DIRSHIFT) | \
  323. ((type) << _VKI_IOC_TYPESHIFT) | \
  324. ((nr) << _VKI_IOC_NRSHIFT) | \
  325. ((size) << _VKI_IOC_SIZESHIFT))
  326. #define _VKI_IO(type,nr) _VKI_IOC(_VKI_IOC_NONE,(type),(nr),0)
  327. #define _VKI_IOR(type,nr,size) _VKI_IOC(_VKI_IOC_READ,(type),(nr),sizeof(size))
  328. #define _VKI_IOW(type,nr,size) _VKI_IOC(_VKI_IOC_WRITE,(type),(nr),sizeof(size))
  329. #define _VKI_IOWR(type,nr,size) _VKI_IOC(_VKI_IOC_READ|_VKI_IOC_WRITE,(type),(nr),sizeof(size))
  330. #define _VKI_IOC_DIR(nr) (((nr) >> _VKI_IOC_DIRSHIFT) & _VKI_IOC_DIRMASK)
  331. #define _VKI_IOC_SIZE(nr) (((nr) >> _VKI_IOC_SIZESHIFT) & _VKI_IOC_SIZEMASK)
  332. //----------------------------------------------------------------------
  333. // From linux-3.10.5/include/uapi/asm-generic/ioctls.h
  334. //----------------------------------------------------------------------
  335. #define VKI_TCGETS 0x5401
  336. #define VKI_TCSETS 0x5402
  337. #define VKI_TCSETSW 0x5403
  338. #define VKI_TCSETSF 0x5404
  339. #define VKI_TCGETA 0x5405
  340. #define VKI_TCSETA 0x5406
  341. #define VKI_TCSETAW 0x5407
  342. #define VKI_TCSETAF 0x5408
  343. #define VKI_TCSBRK 0x5409
  344. #define VKI_TCXONC 0x540A
  345. #define VKI_TCFLSH 0x540B
  346. #define VKI_TIOCSCTTY 0x540E
  347. #define VKI_TIOCGPGRP 0x540F
  348. #define VKI_TIOCSPGRP 0x5410
  349. #define VKI_TIOCOUTQ 0x5411
  350. #define VKI_TIOCGWINSZ 0x5413
  351. #define VKI_TIOCSWINSZ 0x5414
  352. #define VKI_TIOCMGET 0x5415
  353. #define VKI_TIOCMBIS 0x5416
  354. #define VKI_TIOCMBIC 0x5417
  355. #define VKI_TIOCMSET 0x5418
  356. #define VKI_FIONREAD 0x541B
  357. #define VKI_TIOCLINUX 0x541C
  358. #define VKI_FIONBIO 0x5421
  359. #define VKI_TIOCNOTTY 0x5422
  360. #define VKI_TCSBRKP 0x5425
  361. #define VKI_TIOCGPTN _VKI_IOR('T',0x30, unsigned int)
  362. #define VKI_TIOCSPTLCK _VKI_IOW('T',0x31, int)
  363. #define VKI_FIONCLEX 0x5450
  364. #define VKI_FIOCLEX 0x5451
  365. #define VKI_FIOASYNC 0x5452
  366. #define VKI_TIOCSERGETLSR 0x5459
  367. #define VKI_TIOCGICOUNT 0x545D
  368. //----------------------------------------------------------------------
  369. // From linux-3.9.9/include/uapi/asm-generic/poll.h
  370. //----------------------------------------------------------------------
  371. #define VKI_POLLIN 0x0001
  372. struct vki_pollfd {
  373. int fd;
  374. short events;
  375. short revents;
  376. };
  377. //----------------------------------------------------------------------
  378. // From linux-3.10.5/arch/arm64/include/uapi/asm/ptrace.h
  379. //----------------------------------------------------------------------
  380. //ZZ struct vki_user_i387_struct {
  381. //ZZ unsigned short cwd;
  382. //ZZ unsigned short swd;
  383. //ZZ unsigned short twd; /* Note this is not the same as the 32bit/x87/FSAVE twd */
  384. //ZZ unsigned short fop;
  385. //ZZ __vki_u64 rip;
  386. //ZZ __vki_u64 rdp;
  387. //ZZ __vki_u32 mxcsr;
  388. //ZZ __vki_u32 mxcsr_mask;
  389. //ZZ __vki_u32 st_space[32]; /* 8*16 bytes for each FP-reg = 128 bytes */
  390. //ZZ __vki_u32 xmm_space[64]; /* 16*16 bytes for each XMM-reg = 256 bytes */
  391. //ZZ __vki_u32 padding[24];
  392. //ZZ };
  393. //ZZ
  394. //ZZ struct vki_user_regs_struct {
  395. //ZZ unsigned long r15,r14,r13,r12,rbp,rbx,r11,r10;
  396. //ZZ unsigned long r9,r8,rax,rcx,rdx,rsi,rdi,orig_rax;
  397. //ZZ unsigned long rip,cs,eflags;
  398. //ZZ unsigned long rsp,ss;
  399. //ZZ unsigned long fs_base, gs_base;
  400. //ZZ unsigned long ds,es,fs,gs;
  401. //ZZ };
  402. struct vki_user_pt_regs {
  403. __vki_u64 regs[31];
  404. __vki_u64 sp;
  405. __vki_u64 pc;
  406. __vki_u64 pstate;
  407. };
  408. /* I think that the new name in the kernel for these is "user_pt_regs"
  409. and the old name is "user_regs_struct". Unfortunately can't clone
  410. a 'struct' type using 'typedef' and still have a 'struct' type, so
  411. use a blunter instrument instead. */
  412. #define vki_user_regs_struct vki_user_pt_regs
  413. struct vki_user_fpsimd_state {
  414. __uint128_t vregs[32];
  415. __vki_u32 fpsr;
  416. __vki_u32 fpcr;
  417. };
  418. //----------------------------------------------------------------------
  419. // From linux-3.9.9/arch/arm64/include/asm/elf.h
  420. //----------------------------------------------------------------------
  421. typedef unsigned long vki_elf_greg_t;
  422. #define VKI_ELF_NGREG (sizeof (struct vki_user_pt_regs) / sizeof(vki_elf_greg_t))
  423. typedef vki_elf_greg_t vki_elf_gregset_t[VKI_ELF_NGREG];
  424. typedef struct vki_user_fpsimd_state vki_elf_fpregset_t;
  425. //----------------------------------------------------------------------
  426. // From linux-3.10.5/arch/arm64/include/asm/ucontext.h
  427. //----------------------------------------------------------------------
  428. struct vki_ucontext {
  429. unsigned long uc_flags;
  430. struct vki_ucontext *uc_link;
  431. vki_stack_t uc_stack;
  432. vki_sigset_t uc_sigmask;
  433. /* glibc uses a 1024-bit sigset_t */
  434. __vki_u8 __unused0[1024 / 8 - sizeof(vki_sigset_t)];
  435. /* last for future expansion */
  436. struct vki_sigcontext uc_mcontext;
  437. };
  438. //ZZ //----------------------------------------------------------------------
  439. //ZZ // From linux-2.6.9/include/asm-x86_64/segment.h
  440. //ZZ //----------------------------------------------------------------------
  441. //ZZ
  442. //ZZ #define VKI_GDT_ENTRY_TLS_ENTRIES 3
  443. //ZZ
  444. //ZZ #define VKI_GDT_ENTRY_TLS_MIN 11
  445. //ZZ #define VKI_GDT_ENTRY_TLS_MAX 13
  446. //ZZ
  447. //ZZ //----------------------------------------------------------------------
  448. //ZZ // From linux-2.6.11.9/include/asm-x86_64/prctl.h
  449. //ZZ //----------------------------------------------------------------------
  450. //ZZ
  451. //ZZ #define VKI_ARCH_SET_GS 0x1001
  452. //ZZ #define VKI_ARCH_SET_FS 0x1002
  453. //ZZ #define VKI_ARCH_GET_FS 0x1003
  454. //ZZ #define VKI_ARCH_GET_GS 0x1004
  455. //ZZ
  456. //ZZ //----------------------------------------------------------------------
  457. //ZZ // From linux-2.6.9/include/asm-x86_64/ldt.h
  458. //ZZ //----------------------------------------------------------------------
  459. //ZZ
  460. //ZZ // I think this LDT stuff will have to be reinstated for amd64, but I'm not
  461. //ZZ // certain. (Nb: The sys_arch_prctl seems to have replaced
  462. //ZZ // [gs]et_thread_area syscalls.)
  463. //ZZ //
  464. //ZZ // Note that the type here is very slightly different to the
  465. //ZZ // type for x86 (the final 'lm' field is added); I'm not sure about the
  466. //ZZ // significance of that... --njn
  467. //ZZ
  468. //ZZ /* [[Nb: This is the structure passed to the modify_ldt syscall. Just so as
  469. //ZZ to confuse and annoy everyone, this is _not_ the same as an
  470. //ZZ VgLdtEntry and has to be translated into such. The logic for doing
  471. //ZZ so, in vg_ldt.c, is copied from the kernel sources.]] */
  472. //ZZ /* Note also that a comment in ldt.h indicates that the below
  473. //ZZ contains several fields ignored on 64bit, and that modify_ldt
  474. //ZZ is rather for 32bit. */
  475. //ZZ struct vki_user_desc {
  476. //ZZ unsigned int entry_number;
  477. //ZZ unsigned long base_addr;
  478. //ZZ unsigned int limit;
  479. //ZZ unsigned int seg_32bit:1;
  480. //ZZ unsigned int contents:2;
  481. //ZZ unsigned int read_exec_only:1;
  482. //ZZ unsigned int limit_in_pages:1;
  483. //ZZ unsigned int seg_not_present:1;
  484. //ZZ unsigned int useable:1;
  485. //ZZ unsigned int lm:1;
  486. //ZZ };
  487. //ZZ
  488. //ZZ // [[Nb: for our convenience within Valgrind, use a more specific name]]
  489. typedef char vki_modify_ldt_t;
  490. //----------------------------------------------------------------------
  491. // From linux-3.10.5/include/asm-generic/ipcbuf.h
  492. //----------------------------------------------------------------------
  493. struct vki_ipc64_perm
  494. {
  495. __vki_kernel_key_t key;
  496. __vki_kernel_uid32_t uid;
  497. __vki_kernel_gid32_t gid;
  498. __vki_kernel_uid32_t cuid;
  499. __vki_kernel_gid32_t cgid;
  500. __vki_kernel_mode_t mode;
  501. unsigned char __pad1[4 - sizeof(__vki_kernel_mode_t)];
  502. unsigned short seq;
  503. unsigned short __pad2;
  504. unsigned long __unused1;
  505. unsigned long __unused2;
  506. };
  507. //----------------------------------------------------------------------
  508. // From linux-3.10.5/include/uapi/asm-generic/sembuf.h
  509. //----------------------------------------------------------------------
  510. struct vki_semid64_ds {
  511. struct vki_ipc64_perm sem_perm; /* permissions .. see ipc.h */
  512. __vki_kernel_time_t sem_otime; /* last semop time */
  513. __vki_kernel_time_t sem_ctime; /* last change time */
  514. unsigned long sem_nsems; /* no. of semaphores in array */
  515. unsigned long __unused3;
  516. unsigned long __unused4;
  517. };
  518. //----------------------------------------------------------------------
  519. // From linux-3.10.5/include/uapi/asm-generic/msgbuf.h
  520. //----------------------------------------------------------------------
  521. struct vki_msqid64_ds {
  522. struct vki_ipc64_perm msg_perm;
  523. __vki_kernel_time_t msg_stime; /* last msgsnd time */
  524. __vki_kernel_time_t msg_rtime; /* last msgrcv time */
  525. __vki_kernel_time_t msg_ctime; /* last change time */
  526. unsigned long msg_cbytes; /* current number of bytes on queue */
  527. unsigned long msg_qnum; /* number of messages in queue */
  528. unsigned long msg_qbytes; /* max number of bytes on queue */
  529. __vki_kernel_pid_t msg_lspid; /* pid of last msgsnd */
  530. __vki_kernel_pid_t msg_lrpid; /* last receive pid */
  531. unsigned long __unused4;
  532. unsigned long __unused5;
  533. };
  534. //----------------------------------------------------------------------
  535. // From linux-3.10.5/include/uapi/asm-generic/shmbuf.h
  536. //----------------------------------------------------------------------
  537. struct vki_shmid64_ds {
  538. struct vki_ipc64_perm shm_perm; /* operation perms */
  539. vki_size_t shm_segsz; /* size of segment (bytes) */
  540. __vki_kernel_time_t shm_atime; /* last attach time */
  541. __vki_kernel_time_t shm_dtime; /* last detach time */
  542. __vki_kernel_time_t shm_ctime; /* last change time */
  543. __vki_kernel_pid_t shm_cpid; /* pid of creator */
  544. __vki_kernel_pid_t shm_lpid; /* pid of last operator */
  545. unsigned long shm_nattch; /* no. of current attaches */
  546. unsigned long __unused4;
  547. unsigned long __unused5;
  548. };
  549. struct vki_shminfo64 {
  550. unsigned long shmmax;
  551. unsigned long shmmin;
  552. unsigned long shmmni;
  553. unsigned long shmseg;
  554. unsigned long shmall;
  555. unsigned long __unused1;
  556. unsigned long __unused2;
  557. unsigned long __unused3;
  558. unsigned long __unused4;
  559. };
  560. //----------------------------------------------------------------------
  561. // From linux-3.9.9/arch/arm64/include/asm/ptrace.h
  562. //----------------------------------------------------------------------
  563. #define VKI_PTRACE_GETREGS 12
  564. #define VKI_PTRACE_SETREGS 13
  565. //#define VKI_PTRACE_GETFPREGS 14
  566. //#define VKI_PTRACE_SETFPREGS 15
  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. // From linux-4.17/include/uapi/asm-generic/ioctls.h
  579. //----------------------------------------------------------------------
  580. #define VKI_HWCAP_FP (1 << 0)
  581. #define VKI_HWCAP_ASIMD (1 << 1)
  582. #define VKI_HWCAP_EVTSTRM (1 << 2)
  583. #define VKI_HWCAP_AES (1 << 3)
  584. #define VKI_HWCAP_PMULL (1 << 4)
  585. #define VKI_HWCAP_SHA1 (1 << 5)
  586. #define VKI_HWCAP_SHA2 (1 << 6)
  587. #define VKI_HWCAP_CRC32 (1 << 7)
  588. #define VKI_HWCAP_ATOMICS (1 << 8)
  589. #define VKI_HWCAP_FPHP (1 << 9)
  590. #define VKI_HWCAP_ASIMDHP (1 << 10)
  591. #define VKI_HWCAP_CPUID (1 << 11)
  592. #define VKI_HWCAP_ASIMDRDM (1 << 12)
  593. #define VKI_HWCAP_JSCVT (1 << 13)
  594. #define VKI_HWCAP_FCMA (1 << 14)
  595. #define VKI_HWCAP_LRCPC (1 << 15)
  596. #define VKI_HWCAP_DCPOP (1 << 16)
  597. #define VKI_HWCAP_SHA3 (1 << 17)
  598. #define VKI_HWCAP_SM3 (1 << 18)
  599. #define VKI_HWCAP_SM4 (1 << 19)
  600. #define VKI_HWCAP_ASIMDDP (1 << 20)
  601. #define VKI_HWCAP_SHA512 (1 << 21)
  602. #define VKI_HWCAP_SVE (1 << 22)
  603. #define VKI_HWCAP_ASIMDFHM (1 << 23)
  604. #define VKI_HWCAP_DIT (1 << 24)
  605. #define VKI_HWCAP_USCAT (1 << 25)
  606. #define VKI_HWCAP_ILRCPC (1 << 26)
  607. #define VKI_HWCAP_FLAGM (1 << 27)
  608. //----------------------------------------------------------------------
  609. // And that's it!
  610. //----------------------------------------------------------------------
  611. #endif // __VKI_ARM64_LINUX_H
  612. /*--------------------------------------------------------------------*/
  613. /*--- end ---*/
  614. /*--------------------------------------------------------------------*/