diff options
| -rw-r--r-- | include/linux/context_tracking.h | 35 | ||||
| -rw-r--r-- | include/linux/kvm_host.h | 37 | ||||
| -rw-r--r-- | kernel/context_tracking.c | 1 |
3 files changed, 36 insertions, 37 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 | ||
| 8 | struct context_tracking { | 9 | struct context_tracking { |
| @@ -19,6 +20,26 @@ struct context_tracking { | |||
| 19 | } state; | 20 | } state; |
| 20 | }; | 21 | }; |
| 21 | 22 | ||
| 23 | static 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 | |||
| 33 | static 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 |
| 23 | DECLARE_PER_CPU(struct context_tracking, context_tracking); | 44 | DECLARE_PER_CPU(struct context_tracking, context_tracking); |
| 24 | 45 | ||
| @@ -35,6 +56,9 @@ static inline bool context_tracking_active(void) | |||
| 35 | extern void user_enter(void); | 56 | extern void user_enter(void); |
| 36 | extern void user_exit(void); | 57 | extern void user_exit(void); |
| 37 | 58 | ||
| 59 | extern void guest_enter(void); | ||
| 60 | extern void guest_exit(void); | ||
| 61 | |||
| 38 | static inline enum ctx_state exception_enter(void) | 62 | static 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, | |||
| 57 | static inline bool context_tracking_in_user(void) { return false; } | 81 | static inline bool context_tracking_in_user(void) { return false; } |
| 58 | static inline void user_enter(void) { } | 82 | static inline void user_enter(void) { } |
| 59 | static inline void user_exit(void) { } | 83 | static inline void user_exit(void) { } |
| 84 | |||
| 85 | static inline void guest_enter(void) | ||
| 86 | { | ||
| 87 | __guest_enter(); | ||
| 88 | } | ||
| 89 | |||
| 90 | static inline void guest_exit(void) | ||
| 91 | { | ||
| 92 | __guest_exit(); | ||
| 93 | } | ||
| 94 | |||
| 60 | static inline enum ctx_state exception_enter(void) { return 0; } | 95 | static inline enum ctx_state exception_enter(void) { return 0; } |
| 61 | static inline void exception_exit(enum ctx_state prev_ctx) { } | 96 | static inline void exception_exit(enum ctx_state prev_ctx) { } |
| 62 | static inline void context_tracking_task_switch(struct task_struct *prev, | 97 | static inline void context_tracking_task_switch(struct task_struct *prev, |
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index f0eea07d2c2b..8db53cfaccdb 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
| @@ -23,6 +23,7 @@ | |||
| 23 | #include <linux/ratelimit.h> | 23 | #include <linux/ratelimit.h> |
| 24 | #include <linux/err.h> | 24 | #include <linux/err.h> |
| 25 | #include <linux/irqflags.h> | 25 | #include <linux/irqflags.h> |
| 26 | #include <linux/context_tracking.h> | ||
| 26 | #include <asm/signal.h> | 27 | #include <asm/signal.h> |
| 27 | 28 | ||
| 28 | #include <linux/kvm.h> | 29 | #include <linux/kvm.h> |
| @@ -760,42 +761,6 @@ static inline int kvm_iommu_unmap_guest(struct kvm *kvm) | |||
| 760 | } | 761 | } |
| 761 | #endif | 762 | #endif |
| 762 | 763 | ||
| 763 | static inline void __guest_enter(void) | ||
| 764 | { | ||
| 765 | /* | ||
| 766 | * This is running in ioctl context so we can avoid | ||
| 767 | * the call to vtime_account() with its unnecessary idle check. | ||
| 768 | */ | ||
| 769 | vtime_account_system(current); | ||
| 770 | current->flags |= PF_VCPU; | ||
| 771 | } | ||
| 772 | |||
| 773 | static inline void __guest_exit(void) | ||
| 774 | { | ||
| 775 | /* | ||
| 776 | * This is running in ioctl context so we can avoid | ||
| 777 | * the call to vtime_account() with its unnecessary idle check. | ||
| 778 | */ | ||
| 779 | vtime_account_system(current); | ||
| 780 | current->flags &= ~PF_VCPU; | ||
| 781 | } | ||
| 782 | |||
| 783 | #ifdef CONFIG_CONTEXT_TRACKING | ||
| 784 | extern void guest_enter(void); | ||
| 785 | extern void guest_exit(void); | ||
| 786 | |||
| 787 | #else /* !CONFIG_CONTEXT_TRACKING */ | ||
| 788 | static inline void guest_enter(void) | ||
| 789 | { | ||
| 790 | __guest_enter(); | ||
| 791 | } | ||
| 792 | |||
| 793 | static inline void guest_exit(void) | ||
| 794 | { | ||
| 795 | __guest_exit(); | ||
| 796 | } | ||
| 797 | #endif /* !CONFIG_CONTEXT_TRACKING */ | ||
| 798 | |||
| 799 | static inline void kvm_guest_enter(void) | 764 | static inline void kvm_guest_enter(void) |
| 800 | { | 765 | { |
| 801 | unsigned long flags; | 766 | unsigned long flags; |
diff --git a/kernel/context_tracking.c b/kernel/context_tracking.c index 65349f07b878..85bdde1137eb 100644 --- a/kernel/context_tracking.c +++ b/kernel/context_tracking.c | |||
| @@ -15,7 +15,6 @@ | |||
| 15 | */ | 15 | */ |
| 16 | 16 | ||
| 17 | #include <linux/context_tracking.h> | 17 | #include <linux/context_tracking.h> |
| 18 | #include <linux/kvm_host.h> | ||
| 19 | #include <linux/rcupdate.h> | 18 | #include <linux/rcupdate.h> |
| 20 | #include <linux/sched.h> | 19 | #include <linux/sched.h> |
| 21 | #include <linux/hardirq.h> | 20 | #include <linux/hardirq.h> |
