Skip to content

Commit 18869f2

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: disable preemption around the call to kvm_arch_vcpu_{un|}blocking
On SVM, if preemption happens right after the call to finish_rcuwait but before call to kvm_arch_vcpu_unblocking on SVM/AVIC, it itself will re-enable AVIC, and then we will try to re-enable it again in kvm_arch_vcpu_unblocking which will lead to a warning in __avic_vcpu_load. The same problem can happen if the vCPU is preempted right after the call to kvm_arch_vcpu_blocking but before the call to prepare_to_rcuwait and in this case, we will end up with AVIC enabled during sleep - Ooops. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20220606180829.102503-7-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 66c768d commit 18869f2

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

virt/kvm/kvm_main.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3328,9 +3328,11 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu)
33283328

33293329
vcpu->stat.generic.blocking = 1;
33303330

3331+
preempt_disable();
33313332
kvm_arch_vcpu_blocking(vcpu);
3332-
33333333
prepare_to_rcuwait(wait);
3334+
preempt_enable();
3335+
33343336
for (;;) {
33353337
set_current_state(TASK_INTERRUPTIBLE);
33363338

@@ -3340,9 +3342,11 @@ bool kvm_vcpu_block(struct kvm_vcpu *vcpu)
33403342
waited = true;
33413343
schedule();
33423344
}
3343-
finish_rcuwait(wait);
33443345

3346+
preempt_disable();
3347+
finish_rcuwait(wait);
33453348
kvm_arch_vcpu_unblocking(vcpu);
3349+
preempt_enable();
33463350

33473351
vcpu->stat.generic.blocking = 0;
33483352

0 commit comments

Comments
 (0)