siginfo.h 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
  2. #ifndef _UAPI_ASM_GENERIC_SIGINFO_H
  3. #define _UAPI_ASM_GENERIC_SIGINFO_H
  4. #include <linux/compiler.h>
  5. #include <linux/types.h>
  6. typedef union sigval {
  7. int sival_int;
  8. void __user *sival_ptr;
  9. } sigval_t;
  10. /*
  11. * This is the size (including padding) of the part of the
  12. * struct siginfo that is before the union.
  13. */
  14. #ifndef __ARCH_SI_PREAMBLE_SIZE
  15. #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int))
  16. #endif
  17. #define SI_MAX_SIZE 128
  18. #ifndef SI_PAD_SIZE
  19. #define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int))
  20. #endif
  21. /*
  22. * The default "si_band" type is "long", as specified by POSIX.
  23. * However, some architectures want to override this to "int"
  24. * for historical compatibility reasons, so we allow that.
  25. */
  26. #ifndef __ARCH_SI_BAND_T
  27. #define __ARCH_SI_BAND_T long
  28. #endif
  29. #ifndef __ARCH_SI_CLOCK_T
  30. #define __ARCH_SI_CLOCK_T __kernel_clock_t
  31. #endif
  32. #ifndef __ARCH_SI_ATTRIBUTES
  33. #define __ARCH_SI_ATTRIBUTES
  34. #endif
  35. typedef struct siginfo {
  36. int si_signo;
  37. #ifndef __ARCH_HAS_SWAPPED_SIGINFO
  38. int si_errno;
  39. int si_code;
  40. #else
  41. int si_code;
  42. int si_errno;
  43. #endif
  44. union {
  45. int _pad[SI_PAD_SIZE];
  46. /* kill() */
  47. struct {
  48. __kernel_pid_t _pid; /* sender's pid */
  49. __kernel_uid32_t _uid; /* sender's uid */
  50. } _kill;
  51. /* POSIX.1b timers */
  52. struct {
  53. __kernel_timer_t _tid; /* timer id */
  54. int _overrun; /* overrun count */
  55. sigval_t _sigval; /* same as below */
  56. int _sys_private; /* not to be passed to user */
  57. } _timer;
  58. /* POSIX.1b signals */
  59. struct {
  60. __kernel_pid_t _pid; /* sender's pid */
  61. __kernel_uid32_t _uid; /* sender's uid */
  62. sigval_t _sigval;
  63. } _rt;
  64. /* SIGCHLD */
  65. struct {
  66. __kernel_pid_t _pid; /* which child */
  67. __kernel_uid32_t _uid; /* sender's uid */
  68. int _status; /* exit code */
  69. __ARCH_SI_CLOCK_T _utime;
  70. __ARCH_SI_CLOCK_T _stime;
  71. } _sigchld;
  72. /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
  73. struct {
  74. void __user *_addr; /* faulting insn/memory ref. */
  75. #ifdef __ARCH_SI_TRAPNO
  76. int _trapno; /* TRAP # which caused the signal */
  77. #endif
  78. #ifdef __ia64__
  79. int _imm; /* immediate value for "break" */
  80. unsigned int _flags; /* see ia64 si_flags */
  81. unsigned long _isr; /* isr */
  82. #endif
  83. #define __ADDR_BND_PKEY_PAD (__alignof__(void *) < sizeof(short) ? \
  84. sizeof(short) : __alignof__(void *))
  85. union {
  86. /*
  87. * used when si_code=BUS_MCEERR_AR or
  88. * used when si_code=BUS_MCEERR_AO
  89. */
  90. short _addr_lsb; /* LSB of the reported address */
  91. /* used when si_code=SEGV_BNDERR */
  92. struct {
  93. char _dummy_bnd[__ADDR_BND_PKEY_PAD];
  94. void __user *_lower;
  95. void __user *_upper;
  96. } _addr_bnd;
  97. /* used when si_code=SEGV_PKUERR */
  98. struct {
  99. char _dummy_pkey[__ADDR_BND_PKEY_PAD];
  100. __u32 _pkey;
  101. } _addr_pkey;
  102. };
  103. } _sigfault;
  104. /* SIGPOLL */
  105. struct {
  106. __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
  107. int _fd;
  108. } _sigpoll;
  109. /* SIGSYS */
  110. struct {
  111. void __user *_call_addr; /* calling user insn */
  112. int _syscall; /* triggering system call number */
  113. unsigned int _arch; /* AUDIT_ARCH_* of syscall */
  114. } _sigsys;
  115. } _sifields;
  116. } __ARCH_SI_ATTRIBUTES siginfo_t;
  117. /*
  118. * How these fields are to be accessed.
  119. */
  120. #define si_pid _sifields._kill._pid
  121. #define si_uid _sifields._kill._uid
  122. #define si_tid _sifields._timer._tid
  123. #define si_overrun _sifields._timer._overrun
  124. #define si_sys_private _sifields._timer._sys_private
  125. #define si_status _sifields._sigchld._status
  126. #define si_utime _sifields._sigchld._utime
  127. #define si_stime _sifields._sigchld._stime
  128. #define si_value _sifields._rt._sigval
  129. #define si_int _sifields._rt._sigval.sival_int
  130. #define si_ptr _sifields._rt._sigval.sival_ptr
  131. #define si_addr _sifields._sigfault._addr
  132. #ifdef __ARCH_SI_TRAPNO
  133. #define si_trapno _sifields._sigfault._trapno
  134. #endif
  135. #define si_addr_lsb _sifields._sigfault._addr_lsb
  136. #define si_lower _sifields._sigfault._addr_bnd._lower
  137. #define si_upper _sifields._sigfault._addr_bnd._upper
  138. #define si_pkey _sifields._sigfault._addr_pkey._pkey
  139. #define si_band _sifields._sigpoll._band
  140. #define si_fd _sifields._sigpoll._fd
  141. #define si_call_addr _sifields._sigsys._call_addr
  142. #define si_syscall _sifields._sigsys._syscall
  143. #define si_arch _sifields._sigsys._arch
  144. /*
  145. * si_code values
  146. * Digital reserves positive values for kernel-generated signals.
  147. */
  148. #define SI_USER 0 /* sent by kill, sigsend, raise */
  149. #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */
  150. #define SI_QUEUE -1 /* sent by sigqueue */
  151. #define SI_TIMER -2 /* sent by timer expiration */
  152. #define SI_MESGQ -3 /* sent by real time mesq state change */
  153. #define SI_ASYNCIO -4 /* sent by AIO completion */
  154. #define SI_SIGIO -5 /* sent by queued SIGIO */
  155. #define SI_TKILL -6 /* sent by tkill system call */
  156. #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */
  157. #define SI_ASYNCNL -60 /* sent by glibc async name lookup completion */
  158. #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0)
  159. #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0)
  160. /*
  161. * SIGILL si_codes
  162. */
  163. #define ILL_ILLOPC 1 /* illegal opcode */
  164. #define ILL_ILLOPN 2 /* illegal operand */
  165. #define ILL_ILLADR 3 /* illegal addressing mode */
  166. #define ILL_ILLTRP 4 /* illegal trap */
  167. #define ILL_PRVOPC 5 /* privileged opcode */
  168. #define ILL_PRVREG 6 /* privileged register */
  169. #define ILL_COPROC 7 /* coprocessor error */
  170. #define ILL_BADSTK 8 /* internal stack error */
  171. #define ILL_BADIADDR 9 /* unimplemented instruction address */
  172. #define __ILL_BREAK 10 /* illegal break */
  173. #define __ILL_BNDMOD 11 /* bundle-update (modification) in progress */
  174. #define NSIGILL 11
  175. /*
  176. * SIGFPE si_codes
  177. */
  178. #define FPE_INTDIV 1 /* integer divide by zero */
  179. #define FPE_INTOVF 2 /* integer overflow */
  180. #define FPE_FLTDIV 3 /* floating point divide by zero */
  181. #define FPE_FLTOVF 4 /* floating point overflow */
  182. #define FPE_FLTUND 5 /* floating point underflow */
  183. #define FPE_FLTRES 6 /* floating point inexact result */
  184. #define FPE_FLTINV 7 /* floating point invalid operation */
  185. #define FPE_FLTSUB 8 /* subscript out of range */
  186. #define __FPE_DECOVF 9 /* decimal overflow */
  187. #define __FPE_DECDIV 10 /* decimal division by zero */
  188. #define __FPE_DECERR 11 /* packed decimal error */
  189. #define __FPE_INVASC 12 /* invalid ASCII digit */
  190. #define __FPE_INVDEC 13 /* invalid decimal digit */
  191. #define FPE_FLTUNK 14 /* undiagnosed floating-point exception */
  192. #define FPE_CONDTRAP 15 /* trap on condition */
  193. #define NSIGFPE 15
  194. /*
  195. * SIGSEGV si_codes
  196. */
  197. #define SEGV_MAPERR 1 /* address not mapped to object */
  198. #define SEGV_ACCERR 2 /* invalid permissions for mapped object */
  199. #define SEGV_BNDERR 3 /* failed address bound checks */
  200. #ifdef __ia64__
  201. # define __SEGV_PSTKOVF 4 /* paragraph stack overflow */
  202. #else
  203. # define SEGV_PKUERR 4 /* failed protection key checks */
  204. #endif
  205. #define SEGV_ACCADI 5 /* ADI not enabled for mapped object */
  206. #define SEGV_ADIDERR 6 /* Disrupting MCD error */
  207. #define SEGV_ADIPERR 7 /* Precise MCD exception */
  208. #define NSIGSEGV 7
  209. /*
  210. * SIGBUS si_codes
  211. */
  212. #define BUS_ADRALN 1 /* invalid address alignment */
  213. #define BUS_ADRERR 2 /* non-existent physical address */
  214. #define BUS_OBJERR 3 /* object specific hardware error */
  215. /* hardware memory error consumed on a machine check: action required */
  216. #define BUS_MCEERR_AR 4
  217. /* hardware memory error detected in process but not consumed: action optional*/
  218. #define BUS_MCEERR_AO 5
  219. #define NSIGBUS 5
  220. /*
  221. * SIGTRAP si_codes
  222. */
  223. #define TRAP_BRKPT 1 /* process breakpoint */
  224. #define TRAP_TRACE 2 /* process trace trap */
  225. #define TRAP_BRANCH 3 /* process taken branch trap */
  226. #define TRAP_HWBKPT 4 /* hardware breakpoint/watchpoint */
  227. #define TRAP_UNK 5 /* undiagnosed trap */
  228. #define NSIGTRAP 5
  229. /*
  230. * There is an additional set of SIGTRAP si_codes used by ptrace
  231. * that are of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP)
  232. */
  233. /*
  234. * SIGCHLD si_codes
  235. */
  236. #define CLD_EXITED 1 /* child has exited */
  237. #define CLD_KILLED 2 /* child was killed */
  238. #define CLD_DUMPED 3 /* child terminated abnormally */
  239. #define CLD_TRAPPED 4 /* traced child has trapped */
  240. #define CLD_STOPPED 5 /* child has stopped */
  241. #define CLD_CONTINUED 6 /* stopped child has continued */
  242. #define NSIGCHLD 6
  243. /*
  244. * SIGPOLL (or any other signal without signal specific si_codes) si_codes
  245. */
  246. #define POLL_IN 1 /* data input available */
  247. #define POLL_OUT 2 /* output buffers available */
  248. #define POLL_MSG 3 /* input message available */
  249. #define POLL_ERR 4 /* i/o error */
  250. #define POLL_PRI 5 /* high priority input available */
  251. #define POLL_HUP 6 /* device disconnected */
  252. #define NSIGPOLL 6
  253. /*
  254. * SIGSYS si_codes
  255. */
  256. #define SYS_SECCOMP 1 /* seccomp triggered */
  257. #define NSIGSYS 1
  258. /*
  259. * sigevent definitions
  260. *
  261. * It seems likely that SIGEV_THREAD will have to be handled from
  262. * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
  263. * thread manager then catches and does the appropriate nonsense.
  264. * However, everything is written out here so as to not get lost.
  265. */
  266. #define SIGEV_SIGNAL 0 /* notify via signal */
  267. #define SIGEV_NONE 1 /* other notification: meaningless */
  268. #define SIGEV_THREAD 2 /* deliver via thread creation */
  269. #define SIGEV_THREAD_ID 4 /* deliver to thread */
  270. /*
  271. * This works because the alignment is ok on all current architectures
  272. * but we leave open this being overridden in the future
  273. */
  274. #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
  275. #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t))
  276. #endif
  277. #define SIGEV_MAX_SIZE 64
  278. #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
  279. / sizeof(int))
  280. typedef struct sigevent {
  281. sigval_t sigev_value;
  282. int sigev_signo;
  283. int sigev_notify;
  284. union {
  285. int _pad[SIGEV_PAD_SIZE];
  286. int _tid;
  287. struct {
  288. void (*_function)(sigval_t);
  289. void *_attribute; /* really pthread_attr_t */
  290. } _sigev_thread;
  291. } _sigev_un;
  292. } sigevent_t;
  293. #define sigev_notify_function _sigev_un._sigev_thread._function
  294. #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
  295. #define sigev_notify_thread_id _sigev_un._tid
  296. #endif /* _UAPI_ASM_GENERIC_SIGINFO_H */