siginfo.h 9.7 KB

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