Skip to contentSkip to conversation

KVM: arm/arm64: GICv4: Do not perform a map to a mapped vLPI

PATCH Superseded Kunkun Jiang 2 participants 3 messages Nov 19, 2023 – Nov 20, 2023

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 KVM: arm/arm64: GICv4: Do not perform a map to a mapped vLPI

Before performing a map, let's check whether the vLPI has been mapped. This corresponds to checking whether a vLPI is valid before unmap it.

Fixes 196b136498b3 ("KVM: arm/arm64: GICv4: Wire mapping/unmapping of VLPIs in VFIO irq bypass")
---
 arch/arm64/kvm/vgic/vgic-v4.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kvm/vgic/vgic-v4.c +5 -0
index 339a55194b2c..fb60bbb94460 100644
@@ -436,6 +436,11 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, int virq,
 	if (ret)
 		goto out;
 
+	if (irq->hw) {
+		ret = 0;
+		goto out;
+	}
+
 	/*
 	 * Emit the mapping request. If it fails, the ITS probably
 	 * isn't v4 compatible, so let's silently bail out. Holding
Signature · 1 line
2.33.0
maintainer Acked-by on v2 1/1
#1 lore raw
Quoted 3 lines · Kunkun Jiang

Before performing a map, let's check whether the vLPI has been mapped. This corresponds to checking whether a vLPI is valid before unmap it.

I don't understand this last sentence. Mapping and unmapping are two different actions, and we shouldn't conflate them.

Quoted 13 lines
Fixes 196b136498b3 ("KVM: arm/arm64: GICv4: Wire mapping/unmapping of

VLPIs in VFIO irq bypass")

---
 arch/arm64/kvm/vgic/vgic-v4.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/arm64/kvm/vgic/vgic-v4.c +0 -0
index 339a55194b2c..fb60bbb94460 100644

arch/arm64/kvm/vgic/vgic-v4.c int kvm_vgic_v4_set_forwarding(struct kvm *kvm, · line 441

Quoted 6 lines
arch/arm64/kvm/vgic/vgic-v4.c +2 -0
@@ -436,6 +436,11 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, 
 int virq,
 	if (ret)
 		goto out;
 
+	if (irq->hw) {
+		ret = 0;

ret is obviously already 0.

Quoted 6 lines
arch/arm64/kvm/vgic/vgic-v4.c +3 -0
+		goto out;
+	}
+
 	/*
 	 * Emit the mapping request. If it fails, the ITS probably

* isn't v4 compatible, so let's silently bail out. Holding

Furthermore, this really deserves a comment. Something like:

/* Silently exit if the vLPI is already mapped */

With these changes:

Oliver, can you please apply these changes and queue it as a fix for 6.7?

Thanks,

        M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#2 lore raw

Hi Marc,Oliver,

Quoted 39 lines · Marc Zyngier
Quoted 3 lines · Kunkun Jiang

Before performing a map, let's check whether the vLPI has been mapped. This corresponds to checking whether a vLPI is valid before unmap it.

I don't understand this last sentence. Mapping and unmapping are two different actions, and we shouldn't conflate them.

Quoted 13 lines
Fixes 196b136498b3 ("KVM: arm/arm64: GICv4: Wire mapping/unmapping of

VLPIs in VFIO irq bypass")

---
 arch/arm64/kvm/vgic/vgic-v4.c | 5 +++++

 1 file changed, 5 insertions(+)
arch/arm64/kvm/vgic/vgic-v4.c +0 -0
index 339a55194b2c..fb60bbb94460 100644

arch/arm64/kvm/vgic/vgic-v4.c int kvm_vgic_v4_set_forwarding(struct kvm *kvm, · line 441

Quoted 6 lines
arch/arm64/kvm/vgic/vgic-v4.c +2 -0
@@ -436,6 +436,11 @@ int kvm_vgic_v4_set_forwarding(struct kvm *kvm, 
 int virq,
      if (ret)
          goto out;
 
+    if (irq->hw) {
+        ret = 0;

ret is obviously already 0.

Quoted 6 lines
arch/arm64/kvm/vgic/vgic-v4.c +3 -0
+        goto out;
+    }
+
      /*
       * Emit the mapping request. If it fails, the ITS probably

      * isn't v4 compatible, so let's silently bail out. Holding

Furthermore, this really deserves a comment. Something like:

Quoted 9 lines

/* Silently exit if the vLPI is already mapped */

With these changes:

Oliver, can you please apply these changes and queue it as a fix for 6.7?

Thank you for your careful review. I just sent the v3 and applied these changes.
https://lore.kernel.org/kvmarm/[email protected]/

Thanks,
Kunkun Jiang

Quoted 3 lines

Thanks,

        M.