Skip to contentSkip to conversation

KVM: arm/arm64: vgic: Stop injecting the MSI occurrence twice

PATCH Superseded Shanker Donthineni 3 participants 3 messages Feb 3, 2017 KVM arm64

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm/arm64: vgic: Stop injecting the MSI occurrence twice

The IRQFD framework calls the architecture dependent function twice if the corresponding GSI type is edge triggered. For ARM, the function kvm_set_msi() is getting called twice whenever the IRQFD receives the event signal. The rest of the code path is trying to inject the MSI without any validation checks. No need to call the function vgic_its_inject_msi() second time to avoid an unnecessary overhead in IRQ queue logic. It also avoids the possibility of VM seeing the MSI twice.

Simple fix, return -1 if the argument 'level' value is zero.

---
 virt/kvm/arm/vgic/vgic-irqfd.c | 3 +++
 1 file changed, 3 insertions(+)
virt/kvm/arm/vgic/vgic-irqfd.c +3 -0
index d918dcf..f138ed2 100644
@@ -99,6 +99,9 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 	if (!vgic_has_its(kvm))
 		return -ENODEV;
 
+	if (!level)
+		return -1;
+
 	return vgic_its_inject_msi(kvm, &msi);
 }
 
Signature · 2 lines
Qualcomm Datacenter Technologies, Inc. on behalf of the Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Reviewed-by on v1 1/1
#1 lore raw

Hi Shanker,

Quoted 9 lines · Shanker Donthineni

The IRQFD framework calls the architecture dependent function twice if the corresponding GSI type is edge triggered. For ARM, the function kvm_set_msi() is getting called twice whenever the IRQFD receives the event signal. The rest of the code path is trying to inject the MSI without any validation checks. No need to call the function vgic_its_inject_msi() second time to avoid an unnecessary overhead in IRQ queue logic. It also avoids the possibility of VM seeing the MSI twice.

Quoted 3 lines

Simple fix, return -1 if the argument 'level' value is zero.

Thanks for catching that bug!

Eric

Quoted 19 lines
---
 virt/kvm/arm/vgic/vgic-irqfd.c | 3 +++
 1 file changed, 3 insertions(+)
virt/kvm/arm/vgic/vgic-irqfd.c +3 -0
index d918dcf..f138ed2 100644
@@ -99,6 +99,9 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 	if (!vgic_has_its(kvm))
 		return -ENODEV;
 
+	if (!level)
+		return -1;
+
 	return vgic_its_inject_msi(kvm, &msi);
 }
 
Reviewed-by on v1 1/1
#2 lore raw
In reply to Shanker Donthineni

Hi Shanker,

[please cc the kvmarm list for kvm/arm patches, thanks]

Quoted 22 lines · Shanker Donthineni

The IRQFD framework calls the architecture dependent function twice if the corresponding GSI type is edge triggered. For ARM, the function kvm_set_msi() is getting called twice whenever the IRQFD receives the event signal. The rest of the code path is trying to inject the MSI without any validation checks. No need to call the function vgic_its_inject_msi() second time to avoid an unnecessary overhead in IRQ queue logic. It also avoids the possibility of VM seeing the MSI twice.

Simple fix, return -1 if the argument 'level' value is zero.

---
 virt/kvm/arm/vgic/vgic-irqfd.c | 3 +++
 1 file changed, 3 insertions(+)
virt/kvm/arm/vgic/vgic-irqfd.c +0 -0
index d918dcf..f138ed2 100644

virt/kvm/arm/vgic/vgic-irqfd.c int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e, · line 107

Quoted 9 lines
virt/kvm/arm/vgic/vgic-irqfd.c +3 -0
@@ -99,6 +99,9 @@ int kvm_set_msi(struct kvm_kernel_irq_routing_entry *e,
 	if (!vgic_has_its(kvm))
 		return -ENODEV;
 
+	if (!level)
+		return -1;
+
 	return vgic_its_inject_msi(kvm, &msi);
 }