Skip to contentSkip to conversation

PCI: hv: Use nested hypercall for retargeting interrupts

PATCH Applied Jinank Jain 4 participants 7 messages Apr 4, 2023 – Apr 13, 2023

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: hv: Use nested hypercall for retargeting interrupts

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

---
 drivers/pci/controller/pci-hyperv.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +8 -2
index f33370b75628..2123f632ecf7 100644
@@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data)
 		}
 	}
 
-	res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17),
-			      params, NULL);
+	if (hv_nested)
+		res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT |
+					     (var_size << 17),
+					     params, NULL);
+	else
+		res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT |
+				      (var_size << 17),
+				      params, NULL);
 
 exit_unlock:
 	spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 29 lines · Jinank Jain

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

---
 drivers/pci/controller/pci-hyperv.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +8 -2
index f33370b75628..2123f632ecf7 100644
@@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data)
 		}
 	}
 
-	res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17),
-			      params, NULL);
+	if (hv_nested)
+		res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT |
+					     (var_size << 17),
+					     params, NULL);
+	else
+		res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT |
+				      (var_size << 17),
+				      params, NULL);
 
 exit_unlock:
 	spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);
maintainer
#2 lore raw
In reply to Jinank Jain
Quoted 4 lines · Jinank Jain

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

While I think this is a sensible change -- how did you discover this? Can you provide a bit more information?

Quoted 28 lines
---
 drivers/pci/controller/pci-hyperv.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +8 -2
index f33370b75628..2123f632ecf7 100644
@@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data)
 		}
 	}
 
-	res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17),
-			      params, NULL);
+	if (hv_nested)
+		res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT |
+					     (var_size << 17),
+					     params, NULL);
+	else
+		res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT |
+				      (var_size << 17),
+				      params, NULL);
 
 exit_unlock:
 	spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);
Signature · 1 line
2.34.1
#3 lore raw

This was observed while testing pass-through PCI devices on the nested MSHV setup.

Regards,

Jinank

Quoted 36 lines · Wei Liu
Quoted 4 lines · Jinank Jain

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

While I think this is a sensible change -- how did you discover this? Can you provide a bit more information?

Quoted 28 lines
---
  drivers/pci/controller/pci-hyperv.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)
drivers/pci/controller/pci-hyperv.c +8 -2
index f33370b75628..2123f632ecf7 100644
@@ -704,8 +704,14 @@ static void hv_arch_irq_unmask(struct irq_data *data)
  		}
  	}
 
-	res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT | (var_size << 17),
-			      params, NULL);
+	if (hv_nested)
+		res = hv_do_nested_hypercall(HVCALL_RETARGET_INTERRUPT |
+					     (var_size << 17),
+					     params, NULL);
+	else
+		res = hv_do_hypercall(HVCALL_RETARGET_INTERRUPT |
+				      (var_size << 17),
+				      params, NULL);
 
  exit_unlock:
  	spin_unlock_irqrestore(&hbus->retarget_msi_interrupt_lock, flags);
Signature · 1 line
2.34.1
#5 lore raw

From: Wei Liu <[email protected]> Sent: Wednesday, April 12, 2023 6:23 PM

Quoted 8 lines · Jinank Jain
Quoted 4 lines

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

Applied to hyperv-next. Thanks.

I'd like to hold off on taking this change. Nuno and I are discussing how best to handle nested hypercalls. In addition to the proposed nested changes, we have hypercall changes coming as part of the TDX and fully enlightened SNP patch sets. If possible, I'd like to avoid adding logic at the hv_do_hypercall() call sites. It's not clear whether avoiding such logic will really be feasible, but I'd like to think about it for a bit before reaching that conclusion.

Michael

maintainer
#6 lore raw
Quoted 10 lines · Michael Kelley (LINUX)

From: Wei Liu <[email protected]> Sent: Wednesday, April 12, 2023 6:23 PM

Quoted 8 lines · Jinank Jain
Quoted 4 lines

In case of nested MSHV, retargeting interrupt hypercall should be sent to L0 hypervisor instead of L1 hypervisor.

Applied to hyperv-next. Thanks.

Quoted 7 lines

I'd like to hold off on taking this change. Nuno and I are discussing how best to handle nested hypercalls. In addition to the proposed nested changes, we have hypercall changes coming as part of the TDX and fully enlightened SNP patch sets. If possible, I'd like to avoid adding logic at the hv_do_hypercall() call sites. It's not clear whether avoiding such logic will really be feasible, but I'd like to think about it for a bit before reaching that conclusion.

I thought that discussion will go on for a while but this patch fixed a real bug.

Holding off is fine too. I will remove this patch from hyperv-next.

Thanks,
Wei.

Quoted 3 lines

Michael