Skip to content

Commit 66c768d

Browse files
Maxim Levitskybonzini
authored andcommitted
KVM: x86: disable preemption while updating apicv inhibition
Currently nothing prevents preemption in kvm_vcpu_update_apicv. On SVM, If the preemption happens after we update the vcpu->arch.apicv_active, the preemption itself will 'update' the inhibition since the AVIC will be first disabled on vCPU unload and then enabled, when the current task is loaded again. Then we will try to update it again, which will lead to a warning in __avic_vcpu_load, that the AVIC is already enabled. Fix this by disabling preemption in this code. Signed-off-by: Maxim Levitsky <mlevitsk@redhat.com> Message-Id: <20220606180829.102503-6-mlevitsk@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
1 parent 603ccef commit 66c768d

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

arch/x86/kvm/x86.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9850,6 +9850,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu)
98509850
return;
98519851

98529852
down_read(&vcpu->kvm->arch.apicv_update_lock);
9853+
preempt_disable();
98539854

98549855
activate = kvm_vcpu_apicv_activated(vcpu);
98559856

@@ -9870,6 +9871,7 @@ void kvm_vcpu_update_apicv(struct kvm_vcpu *vcpu)
98709871
kvm_make_request(KVM_REQ_EVENT, vcpu);
98719872

98729873
out:
9874+
preempt_enable();
98739875
up_read(&vcpu->kvm->arch.apicv_update_lock);
98749876
}
98759877
EXPORT_SYMBOL_GPL(kvm_vcpu_update_apicv);

0 commit comments

Comments
 (0)