^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_X86_SIGNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_X86_SIGNAL_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/linkage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) /* Most things should be clean enough to redefine this at will, if care
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) is taken to make libc match. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #define _NSIG 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #ifdef __i386__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) # define _NSIG_BPW 32
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) # define _NSIG_BPW 64
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #define _NSIG_WORDS (_NSIG / _NSIG_BPW)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) typedef unsigned long old_sigset_t; /* at least 32 bits */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) typedef struct {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) unsigned long sig[_NSIG_WORDS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) } sigset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) /* non-uapi in-kernel SA_FLAGS for those indicates ABI for a signal frame */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) #define SA_IA32_ABI 0x02000000u
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) #define SA_X32_ABI 0x01000000u
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #ifndef CONFIG_COMPAT
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) typedef sigset_t compat_sigset_t;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) #include <uapi/asm/signal.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) #ifndef __ASSEMBLY__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) #define __ARCH_HAS_SA_RESTORER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) #include <asm/asm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) #include <uapi/asm/sigcontext.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) #ifdef __i386__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) #define __HAVE_ARCH_SIG_BITOPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) #define sigaddset(set,sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) (__builtin_constant_p(sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) ? __const_sigaddset((set), (sig)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) : __gen_sigaddset((set), (sig)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) static inline void __gen_sigaddset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) asm("btsl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) static inline void __const_sigaddset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) unsigned long sig = _sig - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) set->sig[sig / _NSIG_BPW] |= 1 << (sig % _NSIG_BPW);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) #define sigdelset(set, sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65) (__builtin_constant_p(sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) ? __const_sigdelset((set), (sig)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) : __gen_sigdelset((set), (sig)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) static inline void __gen_sigdelset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) asm("btrl %1,%0" : "+m"(*set) : "Ir"(_sig - 1) : "cc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) static inline void __const_sigdelset(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) unsigned long sig = _sig - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) set->sig[sig / _NSIG_BPW] &= ~(1 << (sig % _NSIG_BPW));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) static inline int __const_sigismember(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) unsigned long sig = _sig - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) return 1 & (set->sig[sig / _NSIG_BPW] >> (sig % _NSIG_BPW));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) static inline int __gen_sigismember(sigset_t *set, int _sig)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) bool ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) asm("btl %2,%1" CC_SET(c)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) : CC_OUT(c) (ret) : "m"(*set), "Ir"(_sig-1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) #define sigismember(set, sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) (__builtin_constant_p(sig) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) ? __const_sigismember((set), (sig)) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) : __gen_sigismember((set), (sig)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) struct pt_regs;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) #else /* __i386__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) #undef __HAVE_ARCH_SIG_BITOPS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) #endif /* !__i386__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) #endif /* __ASSEMBLY__ */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) #endif /* _ASM_X86_SIGNAL_H */