diff options
Diffstat (limited to 'include/linux/context_tracking.h')
| -rw-r--r-- | include/linux/context_tracking.h | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h index 5a69273e93e6..365f4a61bf04 100644 --- a/include/linux/context_tracking.h +++ b/include/linux/context_tracking.h | |||
| @@ -5,7 +5,6 @@ | |||
| 5 | #include <linux/percpu.h> | 5 | #include <linux/percpu.h> |
| 6 | #include <asm/ptrace.h> | 6 | #include <asm/ptrace.h> |
| 7 | 7 | ||
| 8 | #ifdef CONFIG_CONTEXT_TRACKING | ||
| 9 | struct context_tracking { | 8 | struct context_tracking { |
| 10 | /* | 9 | /* |
| 11 | * When active is false, probes are unset in order | 10 | * When active is false, probes are unset in order |
| @@ -14,12 +13,13 @@ struct context_tracking { | |||
| 14 | * may be further optimized using static keys. | 13 | * may be further optimized using static keys. |
| 15 | */ | 14 | */ |
| 16 | bool active; | 15 | bool active; |
| 17 | enum { | 16 | enum ctx_state { |
| 18 | IN_KERNEL = 0, | 17 | IN_KERNEL = 0, |
| 19 | IN_USER, | 18 | IN_USER, |
| 20 | } state; | 19 | } state; |
| 21 | }; | 20 | }; |
| 22 | 21 | ||
| 22 | #ifdef CONFIG_CONTEXT_TRACKING | ||
| 23 | DECLARE_PER_CPU(struct context_tracking, context_tracking); | 23 | DECLARE_PER_CPU(struct context_tracking, context_tracking); |
| 24 | 24 | ||
| 25 | static inline bool context_tracking_in_user(void) | 25 | static inline bool context_tracking_in_user(void) |
| @@ -35,14 +35,19 @@ static inline bool context_tracking_active(void) | |||
| 35 | extern void user_enter(void); | 35 | extern void user_enter(void); |
| 36 | extern void user_exit(void); | 36 | extern void user_exit(void); |
| 37 | 37 | ||
| 38 | static inline void exception_enter(struct pt_regs *regs) | 38 | static inline enum ctx_state exception_enter(void) |
| 39 | { | 39 | { |
| 40 | enum ctx_state prev_ctx; | ||
| 41 | |||
| 42 | prev_ctx = this_cpu_read(context_tracking.state); | ||
| 40 | user_exit(); | 43 | user_exit(); |
| 44 | |||
| 45 | return prev_ctx; | ||
| 41 | } | 46 | } |
| 42 | 47 | ||
| 43 | static inline void exception_exit(struct pt_regs *regs) | 48 | static inline void exception_exit(enum ctx_state prev_ctx) |
| 44 | { | 49 | { |
| 45 | if (user_mode(regs)) | 50 | if (prev_ctx == IN_USER) |
| 46 | user_enter(); | 51 | user_enter(); |
| 47 | } | 52 | } |
| 48 | 53 | ||
| @@ -52,8 +57,8 @@ extern void context_tracking_task_switch(struct task_struct *prev, | |||
| 52 | static inline bool context_tracking_in_user(void) { return false; } | 57 | static inline bool context_tracking_in_user(void) { return false; } |
| 53 | static inline void user_enter(void) { } | 58 | static inline void user_enter(void) { } |
| 54 | static inline void user_exit(void) { } | 59 | static inline void user_exit(void) { } |
| 55 | static inline void exception_enter(struct pt_regs *regs) { } | 60 | static inline enum ctx_state exception_enter(void) { return 0; } |
| 56 | static inline void exception_exit(struct pt_regs *regs) { } | 61 | static inline void exception_exit(enum ctx_state prev_ctx) { } |
| 57 | static inline void context_tracking_task_switch(struct task_struct *prev, | 62 | static inline void context_tracking_task_switch(struct task_struct *prev, |
| 58 | struct task_struct *next) { } | 63 | struct task_struct *next) { } |
| 59 | #endif /* !CONFIG_CONTEXT_TRACKING */ | 64 | #endif /* !CONFIG_CONTEXT_TRACKING */ |
