Back to home page

OSCL-LXR

 
 

    


0001 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
0002 #ifndef _UAPI_ASM_GENERIC_SIGINFO_H
0003 #define _UAPI_ASM_GENERIC_SIGINFO_H
0004 
0005 #include <linux/compiler.h>
0006 #include <linux/types.h>
0007 
0008 typedef union sigval {
0009     int sival_int;
0010     void __user *sival_ptr;
0011 } sigval_t;
0012 
0013 #define SI_MAX_SIZE 128
0014 
0015 /*
0016  * The default "si_band" type is "long", as specified by POSIX.
0017  * However, some architectures want to override this to "int"
0018  * for historical compatibility reasons, so we allow that.
0019  */
0020 #ifndef __ARCH_SI_BAND_T
0021 #define __ARCH_SI_BAND_T long
0022 #endif
0023 
0024 #ifndef __ARCH_SI_CLOCK_T
0025 #define __ARCH_SI_CLOCK_T __kernel_clock_t
0026 #endif
0027 
0028 #ifndef __ARCH_SI_ATTRIBUTES
0029 #define __ARCH_SI_ATTRIBUTES
0030 #endif
0031 
0032 /*
0033  * Be careful when extending this union.  On 32bit siginfo_t is 32bit
0034  * aligned.  Which means that a 64bit field or any other field that
0035  * would increase the alignment of siginfo_t will break the ABI.
0036  */
0037 union __sifields {
0038     /* kill() */
0039     struct {
0040         __kernel_pid_t _pid;    /* sender's pid */
0041         __kernel_uid32_t _uid;  /* sender's uid */
0042     } _kill;
0043 
0044     /* POSIX.1b timers */
0045     struct {
0046         __kernel_timer_t _tid;  /* timer id */
0047         int _overrun;       /* overrun count */
0048         sigval_t _sigval;   /* same as below */
0049         int _sys_private;       /* not to be passed to user */
0050     } _timer;
0051 
0052     /* POSIX.1b signals */
0053     struct {
0054         __kernel_pid_t _pid;    /* sender's pid */
0055         __kernel_uid32_t _uid;  /* sender's uid */
0056         sigval_t _sigval;
0057     } _rt;
0058 
0059     /* SIGCHLD */
0060     struct {
0061         __kernel_pid_t _pid;    /* which child */
0062         __kernel_uid32_t _uid;  /* sender's uid */
0063         int _status;        /* exit code */
0064         __ARCH_SI_CLOCK_T _utime;
0065         __ARCH_SI_CLOCK_T _stime;
0066     } _sigchld;
0067 
0068     /* SIGILL, SIGFPE, SIGSEGV, SIGBUS, SIGTRAP, SIGEMT */
0069     struct {
0070         void __user *_addr; /* faulting insn/memory ref. */
0071 #ifdef __ia64__
0072         int _imm;       /* immediate value for "break" */
0073         unsigned int _flags;    /* see ia64 si_flags */
0074         unsigned long _isr; /* isr */
0075 #endif
0076 
0077 #define __ADDR_BND_PKEY_PAD  (__alignof__(void *) < sizeof(short) ? \
0078                   sizeof(short) : __alignof__(void *))
0079         union {
0080             /* used on alpha and sparc */
0081             int _trapno;    /* TRAP # which caused the signal */
0082             /*
0083              * used when si_code=BUS_MCEERR_AR or
0084              * used when si_code=BUS_MCEERR_AO
0085              */
0086             short _addr_lsb; /* LSB of the reported address */
0087             /* used when si_code=SEGV_BNDERR */
0088             struct {
0089                 char _dummy_bnd[__ADDR_BND_PKEY_PAD];
0090                 void __user *_lower;
0091                 void __user *_upper;
0092             } _addr_bnd;
0093             /* used when si_code=SEGV_PKUERR */
0094             struct {
0095                 char _dummy_pkey[__ADDR_BND_PKEY_PAD];
0096                 __u32 _pkey;
0097             } _addr_pkey;
0098             /* used when si_code=TRAP_PERF */
0099             struct {
0100                 unsigned long _data;
0101                 __u32 _type;
0102                 __u32 _flags;
0103             } _perf;
0104         };
0105     } _sigfault;
0106 
0107     /* SIGPOLL */
0108     struct {
0109         __ARCH_SI_BAND_T _band; /* POLL_IN, POLL_OUT, POLL_MSG */
0110         int _fd;
0111     } _sigpoll;
0112 
0113     /* SIGSYS */
0114     struct {
0115         void __user *_call_addr; /* calling user insn */
0116         int _syscall;   /* triggering system call number */
0117         unsigned int _arch; /* AUDIT_ARCH_* of syscall */
0118     } _sigsys;
0119 };
0120 
0121 #ifndef __ARCH_HAS_SWAPPED_SIGINFO
0122 #define __SIGINFO           \
0123 struct {                \
0124     int si_signo;           \
0125     int si_errno;           \
0126     int si_code;            \
0127     union __sifields _sifields; \
0128 }
0129 #else
0130 #define __SIGINFO           \
0131 struct {                \
0132     int si_signo;           \
0133     int si_code;            \
0134     int si_errno;           \
0135     union __sifields _sifields; \
0136 }
0137 #endif /* __ARCH_HAS_SWAPPED_SIGINFO */
0138 
0139 typedef struct siginfo {
0140     union {
0141         __SIGINFO;
0142         int _si_pad[SI_MAX_SIZE/sizeof(int)];
0143     };
0144 } __ARCH_SI_ATTRIBUTES siginfo_t;
0145 
0146 /*
0147  * How these fields are to be accessed.
0148  */
0149 #define si_pid      _sifields._kill._pid
0150 #define si_uid      _sifields._kill._uid
0151 #define si_tid      _sifields._timer._tid
0152 #define si_overrun  _sifields._timer._overrun
0153 #define si_sys_private  _sifields._timer._sys_private
0154 #define si_status   _sifields._sigchld._status
0155 #define si_utime    _sifields._sigchld._utime
0156 #define si_stime    _sifields._sigchld._stime
0157 #define si_value    _sifields._rt._sigval
0158 #define si_int      _sifields._rt._sigval.sival_int
0159 #define si_ptr      _sifields._rt._sigval.sival_ptr
0160 #define si_addr     _sifields._sigfault._addr
0161 #define si_trapno   _sifields._sigfault._trapno
0162 #define si_addr_lsb _sifields._sigfault._addr_lsb
0163 #define si_lower    _sifields._sigfault._addr_bnd._lower
0164 #define si_upper    _sifields._sigfault._addr_bnd._upper
0165 #define si_pkey     _sifields._sigfault._addr_pkey._pkey
0166 #define si_perf_data    _sifields._sigfault._perf._data
0167 #define si_perf_type    _sifields._sigfault._perf._type
0168 #define si_perf_flags   _sifields._sigfault._perf._flags
0169 #define si_band     _sifields._sigpoll._band
0170 #define si_fd       _sifields._sigpoll._fd
0171 #define si_call_addr    _sifields._sigsys._call_addr
0172 #define si_syscall  _sifields._sigsys._syscall
0173 #define si_arch     _sifields._sigsys._arch
0174 
0175 /*
0176  * si_code values
0177  * Digital reserves positive values for kernel-generated signals.
0178  */
0179 #define SI_USER     0       /* sent by kill, sigsend, raise */
0180 #define SI_KERNEL   0x80        /* sent by the kernel from somewhere */
0181 #define SI_QUEUE    -1      /* sent by sigqueue */
0182 #define SI_TIMER    -2      /* sent by timer expiration */
0183 #define SI_MESGQ    -3      /* sent by real time mesq state change */
0184 #define SI_ASYNCIO  -4      /* sent by AIO completion */
0185 #define SI_SIGIO    -5      /* sent by queued SIGIO */
0186 #define SI_TKILL    -6      /* sent by tkill system call */
0187 #define SI_DETHREAD -7      /* sent by execve() killing subsidiary threads */
0188 #define SI_ASYNCNL  -60     /* sent by glibc async name lookup completion */
0189 
0190 #define SI_FROMUSER(siptr)  ((siptr)->si_code <= 0)
0191 #define SI_FROMKERNEL(siptr)    ((siptr)->si_code > 0)
0192 
0193 /*
0194  * SIGILL si_codes
0195  */
0196 #define ILL_ILLOPC  1   /* illegal opcode */
0197 #define ILL_ILLOPN  2   /* illegal operand */
0198 #define ILL_ILLADR  3   /* illegal addressing mode */
0199 #define ILL_ILLTRP  4   /* illegal trap */
0200 #define ILL_PRVOPC  5   /* privileged opcode */
0201 #define ILL_PRVREG  6   /* privileged register */
0202 #define ILL_COPROC  7   /* coprocessor error */
0203 #define ILL_BADSTK  8   /* internal stack error */
0204 #define ILL_BADIADDR    9   /* unimplemented instruction address */
0205 #define __ILL_BREAK 10  /* illegal break */
0206 #define __ILL_BNDMOD    11  /* bundle-update (modification) in progress */
0207 #define NSIGILL     11
0208 
0209 /*
0210  * SIGFPE si_codes
0211  */
0212 #define FPE_INTDIV  1   /* integer divide by zero */
0213 #define FPE_INTOVF  2   /* integer overflow */
0214 #define FPE_FLTDIV  3   /* floating point divide by zero */
0215 #define FPE_FLTOVF  4   /* floating point overflow */
0216 #define FPE_FLTUND  5   /* floating point underflow */
0217 #define FPE_FLTRES  6   /* floating point inexact result */
0218 #define FPE_FLTINV  7   /* floating point invalid operation */
0219 #define FPE_FLTSUB  8   /* subscript out of range */
0220 #define __FPE_DECOVF    9   /* decimal overflow */
0221 #define __FPE_DECDIV    10  /* decimal division by zero */
0222 #define __FPE_DECERR    11  /* packed decimal error */
0223 #define __FPE_INVASC    12  /* invalid ASCII digit */
0224 #define __FPE_INVDEC    13  /* invalid decimal digit */
0225 #define FPE_FLTUNK  14  /* undiagnosed floating-point exception */
0226 #define FPE_CONDTRAP    15  /* trap on condition */
0227 #define NSIGFPE     15
0228 
0229 /*
0230  * SIGSEGV si_codes
0231  */
0232 #define SEGV_MAPERR 1   /* address not mapped to object */
0233 #define SEGV_ACCERR 2   /* invalid permissions for mapped object */
0234 #define SEGV_BNDERR 3   /* failed address bound checks */
0235 #ifdef __ia64__
0236 # define __SEGV_PSTKOVF 4   /* paragraph stack overflow */
0237 #else
0238 # define SEGV_PKUERR    4   /* failed protection key checks */
0239 #endif
0240 #define SEGV_ACCADI 5   /* ADI not enabled for mapped object */
0241 #define SEGV_ADIDERR    6   /* Disrupting MCD error */
0242 #define SEGV_ADIPERR    7   /* Precise MCD exception */
0243 #define SEGV_MTEAERR    8   /* Asynchronous ARM MTE error */
0244 #define SEGV_MTESERR    9   /* Synchronous ARM MTE exception */
0245 #define NSIGSEGV    9
0246 
0247 /*
0248  * SIGBUS si_codes
0249  */
0250 #define BUS_ADRALN  1   /* invalid address alignment */
0251 #define BUS_ADRERR  2   /* non-existent physical address */
0252 #define BUS_OBJERR  3   /* object specific hardware error */
0253 /* hardware memory error consumed on a machine check: action required */
0254 #define BUS_MCEERR_AR   4
0255 /* hardware memory error detected in process but not consumed: action optional*/
0256 #define BUS_MCEERR_AO   5
0257 #define NSIGBUS     5
0258 
0259 /*
0260  * SIGTRAP si_codes
0261  */
0262 #define TRAP_BRKPT  1   /* process breakpoint */
0263 #define TRAP_TRACE  2   /* process trace trap */
0264 #define TRAP_BRANCH     3   /* process taken branch trap */
0265 #define TRAP_HWBKPT     4   /* hardware breakpoint/watchpoint */
0266 #define TRAP_UNK    5   /* undiagnosed trap */
0267 #define TRAP_PERF   6   /* perf event with sigtrap=1 */
0268 #define NSIGTRAP    6
0269 
0270 /*
0271  * There is an additional set of SIGTRAP si_codes used by ptrace
0272  * that are of the form: ((PTRACE_EVENT_XXX << 8) | SIGTRAP)
0273  */
0274 
0275 /*
0276  * Flags for si_perf_flags if SIGTRAP si_code is TRAP_PERF.
0277  */
0278 #define TRAP_PERF_FLAG_ASYNC (1u << 0)
0279 
0280 /*
0281  * SIGCHLD si_codes
0282  */
0283 #define CLD_EXITED  1   /* child has exited */
0284 #define CLD_KILLED  2   /* child was killed */
0285 #define CLD_DUMPED  3   /* child terminated abnormally */
0286 #define CLD_TRAPPED 4   /* traced child has trapped */
0287 #define CLD_STOPPED 5   /* child has stopped */
0288 #define CLD_CONTINUED   6   /* stopped child has continued */
0289 #define NSIGCHLD    6
0290 
0291 /*
0292  * SIGPOLL (or any other signal without signal specific si_codes) si_codes
0293  */
0294 #define POLL_IN     1   /* data input available */
0295 #define POLL_OUT    2   /* output buffers available */
0296 #define POLL_MSG    3   /* input message available */
0297 #define POLL_ERR    4   /* i/o error */
0298 #define POLL_PRI    5   /* high priority input available */
0299 #define POLL_HUP    6   /* device disconnected */
0300 #define NSIGPOLL    6
0301 
0302 /*
0303  * SIGSYS si_codes
0304  */
0305 #define SYS_SECCOMP 1   /* seccomp triggered */
0306 #define SYS_USER_DISPATCH 2 /* syscall user dispatch triggered */
0307 #define NSIGSYS     2
0308 
0309 /*
0310  * SIGEMT si_codes
0311  */
0312 #define EMT_TAGOVF  1   /* tag overflow */
0313 #define NSIGEMT     1
0314 
0315 /*
0316  * sigevent definitions
0317  * 
0318  * It seems likely that SIGEV_THREAD will have to be handled from 
0319  * userspace, libpthread transmuting it to SIGEV_SIGNAL, which the
0320  * thread manager then catches and does the appropriate nonsense.
0321  * However, everything is written out here so as to not get lost.
0322  */
0323 #define SIGEV_SIGNAL    0   /* notify via signal */
0324 #define SIGEV_NONE  1   /* other notification: meaningless */
0325 #define SIGEV_THREAD    2   /* deliver via thread creation */
0326 #define SIGEV_THREAD_ID 4   /* deliver to thread */
0327 
0328 /*
0329  * This works because the alignment is ok on all current architectures
0330  * but we leave open this being overridden in the future
0331  */
0332 #ifndef __ARCH_SIGEV_PREAMBLE_SIZE
0333 #define __ARCH_SIGEV_PREAMBLE_SIZE  (sizeof(int) * 2 + sizeof(sigval_t))
0334 #endif
0335 
0336 #define SIGEV_MAX_SIZE  64
0337 #define SIGEV_PAD_SIZE  ((SIGEV_MAX_SIZE - __ARCH_SIGEV_PREAMBLE_SIZE) \
0338         / sizeof(int))
0339 
0340 typedef struct sigevent {
0341     sigval_t sigev_value;
0342     int sigev_signo;
0343     int sigev_notify;
0344     union {
0345         int _pad[SIGEV_PAD_SIZE];
0346          int _tid;
0347 
0348         struct {
0349             void (*_function)(sigval_t);
0350             void *_attribute;   /* really pthread_attr_t */
0351         } _sigev_thread;
0352     } _sigev_un;
0353 } sigevent_t;
0354 
0355 #define sigev_notify_function   _sigev_un._sigev_thread._function
0356 #define sigev_notify_attributes _sigev_un._sigev_thread._attribute
0357 #define sigev_notify_thread_id   _sigev_un._tid
0358 
0359 
0360 #endif /* _UAPI_ASM_GENERIC_SIGINFO_H */