[PATCH 2/4] KVM: x86: SVM: disable preemption in avic_refresh_apicv_exec_ctrl

From: Maxim Levitsky
Date: Tue Mar 01 2022 - 08:56:00 EST


avic_refresh_apicv_exec_ctrl is called from vcpu_enter_guest,
without preemption disabled, however avic_vcpu_load, and
avic_vcpu_put expect preemption to be disabled.

This issue was found by lockdep.

Signed-off-by: Maxim Levitsky <mlevitsk@xxxxxxxxxx>
---
arch/x86/kvm/svm/avic.c | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/arch/x86/kvm/svm/avic.c b/arch/x86/kvm/svm/avic.c
index aea0b13773fd3..e23159f3a62ba 100644
--- a/arch/x86/kvm/svm/avic.c
+++ b/arch/x86/kvm/svm/avic.c
@@ -640,12 +640,16 @@ void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
}
vmcb_mark_dirty(vmcb, VMCB_AVIC);

+ preempt_disable();
+
if (activated)
avic_vcpu_load(vcpu, vcpu->cpu);
else
avic_vcpu_put(vcpu);

avic_set_pi_irte_mode(vcpu, activated);
+
+ preempt_enable();
}

static void svm_ir_list_del(struct vcpu_svm *svm, struct amd_iommu_pi_data *pi)
--
2.26.3