diff options
author | Christian Borntraeger <borntraeger@de.ibm.com> | 2015-04-30 13:43:30 +0200 |
---|---|---|
committer | Alex Shi <alex.shi@linaro.org> | 2016-05-24 11:10:08 +0800 |
commit | e0497e5362b9fa13bbd0cdb43ea5d7739a919e22 (patch) | |
tree | 07044671ffaf01cc5b3757f950c1e3db9a6cbe0c /include | |
parent | dc61eb672d45359d3b5547e939e49ea1281d335f (diff) |
KVM: provide irq_unsafe kvm_guest_{enter|exit}
Several kvm architectures disable interrupts before kvm_guest_enter.
kvm_guest_enter then uses local_irq_save/restore to disable interrupts
again or for the first time. Lets provide underscore versions of
kvm_guest_{enter|exit} that assume being called locked.
kvm_guest_enter now disables interrupts for the full function and
thus we can remove the check for preemptible.
This patch then adopts s390/kvm to use local_irq_disable/enable calls
which are slighty cheaper that local_irq_save/restore and call these
new functions.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit 0097d12e504b3ce57b68810737ad6a5a64a98c68)
Signed-off-by: Alex Shi <alex.shi@linaro.org>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/kvm_host.h | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 29a57a5b7cee..110964d19e5a 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h @@ -773,16 +773,10 @@ static inline void kvm_iommu_unmap_pages(struct kvm *kvm, } #endif -static inline void kvm_guest_enter(void) +/* must be called with irqs disabled */ +static inline void __kvm_guest_enter(void) { - unsigned long flags; - - BUG_ON(preemptible()); - - local_irq_save(flags); guest_enter(); - local_irq_restore(flags); - /* KVM does not hold any references to rcu protected data when it * switches CPU into a guest mode. In fact switching to a guest mode * is very similar to exiting to userspace from rcu point of view. In @@ -794,12 +788,27 @@ static inline void kvm_guest_enter(void) rcu_virt_note_context_switch(smp_processor_id()); } +/* must be called with irqs disabled */ +static inline void __kvm_guest_exit(void) +{ + guest_exit(); +} + +static inline void kvm_guest_enter(void) +{ + unsigned long flags; + + local_irq_save(flags); + __kvm_guest_enter(); + local_irq_restore(flags); +} + static inline void kvm_guest_exit(void) { unsigned long flags; local_irq_save(flags); - guest_exit(); + __kvm_guest_exit(); local_irq_restore(flags); } |