Skip to content

Commit f2bc961

Browse files
committed
KVM: SVM: Fold avic_set_pi_irte_mode() into its sole caller
Fold avic_set_pi_irte_mode() into avic_refresh_apicv_exec_ctrl() in anticipation of moving the __avic_vcpu_{load,put}() calls into the critical section, and because having a one-off helper with a name that's easily confused with avic_pi_update_irte() is unnecessary. No functional change intended. Tested-by: Sairaj Kodilkar <sarunkod@amd.com> Link: https://lore.kernel.org/r/20250611224604.313496-59-seanjc@google.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent a23480f commit f2bc961

File tree

1 file changed

+23
-29
lines changed

1 file changed

+23
-29
lines changed

arch/x86/kvm/svm/avic.c

Lines changed: 23 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -729,34 +729,6 @@ void avic_apicv_post_state_restore(struct kvm_vcpu *vcpu)
729729
avic_handle_ldr_update(vcpu);
730730
}
731731

732-
static void avic_set_pi_irte_mode(struct kvm_vcpu *vcpu, bool activate)
733-
{
734-
int apic_id = kvm_cpu_get_apicid(vcpu->cpu);
735-
unsigned long flags;
736-
struct vcpu_svm *svm = to_svm(vcpu);
737-
struct kvm_kernel_irqfd *irqfd;
738-
739-
/*
740-
* Here, we go through the per-vcpu ir_list to update all existing
741-
* interrupt remapping table entry targeting this vcpu.
742-
*/
743-
spin_lock_irqsave(&svm->ir_list_lock, flags);
744-
745-
if (list_empty(&svm->ir_list))
746-
goto out;
747-
748-
list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) {
749-
void *data = irqfd->irq_bypass_data;
750-
751-
if (activate)
752-
WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apic_id));
753-
else
754-
WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data));
755-
}
756-
out:
757-
spin_unlock_irqrestore(&svm->ir_list_lock, flags);
758-
}
759-
760732
static void svm_ir_list_del(struct kvm_kernel_irqfd *irqfd)
761733
{
762734
struct kvm_vcpu *vcpu = irqfd->irq_bypass_vcpu;
@@ -991,6 +963,10 @@ void avic_refresh_virtual_apic_mode(struct kvm_vcpu *vcpu)
991963
void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
992964
{
993965
bool activated = kvm_vcpu_apicv_active(vcpu);
966+
int apic_id = kvm_cpu_get_apicid(vcpu->cpu);
967+
struct vcpu_svm *svm = to_svm(vcpu);
968+
struct kvm_kernel_irqfd *irqfd;
969+
unsigned long flags;
994970

995971
if (!enable_apicv)
996972
return;
@@ -1002,7 +978,25 @@ void avic_refresh_apicv_exec_ctrl(struct kvm_vcpu *vcpu)
1002978
else
1003979
avic_vcpu_put(vcpu);
1004980

1005-
avic_set_pi_irte_mode(vcpu, activated);
981+
/*
982+
* Here, we go through the per-vcpu ir_list to update all existing
983+
* interrupt remapping table entry targeting this vcpu.
984+
*/
985+
spin_lock_irqsave(&svm->ir_list_lock, flags);
986+
987+
if (list_empty(&svm->ir_list))
988+
goto out;
989+
990+
list_for_each_entry(irqfd, &svm->ir_list, vcpu_list) {
991+
void *data = irqfd->irq_bypass_data;
992+
993+
if (activated)
994+
WARN_ON_ONCE(amd_iommu_activate_guest_mode(data, apic_id));
995+
else
996+
WARN_ON_ONCE(amd_iommu_deactivate_guest_mode(data));
997+
}
998+
out:
999+
spin_unlock_irqrestore(&svm->ir_list_lock, flags);
10061000
}
10071001

10081002
void avic_vcpu_blocking(struct kvm_vcpu *vcpu)

0 commit comments

Comments
 (0)