Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #ifndef _ASM_GENERIC_SIGINFO_H |
| 2 | #define _ASM_GENERIC_SIGINFO_H |
| 3 | |
| 4 | #include <linux/compiler.h> |
| 5 | #include <linux/types.h> |
| 6 | |
| 7 | typedef union sigval { |
| 8 | int sival_int; |
| 9 | void __user *sival_ptr; |
| 10 | } sigval_t; |
| 11 | |
| 12 | /* |
| 13 | * This is the size (including padding) of the part of the |
| 14 | * struct siginfo that is before the union. |
| 15 | */ |
| 16 | #ifndef __ARCH_SI_PREAMBLE_SIZE |
| 17 | #define __ARCH_SI_PREAMBLE_SIZE (3 * sizeof(int)) |
| 18 | #endif |
| 19 | |
| 20 | #define SI_MAX_SIZE 128 |
| 21 | #ifndef SI_PAD_SIZE |
| 22 | #define SI_PAD_SIZE ((SI_MAX_SIZE - __ARCH_SI_PREAMBLE_SIZE) / sizeof(int)) |
| 23 | #endif |
| 24 | |
| 25 | #ifndef __ARCH_SI_UID_T |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 26 | #define __ARCH_SI_UID_T __kernel_uid32_t |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | #endif |
| 28 | |
| 29 | /* |
| 30 | * The default "si_band" type is "long", as specified by POSIX. |
| 31 | * However, some architectures want to override this to "int" |
| 32 | * for historical compatibility reasons, so we allow that. |
| 33 | */ |
| 34 | #ifndef __ARCH_SI_BAND_T |
| 35 | #define __ARCH_SI_BAND_T long |
| 36 | #endif |
| 37 | |
| 38 | #ifndef HAVE_ARCH_SIGINFO_T |
| 39 | |
| 40 | typedef struct siginfo { |
| 41 | int si_signo; |
| 42 | int si_errno; |
| 43 | int si_code; |
| 44 | |
| 45 | union { |
| 46 | int _pad[SI_PAD_SIZE]; |
| 47 | |
| 48 | /* kill() */ |
| 49 | struct { |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 50 | __kernel_pid_t _pid; /* sender's pid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | __ARCH_SI_UID_T _uid; /* sender's uid */ |
| 52 | } _kill; |
| 53 | |
| 54 | /* POSIX.1b timers */ |
| 55 | struct { |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 56 | __kernel_timer_t _tid; /* timer id */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | int _overrun; /* overrun count */ |
| 58 | char _pad[sizeof( __ARCH_SI_UID_T) - sizeof(int)]; |
| 59 | sigval_t _sigval; /* same as below */ |
| 60 | int _sys_private; /* not to be passed to user */ |
| 61 | } _timer; |
| 62 | |
| 63 | /* POSIX.1b signals */ |
| 64 | struct { |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 65 | __kernel_pid_t _pid; /* sender's pid */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | __ARCH_SI_UID_T _uid; /* sender's uid */ |
| 67 | sigval_t _sigval; |
| 68 | } _rt; |
| 69 | |
| 70 | /* SIGCHLD */ |
| 71 | struct { |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 72 | __kernel_pid_t _pid; /* which child */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 73 | __ARCH_SI_UID_T _uid; /* sender's uid */ |
| 74 | int _status; /* exit code */ |
Arnd Bergmann | 85efde6 | 2009-02-26 00:51:39 +0100 | [diff] [blame] | 75 | __kernel_clock_t _utime; |
| 76 | __kernel_clock_t _stime; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | } _sigchld; |
| 78 | |
| 79 | /* SIGILL, SIGFPE, SIGSEGV, SIGBUS */ |
| 80 | struct { |
| 81 | void __user *_addr; /* faulting insn/memory ref. */ |
| 82 | #ifdef __ARCH_SI_TRAPNO |
| 83 | int _trapno; /* TRAP # which caused the signal */ |
| 84 | #endif |
Andi Kleen | ad5fa91 | 2009-09-16 11:50:06 +0200 | [diff] [blame] | 85 | short _addr_lsb; /* LSB of the reported address */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | } _sigfault; |
| 87 | |
| 88 | /* SIGPOLL */ |
| 89 | struct { |
| 90 | __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */ |
| 91 | int _fd; |
| 92 | } _sigpoll; |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 93 | |
| 94 | /* SIGSYS */ |
| 95 | struct { |
Will Drewry | bb6ea43 | 2012-04-12 16:48:01 -0500 | [diff] [blame^] | 96 | void __user *_call_addr; /* calling user insn */ |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 97 | int _syscall; /* triggering system call number */ |
| 98 | unsigned int _arch; /* AUDIT_ARCH_* of syscall */ |
| 99 | } _sigsys; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | } _sifields; |
| 101 | } siginfo_t; |
| 102 | |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 103 | /* If the arch shares siginfo, then it has SIGSYS. */ |
| 104 | #define __ARCH_SIGSYS |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 105 | #endif |
| 106 | |
| 107 | /* |
| 108 | * How these fields are to be accessed. |
| 109 | */ |
| 110 | #define si_pid _sifields._kill._pid |
| 111 | #define si_uid _sifields._kill._uid |
| 112 | #define si_tid _sifields._timer._tid |
| 113 | #define si_overrun _sifields._timer._overrun |
| 114 | #define si_sys_private _sifields._timer._sys_private |
| 115 | #define si_status _sifields._sigchld._status |
| 116 | #define si_utime _sifields._sigchld._utime |
| 117 | #define si_stime _sifields._sigchld._stime |
| 118 | #define si_value _sifields._rt._sigval |
| 119 | #define si_int _sifields._rt._sigval.sival_int |
| 120 | #define si_ptr _sifields._rt._sigval.sival_ptr |
| 121 | #define si_addr _sifields._sigfault._addr |
| 122 | #ifdef __ARCH_SI_TRAPNO |
| 123 | #define si_trapno _sifields._sigfault._trapno |
| 124 | #endif |
Andi Kleen | ad5fa91 | 2009-09-16 11:50:06 +0200 | [diff] [blame] | 125 | #define si_addr_lsb _sifields._sigfault._addr_lsb |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | #define si_band _sifields._sigpoll._band |
| 127 | #define si_fd _sifields._sigpoll._fd |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 128 | #ifdef __ARCH_SIGSYS |
| 129 | #define si_call_addr _sifields._sigsys._call_addr |
| 130 | #define si_syscall _sifields._sigsys._syscall |
| 131 | #define si_arch _sifields._sigsys._arch |
| 132 | #endif |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | |
| 134 | #ifdef __KERNEL__ |
| 135 | #define __SI_MASK 0xffff0000u |
| 136 | #define __SI_KILL (0 << 16) |
| 137 | #define __SI_TIMER (1 << 16) |
| 138 | #define __SI_POLL (2 << 16) |
| 139 | #define __SI_FAULT (3 << 16) |
| 140 | #define __SI_CHLD (4 << 16) |
| 141 | #define __SI_RT (5 << 16) |
| 142 | #define __SI_MESGQ (6 << 16) |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 143 | #define __SI_SYS (7 << 16) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | #define __SI_CODE(T,N) ((T) | ((N) & 0xffff)) |
| 145 | #else |
| 146 | #define __SI_KILL 0 |
| 147 | #define __SI_TIMER 0 |
| 148 | #define __SI_POLL 0 |
| 149 | #define __SI_FAULT 0 |
| 150 | #define __SI_CHLD 0 |
| 151 | #define __SI_RT 0 |
| 152 | #define __SI_MESGQ 0 |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 153 | #define __SI_SYS 0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | #define __SI_CODE(T,N) (N) |
| 155 | #endif |
| 156 | |
| 157 | /* |
| 158 | * si_code values |
| 159 | * Digital reserves positive values for kernel-generated signals. |
| 160 | */ |
| 161 | #define SI_USER 0 /* sent by kill, sigsend, raise */ |
| 162 | #define SI_KERNEL 0x80 /* sent by the kernel from somewhere */ |
| 163 | #define SI_QUEUE -1 /* sent by sigqueue */ |
| 164 | #define SI_TIMER __SI_CODE(__SI_TIMER,-2) /* sent by timer expiration */ |
| 165 | #define SI_MESGQ __SI_CODE(__SI_MESGQ,-3) /* sent by real time mesq state change */ |
| 166 | #define SI_ASYNCIO -4 /* sent by AIO completion */ |
| 167 | #define SI_SIGIO -5 /* sent by queued SIGIO */ |
| 168 | #define SI_TKILL -6 /* sent by tkill system call */ |
| 169 | #define SI_DETHREAD -7 /* sent by execve() killing subsidiary threads */ |
| 170 | |
| 171 | #define SI_FROMUSER(siptr) ((siptr)->si_code <= 0) |
| 172 | #define SI_FROMKERNEL(siptr) ((siptr)->si_code > 0) |
| 173 | |
| 174 | /* |
| 175 | * SIGILL si_codes |
| 176 | */ |
| 177 | #define ILL_ILLOPC (__SI_FAULT|1) /* illegal opcode */ |
| 178 | #define ILL_ILLOPN (__SI_FAULT|2) /* illegal operand */ |
| 179 | #define ILL_ILLADR (__SI_FAULT|3) /* illegal addressing mode */ |
| 180 | #define ILL_ILLTRP (__SI_FAULT|4) /* illegal trap */ |
| 181 | #define ILL_PRVOPC (__SI_FAULT|5) /* privileged opcode */ |
| 182 | #define ILL_PRVREG (__SI_FAULT|6) /* privileged register */ |
| 183 | #define ILL_COPROC (__SI_FAULT|7) /* coprocessor error */ |
| 184 | #define ILL_BADSTK (__SI_FAULT|8) /* internal stack error */ |
| 185 | #define NSIGILL 8 |
| 186 | |
| 187 | /* |
| 188 | * SIGFPE si_codes |
| 189 | */ |
| 190 | #define FPE_INTDIV (__SI_FAULT|1) /* integer divide by zero */ |
| 191 | #define FPE_INTOVF (__SI_FAULT|2) /* integer overflow */ |
| 192 | #define FPE_FLTDIV (__SI_FAULT|3) /* floating point divide by zero */ |
| 193 | #define FPE_FLTOVF (__SI_FAULT|4) /* floating point overflow */ |
| 194 | #define FPE_FLTUND (__SI_FAULT|5) /* floating point underflow */ |
| 195 | #define FPE_FLTRES (__SI_FAULT|6) /* floating point inexact result */ |
| 196 | #define FPE_FLTINV (__SI_FAULT|7) /* floating point invalid operation */ |
| 197 | #define FPE_FLTSUB (__SI_FAULT|8) /* subscript out of range */ |
| 198 | #define NSIGFPE 8 |
| 199 | |
| 200 | /* |
| 201 | * SIGSEGV si_codes |
| 202 | */ |
| 203 | #define SEGV_MAPERR (__SI_FAULT|1) /* address not mapped to object */ |
| 204 | #define SEGV_ACCERR (__SI_FAULT|2) /* invalid permissions for mapped object */ |
| 205 | #define NSIGSEGV 2 |
| 206 | |
| 207 | /* |
| 208 | * SIGBUS si_codes |
| 209 | */ |
| 210 | #define BUS_ADRALN (__SI_FAULT|1) /* invalid address alignment */ |
Lucas De Marchi | 25985ed | 2011-03-30 22:57:33 -0300 | [diff] [blame] | 211 | #define BUS_ADRERR (__SI_FAULT|2) /* non-existent physical address */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | #define BUS_OBJERR (__SI_FAULT|3) /* object specific hardware error */ |
Andi Kleen | ad5fa91 | 2009-09-16 11:50:06 +0200 | [diff] [blame] | 213 | /* hardware memory error consumed on a machine check: action required */ |
| 214 | #define BUS_MCEERR_AR (__SI_FAULT|4) |
| 215 | /* hardware memory error detected in process but not consumed: action optional*/ |
| 216 | #define BUS_MCEERR_AO (__SI_FAULT|5) |
| 217 | #define NSIGBUS 5 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | |
| 219 | /* |
| 220 | * SIGTRAP si_codes |
| 221 | */ |
| 222 | #define TRAP_BRKPT (__SI_FAULT|1) /* process breakpoint */ |
| 223 | #define TRAP_TRACE (__SI_FAULT|2) /* process trace trap */ |
Srinivasa Ds | da654b7 | 2008-09-23 15:23:52 +0530 | [diff] [blame] | 224 | #define TRAP_BRANCH (__SI_FAULT|3) /* process taken branch trap */ |
| 225 | #define TRAP_HWBKPT (__SI_FAULT|4) /* hardware breakpoint/watchpoint */ |
Andi Kleen | 0769c29 | 2009-04-13 14:39:56 -0700 | [diff] [blame] | 226 | #define NSIGTRAP 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 227 | |
| 228 | /* |
| 229 | * SIGCHLD si_codes |
| 230 | */ |
| 231 | #define CLD_EXITED (__SI_CHLD|1) /* child has exited */ |
| 232 | #define CLD_KILLED (__SI_CHLD|2) /* child was killed */ |
| 233 | #define CLD_DUMPED (__SI_CHLD|3) /* child terminated abnormally */ |
| 234 | #define CLD_TRAPPED (__SI_CHLD|4) /* traced child has trapped */ |
| 235 | #define CLD_STOPPED (__SI_CHLD|5) /* child has stopped */ |
| 236 | #define CLD_CONTINUED (__SI_CHLD|6) /* stopped child has continued */ |
| 237 | #define NSIGCHLD 6 |
| 238 | |
| 239 | /* |
| 240 | * SIGPOLL si_codes |
| 241 | */ |
| 242 | #define POLL_IN (__SI_POLL|1) /* data input available */ |
| 243 | #define POLL_OUT (__SI_POLL|2) /* output buffers available */ |
| 244 | #define POLL_MSG (__SI_POLL|3) /* input message available */ |
| 245 | #define POLL_ERR (__SI_POLL|4) /* i/o error */ |
| 246 | #define POLL_PRI (__SI_POLL|5) /* high priority input available */ |
| 247 | #define POLL_HUP (__SI_POLL|6) /* device disconnected */ |
| 248 | #define NSIGPOLL 6 |
| 249 | |
| 250 | /* |
Will Drewry | a0727e8 | 2012-04-12 16:48:00 -0500 | [diff] [blame] | 251 | * SIGSYS si_codes |
| 252 | */ |
| 253 | #define SYS_SECCOMP (__SI_SYS|1) /* seccomp triggered */ |
| 254 | #define NSIGSYS 1 |
| 255 | |
| 256 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | * sigevent definitions |
| 258 | * |
| 259 | * It seems likely that SIGEV_THREAD will have to be handled from |
| 260 | * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the |
| 261 | * thread manager then catches and does the appropriate nonsense. |
| 262 | * However, everything is written out here so as to not get lost. |
| 263 | */ |
| 264 | #define SIGEV_SIGNAL 0 /* notify via signal */ |
| 265 | #define SIGEV_NONE 1 /* other notification: meaningless */ |
| 266 | #define SIGEV_THREAD 2 /* deliver via thread creation */ |
| 267 | #define SIGEV_THREAD_ID 4 /* deliver to thread */ |
| 268 | |
Stephen Rothwell | a71c1ab | 2005-05-01 08:59:08 -0700 | [diff] [blame] | 269 | /* |
| 270 | * This works because the alignment is ok on all current architectures |
| 271 | * but we leave open this being overridden in the future |
| 272 | */ |
| 273 | #ifndef __ARCH_SIGEV_PREAMBLE_SIZE |
| 274 | #define __ARCH_SIGEV_PREAMBLE_SIZE (sizeof(int) * 2 + sizeof(sigval_t)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 275 | #endif |
| 276 | |
Stephen Rothwell | a71c1ab | 2005-05-01 08:59:08 -0700 | [diff] [blame] | 277 | #define SIGEV_MAX_SIZE 64 |
| 278 | #define SIGEV_PAD_SIZE ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \ |
| 279 | / sizeof(int)) |
| 280 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | typedef struct sigevent { |
| 282 | sigval_t sigev_value; |
| 283 | int sigev_signo; |
| 284 | int sigev_notify; |
| 285 | union { |
| 286 | int _pad[SIGEV_PAD_SIZE]; |
| 287 | int _tid; |
| 288 | |
| 289 | struct { |
| 290 | void (*_function)(sigval_t); |
| 291 | void *_attribute; /* really pthread_attr_t */ |
| 292 | } _sigev_thread; |
| 293 | } _sigev_un; |
| 294 | } sigevent_t; |
| 295 | |
| 296 | #define sigev_notify_function _sigev_un._sigev_thread._function |
| 297 | #define sigev_notify_attributes _sigev_un._sigev_thread._attribute |
| 298 | #define sigev_notify_thread_id _sigev_un._tid |
| 299 | |
| 300 | #ifdef __KERNEL__ |
| 301 | |
| 302 | struct siginfo; |
| 303 | void do_schedule_next_timer(struct siginfo *info); |
| 304 | |
| 305 | #ifndef HAVE_ARCH_COPY_SIGINFO |
| 306 | |
| 307 | #include <linux/string.h> |
| 308 | |
| 309 | static inline void copy_siginfo(struct siginfo *to, struct siginfo *from) |
| 310 | { |
| 311 | if (from->si_code < 0) |
| 312 | memcpy(to, from, sizeof(*to)); |
| 313 | else |
| 314 | /* _sigchld is currently the largest know union member */ |
| 315 | memcpy(to, from, __ARCH_SI_PREAMBLE_SIZE + sizeof(from->_sifields._sigchld)); |
| 316 | } |
| 317 | |
| 318 | #endif |
| 319 | |
| 320 | extern int copy_siginfo_to_user(struct siginfo __user *to, struct siginfo *from); |
| 321 | |
| 322 | #endif /* __KERNEL__ */ |
| 323 | |
| 324 | #endif |