aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux
diff options
context:
space:
mode:
authorFrederic Weisbecker <fweisbec@gmail.com>2013-05-15 19:21:38 -0400
committerIngo Molnar <mingo@kernel.org>2013-05-31 05:32:30 -0400
commit521921bad1192fb1b8f9b6a5aa673635848b8b5f (patch)
treee7aa88d4d03fa9b495173469f85a64a9eb530d98 /include/linux
parent45eacc692771bd2b1ea3d384e6345cab3da10861 (diff)
kvm: Move guest entry/exit APIs to context_tracking
The kvm_host.h header file doesn't handle well inclusion when archs don't support KVM. This results in build crashes for such archs when they want to implement context tracking because this subsystem includes kvm_host.h in order to implement the guest_enter/exit APIs but it doesn't handle KVM off case. To fix this, move the guest_enter()/guest_exit() declarations and generic implementation to the context tracking headers. These generic APIs actually belong to this subsystem, besides other domains boundary tracking like user_enter() et al. KVM now properly becomes a user of this library, not the other buggy way around. Reported-by: Kevin Hilman <khilman@linaro.org> Reviewed-by: Kevin Hilman <khilman@linaro.org> Tested-by: Kevin Hilman <khilman@linaro.org> Signed-off-by: Frederic Weisbecker <fweisbec@gmail.com> Cc: Steven Rostedt <rostedt@goodmis.org> Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Kevin Hilman <khilman@linaro.org> Cc: Marcelo Tosatti <mtosatti@redhat.com> Cc: Gleb Natapov <gleb@redhat.com> Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/context_tracking.h35
-rw-r--r--include/linux/kvm_host.h37
2 files changed, 36 insertions, 36 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,
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
763static 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
773static 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
784extern void guest_enter(void);
785extern void guest_exit(void);
786
787#else /* !CONFIG_CONTEXT_TRACKING */
788static inline void guest_enter(void)
789{
790 __guest_enter();
791}
792
793static inline void guest_exit(void)
794{
795 __guest_exit();
796}
797#endif /* !CONFIG_CONTEXT_TRACKING */
798
799static inline void kvm_guest_enter(void) 764static inline void kvm_guest_enter(void)
800{ 765{
801 unsigned long flags; 766 unsigned long flags;