siginfo.h 11 KB

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