Skip to content

Commit d4d53f7

Browse files
Shannon Zhaosashalevin
authored andcommitted
arm/arm64: KVM: vgic: kick the specific vcpu instead of iterating through all
commit 016ed39 upstream. 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 <christoffer.dall@linaro.org> Signed-off-by: Shannon Zhao <zhaoshenglong@huawei.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com> Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
1 parent c0a5bda commit d4d53f7

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

‎virt/kvm/arm/vgic.c‎

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

1611-
static bool vgic_update_irq_pending(struct kvm *kvm, int cpuid,
1611+
static int vgic_update_irq_pending(struct kvm *kvm, int cpuid,
16121612
unsigned int irq_num, bool level)
16131613
{
16141614
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)