| 1 | /* SPDX-License-Identifier: GPL-2.0 */ |
|---|---|
| 2 | #ifndef _LINUX_USER_RETURN_NOTIFIER_H |
| 3 | #define _LINUX_USER_RETURN_NOTIFIER_H |
| 4 | |
| 5 | #ifdef CONFIG_USER_RETURN_NOTIFIER |
| 6 | |
| 7 | #include <linux/list.h> |
| 8 | #include <linux/sched.h> |
| 9 | |
| 10 | struct user_return_notifier { |
| 11 | void (*on_user_return)(struct user_return_notifier *urn); |
| 12 | struct hlist_node link; |
| 13 | }; |
| 14 | |
| 15 | |
| 16 | void user_return_notifier_register(struct user_return_notifier *urn); |
| 17 | void user_return_notifier_unregister(struct user_return_notifier *urn); |
| 18 | |
| 19 | static inline void propagate_user_return_notify(struct task_struct *prev, |
| 20 | struct task_struct *next) |
| 21 | { |
| 22 | if (test_tsk_thread_flag(tsk: prev, TIF_USER_RETURN_NOTIFY)) { |
| 23 | clear_tsk_thread_flag(tsk: prev, TIF_USER_RETURN_NOTIFY); |
| 24 | set_tsk_thread_flag(tsk: next, TIF_USER_RETURN_NOTIFY); |
| 25 | } |
| 26 | } |
| 27 | |
| 28 | void fire_user_return_notifiers(void); |
| 29 | |
| 30 | static inline void clear_user_return_notifier(struct task_struct *p) |
| 31 | { |
| 32 | clear_tsk_thread_flag(tsk: p, TIF_USER_RETURN_NOTIFY); |
| 33 | } |
| 34 | |
| 35 | #else |
| 36 | |
| 37 | struct user_return_notifier {}; |
| 38 | |
| 39 | static inline void propagate_user_return_notify(struct task_struct *prev, |
| 40 | struct task_struct *next) |
| 41 | { |
| 42 | } |
| 43 | |
| 44 | static inline void fire_user_return_notifiers(void) {} |
| 45 | |
| 46 | static inline void clear_user_return_notifier(struct task_struct *p) {} |
| 47 | |
| 48 | #endif |
| 49 | |
| 50 | #endif |
| 51 |
