Skip to contentSkip to conversation

KVM: arm64: ITS: return 1 on successful MSI injection

PATCH Superseded Andre Przywara 3 participants 5 messages Aug 2, 2016

Subsystems (2)

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 KVM: arm64: ITS: return 1 on successful MSI injection

According to the KVM API documentation a successful MSI injection should return a value > 0 on success.
Since we pass the return value of vgic_its_inject_msi() directly on to upper layers and userland, we need to use the same semantics here. Briefly tested with QEMU and kvmtool on GICv3 hardware and the model.

---
Applies on top of next-20160728. Let me know if I should use a different base.

Cheers,
Andre.

 virt/kvm/arm/vgic/vgic-its.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/vgic/vgic-its.c +2 -1
index 07411cf..3268250 100644
@@ -468,6 +468,7 @@ static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
  * We then call vgic_its_trigger_msi() with the decoded data.
+ * According to the KVM_SIGNAL_MSI API description returns > 0 on success.
  */
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 {
@@ -493,7 +494,7 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data);
 	mutex_unlock(&iodev->its->its_lock);
 
-	return 0;
+	return 1;
 }
 
 /* Requires the its_lock to be held. */
Signature · 1 line
2.9.0
#1 lore raw
Quoted 30 lines · Andre Przywara

According to the KVM API documentation a successful MSI injection should return a value > 0 on success.
Since we pass the return value of vgic_its_inject_msi() directly on to upper layers and userland, we need to use the same semantics here. Briefly tested with QEMU and kvmtool on GICv3 hardware and the model.

---
Applies on top of next-20160728. Let me know if I should use a different base.

Cheers,
Andre.

 virt/kvm/arm/vgic/vgic-its.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/vgic/vgic-its.c +1 -0
index 07411cf..3268250 100644
@@ -468,6 +468,7 @@ static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
  * We then call vgic_its_trigger_msi() with the decoded data.
+ * According to the KVM_SIGNAL_MSI API description returns > 0 on success.
  */
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 {

virt/kvm/arm/vgic/vgic-its.c int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) · line 497

Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1 -1
@@ -493,7 +494,7 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data);
 	mutex_unlock(&iodev->its->its_lock);
 
-	return 0;
+	return 1;

Really? And what if:
- ITS is not enabled?
- or no ITTE?
- or collection not mapped?
- or LPIs not enabled?

These are the tests performed by vgic_its_trigger_msi(), so maybe you show make this function return something useful, and propagate the value to userspace instead of blindly returning 1?

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw
In reply to Andre Przywara
Quoted 30 lines · Andre Przywara

According to the KVM API documentation a successful MSI injection should return a value > 0 on success.
Since we pass the return value of vgic_its_inject_msi() directly on to upper layers and userland, we need to use the same semantics here. Briefly tested with QEMU and kvmtool on GICv3 hardware and the model.

---
Applies on top of next-20160728. Let me know if I should use a different base.

Cheers,
Andre.

 virt/kvm/arm/vgic/vgic-its.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/vgic/vgic-its.c +1 -0
index 07411cf..3268250 100644
@@ -468,6 +468,7 @@ static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
  * We then call vgic_its_trigger_msi() with the decoded data.
+ * According to the KVM_SIGNAL_MSI API description returns > 0 on success.
  */
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 {

virt/kvm/arm/vgic/vgic-its.c int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) · line 500

Quoted 8 lines
virt/kvm/arm/vgic/vgic-its.c +1 -1
@@ -493,7 +494,7 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data);
 	mutex_unlock(&iodev->its->its_lock);
 
-	return 0;
+	return 1;
 }
 
 /* Requires the its_lock to be held. */

Do we have a clear understanding of what 'guest blocked the MSI' constitutes in the ARM world?

Thanks,
-Christoffer

#3 lore raw
Quoted 34 lines · Christoffer Dall
Quoted 33 lines · Andre Przywara

According to the KVM API documentation a successful MSI injection should return a value > 0 on success.
Since we pass the return value of vgic_its_inject_msi() directly on to upper layers and userland, we need to use the same semantics here. Briefly tested with QEMU and kvmtool on GICv3 hardware and the model.

---
Applies on top of next-20160728. Let me know if I should use a different base.

Cheers,
Andre.

 virt/kvm/arm/vgic/vgic-its.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/vgic/vgic-its.c +1 -0
index 07411cf..3268250 100644
@@ -468,6 +468,7 @@ static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
  * We then call vgic_its_trigger_msi() with the decoded data.
+ * According to the KVM_SIGNAL_MSI API description returns > 0 on success.
  */
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 {
@@ -493,7 +494,7 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data);
 	mutex_unlock(&iodev->its->its_lock);
 
Quoted 8 lines

virt/kvm/arm/vgic/vgic-its.c int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) · line 500

Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1 -1
-	return 0;
+	return 1;
 }
 
 /* Requires the its_lock to be held. */

Do we have a clear understanding of what 'guest blocked the MSI' constitutes in the ARM world?

I would define it as "the guest has not configured the ITS so that the corresponding LPI could be successfully delivered". Which is any of the conditions where the interrupt cannot make it into the pending table, and is dropped on the floor.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#4 lore raw
Quoted 44 lines · Marc Zyngier
Quoted 34 lines · Christoffer Dall
Quoted 33 lines · Andre Przywara

According to the KVM API documentation a successful MSI injection should return a value > 0 on success.
Since we pass the return value of vgic_its_inject_msi() directly on to upper layers and userland, we need to use the same semantics here. Briefly tested with QEMU and kvmtool on GICv3 hardware and the model.

---
Applies on top of next-20160728. Let me know if I should use a different base.

Cheers,
Andre.

 virt/kvm/arm/vgic/vgic-its.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
virt/kvm/arm/vgic/vgic-its.c +1 -0
index 07411cf..3268250 100644
@@ -468,6 +468,7 @@ static void vgic_its_trigger_msi(struct kvm *kvm, struct vgic_its *its,
  * Queries the KVM IO bus framework to get the ITS pointer from the given
  * doorbell address.
  * We then call vgic_its_trigger_msi() with the decoded data.
+ * According to the KVM_SIGNAL_MSI API description returns > 0 on success.
  */
 int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 {
@@ -493,7 +494,7 @@ int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi)
 	vgic_its_trigger_msi(kvm, iodev->its, msi->devid, msi->data);
 	mutex_unlock(&iodev->its->its_lock);
 
Quoted 8 lines

virt/kvm/arm/vgic/vgic-its.c int vgic_its_inject_msi(struct kvm *kvm, struct kvm_msi *msi) · line 500

Quoted 5 lines
virt/kvm/arm/vgic/vgic-its.c +1 -1
-	return 0;
+	return 1;
 }
 
 /* Requires the its_lock to be held. */

Do we have a clear understanding of what 'guest blocked the MSI' constitutes in the ARM world?

Quoted 5 lines

I would define it as "the guest has not configured the ITS so that the corresponding LPI could be successfully delivered". Which is any of the conditions where the interrupt cannot make it into the pending table, and is dropped on the floor.

sounds good to me.

-Christoffer