Skip to content

Commit 016ed39

Browse files
Shannon ZhaoMarc Zyngier
authored andcommitted
arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all
When call kvm_vgic_inject_irq to inject interrupt, we can known which vcpu the interrupt for by the irq_num and the cpuid. So we should just kick this vcpu to avoid iterating through all. Reviewed-by: Christoffer Dall <[email protected]> Signed-off-by: Shannon Zhao <[email protected]> Signed-off-by: Marc Zyngier <[email protected]>
1 parent b1e952b commit 016ed39

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

virt/kvm/arm/vgic.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,7 +1607,7 @@ static int vgic_validate_injection(struct kvm_vcpu *vcpu, int irq, int level)
16071607
}
16081608
}
16091609

1610-
static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
1610+
static int vgic_update_irq_pending(struct kvm *kvm, int cpuid,
16111611
unsigned int irq_num, bool level)
16121612
{
16131613
struct vgic_dist *dist = &kvm->arch.vgic;
@@ -1673,7 +1673,7 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
16731673
out:
16741674
spin_unlock(&dist->lock);
16751675

1676-
return ret;
1676+
return ret ? cpuid : -EINVAL;
16771677
}
16781678

16791679
/**
@@ -1693,9 +1693,14 @@ static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
16931693
int kvm_vgic_inject_irq(struct kvm *kvm, int cpuid, unsigned int irq_num,
16941694
bool level)
16951695
{
1696-
if (likely(vgic_initialized(kvm)) &&
1697-
vgic_update_irq_pending(kvm, cpuid, irq_num, level))
1698-
vgic_kick_vcpus(kvm);
1696+
int vcpu_id;
1697+
1698+
if (likely(vgic_initialized(kvm))) {
1699+
vcpu_id = vgic_update_irq_pending(kvm, cpuid, irq_num, level);
1700+
if (vcpu_id >= 0)
1701+
/* kick the specified vcpu */
1702+
kvm_vcpu_kick(kvm_get_vcpu(kvm, vcpu_id));
1703+
}
16991704

17001705
return 0;
17011706
}

0 commit comments

Comments
 (0)