aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/context_tracking.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/context_tracking.h')
-rw-r--r--include/linux/context_tracking.h19
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
9struct context_tracking { 8struct 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
23DECLARE_PER_CPU(struct context_tracking, context_tracking); 23DECLARE_PER_CPU(struct context_tracking, context_tracking);
24 24
25static inline bool context_tracking_in_user(void) 25static inline bool context_tracking_in_user(void)
@@ -35,14 +35,19 @@ static inline bool context_tracking_active(void)
35extern void user_enter(void); 35extern void user_enter(void);
36extern void user_exit(void); 36extern void user_exit(void);
37 37
38static inline void exception_enter(struct pt_regs *regs) 38static 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
43static inline void exception_exit(struct pt_regs *regs) 48static 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,
52static inline bool context_tracking_in_user(void) { return false; } 57static inline bool context_tracking_in_user(void) { return false; }
53static inline void user_enter(void) { } 58static inline void user_enter(void) { }
54static inline void user_exit(void) { } 59static inline void user_exit(void) { }
55static inline void exception_enter(struct pt_regs *regs) { } 60static inline enum ctx_state exception_enter(void) { return 0; }
56static inline void exception_exit(struct pt_regs *regs) { } 61static inline void exception_exit(enum ctx_state prev_ctx) { }
57static inline void context_tracking_task_switch(struct task_struct *prev, 62static 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 */