diff options
-rw-r--r-- | include/linux/kvm_host.h | 1 | ||||
-rw-r--r-- | virt/kvm/kvm_main.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index b985a29d8175..bd5a616d9373 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -286,6 +286,7 @@ int kvm_is_visible_gfn(struct kvm *kvm, gfn_t gfn); | |||
286 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); | 286 | void mark_page_dirty(struct kvm *kvm, gfn_t gfn); |
287 | 287 | ||
288 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); | 288 | void kvm_vcpu_block(struct kvm_vcpu *vcpu); |
289 | void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu); | ||
289 | void kvm_resched(struct kvm_vcpu *vcpu); | 290 | void kvm_resched(struct kvm_vcpu *vcpu); |
290 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); | 291 | void kvm_load_guest_fpu(struct kvm_vcpu *vcpu); |
291 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); | 292 | void kvm_put_guest_fpu(struct kvm_vcpu *vcpu); |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 70c8cbea0a99..cac69c4415df 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
@@ -1108,6 +1108,21 @@ void kvm_resched(struct kvm_vcpu *vcpu) | |||
1108 | } | 1108 | } |
1109 | EXPORT_SYMBOL_GPL(kvm_resched); | 1109 | EXPORT_SYMBOL_GPL(kvm_resched); |
1110 | 1110 | ||
1111 | void kvm_vcpu_on_spin(struct kvm_vcpu *vcpu) | ||
1112 | { | ||
1113 | ktime_t expires; | ||
1114 | DEFINE_WAIT(wait); | ||
1115 | |||
1116 | prepare_to_wait(&vcpu->wq, &wait, TASK_INTERRUPTIBLE); | ||
1117 | |||
1118 | /* Sleep for 100 us, and hope lock-holder got scheduled */ | ||
1119 | expires = ktime_add_ns(ktime_get(), 100000UL); | ||
1120 | schedule_hrtimeout(&expires, HRTIMER_MODE_ABS); | ||
1121 | |||
1122 | finish_wait(&vcpu->wq, &wait); | ||
1123 | } | ||
1124 | EXPORT_SYMBOL_GPL(kvm_vcpu_on_spin); | ||
1125 | |||
1111 | static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf) | 1126 | static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf) |
1112 | { | 1127 | { |
1113 | struct kvm_vcpu *vcpu = vma->vm_file->private_data; | 1128 | struct kvm_vcpu *vcpu = vma->vm_file->private_data; |