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