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.h35
1 files changed, 35 insertions, 0 deletions
diff --git a/include/linux/context_tracking.h b/include/linux/context_tracking.h
index 365f4a61bf04..fc09d7b0dacf 100644
--- a/include/linux/context_tracking.h
+++ b/include/linux/context_tracking.h
@@ -3,6 +3,7 @@
3 3
4#include <linux/sched.h> 4#include <linux/sched.h>
5#include <linux/percpu.h> 5#include <linux/percpu.h>
6#include <linux/vtime.h>
6#include <asm/ptrace.h> 7#include <asm/ptrace.h>
7 8
8struct context_tracking { 9struct context_tracking {
@@ -19,6 +20,26 @@ struct context_tracking {
19 } state; 20 } state;
20}; 21};
21 22
23static inline void __guest_enter(void)
24{
25 /*
26 * This is running in ioctl context so we can avoid
27 * the call to vtime_account() with its unnecessary idle check.
28 */
29 vtime_account_system(current);
30 current->flags |= PF_VCPU;
31}
32
33static inline void __guest_exit(void)
34{
35 /*
36 * This is running in ioctl context so we can avoid
37 * the call to vtime_account() with its unnecessary idle check.
38 */
39 vtime_account_system(current);
40 current->flags &= ~PF_VCPU;
41}
42
22#ifdef CONFIG_CONTEXT_TRACKING 43#ifdef CONFIG_CONTEXT_TRACKING
23DECLARE_PER_CPU(struct context_tracking, context_tracking); 44DECLARE_PER_CPU(struct context_tracking, context_tracking);
24 45
@@ -35,6 +56,9 @@ static inline bool context_tracking_active(void)
35extern void user_enter(void); 56extern void user_enter(void);
36extern void user_exit(void); 57extern void user_exit(void);
37 58
59extern void guest_enter(void);
60extern void guest_exit(void);
61
38static inline enum ctx_state exception_enter(void) 62static inline enum ctx_state exception_enter(void)
39{ 63{
40 enum ctx_state prev_ctx; 64 enum ctx_state prev_ctx;
@@ -57,6 +81,17 @@ extern void context_tracking_task_switch(struct task_struct *prev,
57static inline bool context_tracking_in_user(void) { return false; } 81static inline bool context_tracking_in_user(void) { return false; }
58static inline void user_enter(void) { } 82static inline void user_enter(void) { }
59static inline void user_exit(void) { } 83static inline void user_exit(void) { }
84
85static inline void guest_enter(void)
86{
87 __guest_enter();
88}
89
90static inline void guest_exit(void)
91{
92 __guest_exit();
93}
94
60static inline enum ctx_state exception_enter(void) { return 0; } 95static inline enum ctx_state exception_enter(void) { return 0; }
61static inline void exception_exit(enum ctx_state prev_ctx) { } 96static inline void exception_exit(enum ctx_state prev_ctx) { }
62static inline void context_tracking_task_switch(struct task_struct *prev, 97static inline void context_tracking_task_switch(struct task_struct *prev,