diff options
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 55 |
1 files changed, 46 insertions, 9 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 2c497ab0d03d..b7996a768eb2 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <linux/rcupdate.h> | 22 | #include <linux/rcupdate.h> |
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 <asm/signal.h> | 26 | #include <asm/signal.h> |
26 | 27 | ||
27 | #include <linux/kvm.h> | 28 | #include <linux/kvm.h> |
@@ -740,15 +741,52 @@ static inline int kvm_deassign_device(struct kvm *kvm, | |||
740 | } | 741 | } |
741 | #endif /* CONFIG_IOMMU_API */ | 742 | #endif /* CONFIG_IOMMU_API */ |
742 | 743 | ||
743 | static inline void kvm_guest_enter(void) | 744 | static inline void __guest_enter(void) |
744 | { | 745 | { |
745 | BUG_ON(preemptible()); | ||
746 | /* | 746 | /* |
747 | * This is running in ioctl context so we can avoid | 747 | * This is running in ioctl context so we can avoid |
748 | * the call to vtime_account() with its unnecessary idle check. | 748 | * the call to vtime_account() with its unnecessary idle check. |
749 | */ | 749 | */ |
750 | vtime_account_system_irqsafe(current); | 750 | vtime_account_system(current); |
751 | current->flags |= PF_VCPU; | 751 | current->flags |= PF_VCPU; |
752 | } | ||
753 | |||
754 | static inline void __guest_exit(void) | ||
755 | { | ||
756 | /* | ||
757 | * This is running in ioctl context so we can avoid | ||
758 | * the call to vtime_account() with its unnecessary idle check. | ||
759 | */ | ||
760 | vtime_account_system(current); | ||
761 | current->flags &= ~PF_VCPU; | ||
762 | } | ||
763 | |||
764 | #ifdef CONFIG_CONTEXT_TRACKING | ||
765 | extern void guest_enter(void); | ||
766 | extern void guest_exit(void); | ||
767 | |||
768 | #else /* !CONFIG_CONTEXT_TRACKING */ | ||
769 | static inline void guest_enter(void) | ||
770 | { | ||
771 | __guest_enter(); | ||
772 | } | ||
773 | |||
774 | static inline void guest_exit(void) | ||
775 | { | ||
776 | __guest_exit(); | ||
777 | } | ||
778 | #endif /* !CONFIG_CONTEXT_TRACKING */ | ||
779 | |||
780 | static inline void kvm_guest_enter(void) | ||
781 | { | ||
782 | unsigned long flags; | ||
783 | |||
784 | BUG_ON(preemptible()); | ||
785 | |||
786 | local_irq_save(flags); | ||
787 | guest_enter(); | ||
788 | local_irq_restore(flags); | ||
789 | |||
752 | /* KVM does not hold any references to rcu protected data when it | 790 | /* KVM does not hold any references to rcu protected data when it |
753 | * switches CPU into a guest mode. In fact switching to a guest mode | 791 | * switches CPU into a guest mode. In fact switching to a guest mode |
754 | * is very similar to exiting to userspase from rcu point of view. In | 792 | * is very similar to exiting to userspase from rcu point of view. In |
@@ -761,12 +799,11 @@ static inline void kvm_guest_enter(void) | |||
761 | 799 | ||
762 | static inline void kvm_guest_exit(void) | 800 | static inline void kvm_guest_exit(void) |
763 | { | 801 | { |
764 | /* | 802 | unsigned long flags; |
765 | * This is running in ioctl context so we can avoid | 803 | |
766 | * the call to vtime_account() with its unnecessary idle check. | 804 | local_irq_save(flags); |
767 | */ | 805 | guest_exit(); |
768 | vtime_account_system_irqsafe(current); | 806 | local_irq_restore(flags); |
769 | current->flags &= ~PF_VCPU; | ||
770 | } | 807 | } |
771 | 808 | ||
772 | /* | 809 | /* |