1 /* SPDX-License-Identifier: GPL-2.0+ WITH Linu 1 2 #ifndef _LINUX_RSEQ_H 3 #define _LINUX_RSEQ_H 4 5 #ifdef CONFIG_RSEQ 6 7 #include <linux/preempt.h> 8 #include <linux/sched.h> 9 10 /* 11 * Map the event mask on the user-space ABI en 12 * for direct mask checks. 13 */ 14 enum rseq_event_mask_bits { 15 RSEQ_EVENT_PREEMPT_BIT = RSEQ_CS_FLAG 16 RSEQ_EVENT_SIGNAL_BIT = RSEQ_CS_FLAG 17 RSEQ_EVENT_MIGRATE_BIT = RSEQ_CS_FLAG 18 }; 19 20 enum rseq_event_mask { 21 RSEQ_EVENT_PREEMPT = (1U << RSEQ_ 22 RSEQ_EVENT_SIGNAL = (1U << RSEQ_ 23 RSEQ_EVENT_MIGRATE = (1U << RSEQ_ 24 }; 25 26 static inline void rseq_set_notify_resume(stru 27 { 28 if (t->rseq) 29 set_tsk_thread_flag(t, TIF_NOT 30 } 31 32 void __rseq_handle_notify_resume(struct ksigna 33 34 static inline void rseq_handle_notify_resume(s 35 s 36 { 37 if (current->rseq) 38 __rseq_handle_notify_resume(ks 39 } 40 41 static inline void rseq_signal_deliver(struct 42 struct 43 { 44 preempt_disable(); 45 __set_bit(RSEQ_EVENT_SIGNAL_BIT, &curr 46 preempt_enable(); 47 rseq_handle_notify_resume(ksig, regs); 48 } 49 50 /* rseq_preempt() requires preemption to be di 51 static inline void rseq_preempt(struct task_st 52 { 53 __set_bit(RSEQ_EVENT_PREEMPT_BIT, &t-> 54 rseq_set_notify_resume(t); 55 } 56 57 /* rseq_migrate() requires preemption to be di 58 static inline void rseq_migrate(struct task_st 59 { 60 __set_bit(RSEQ_EVENT_MIGRATE_BIT, &t-> 61 rseq_set_notify_resume(t); 62 } 63 64 /* 65 * If parent process has a registered restarta 66 * child inherits. Unregister rseq for a clone 67 */ 68 static inline void rseq_fork(struct task_struc 69 { 70 if (clone_flags & CLONE_VM) { 71 t->rseq = NULL; 72 t->rseq_len = 0; 73 t->rseq_sig = 0; 74 t->rseq_event_mask = 0; 75 } else { 76 t->rseq = current->rseq; 77 t->rseq_len = current->rseq_le 78 t->rseq_sig = current->rseq_si 79 t->rseq_event_mask = current-> 80 } 81 } 82 83 static inline void rseq_execve(struct task_str 84 { 85 t->rseq = NULL; 86 t->rseq_len = 0; 87 t->rseq_sig = 0; 88 t->rseq_event_mask = 0; 89 } 90 91 #else 92 93 static inline void rseq_set_notify_resume(stru 94 { 95 } 96 static inline void rseq_handle_notify_resume(s 97 s 98 { 99 } 100 static inline void rseq_signal_deliver(struct 101 struct 102 { 103 } 104 static inline void rseq_preempt(struct task_st 105 { 106 } 107 static inline void rseq_migrate(struct task_st 108 { 109 } 110 static inline void rseq_fork(struct task_struc 111 { 112 } 113 static inline void rseq_execve(struct task_str 114 { 115 } 116 117 #endif 118 119 #ifdef CONFIG_DEBUG_RSEQ 120 121 void rseq_syscall(struct pt_regs *regs); 122 123 #else 124 125 static inline void rseq_syscall(struct pt_regs 126 { 127 } 128 129 #endif 130 131 #endif /* _LINUX_RSEQ_H */ 132
Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.