Linux-HyperV List
 help / color / mirror / Atom feed
* [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0
@ 2026-12-02 14:43 Hamza Mahfooz
  2026-12-02 21:06 ` Laurence Oberman
  0 siblings, 1 reply; 2+ messages in thread
From: Hamza Mahfooz @ 2026-12-02 14:43 UTC (permalink / raw)
  To: linux-hyperv
  Cc: Haiyang Zhang, Wei Liu, Dexuan Cui, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
	Bjorn Helgaas, Jake Oshins, linux-pci, Michael Kelley,
	Laurence Oberman, Hamza Mahfooz, stable, Asher Kariv, Mukesh R

Hyper-V Discrete Device Assignment (DDA) does not support legacy (INTx)
interrupts.

The current code recognizes PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN
reads and forces a zero value, but only for 8 bit reads. If a 16 or 32
bit read overlaps these fields, they may be returned as a non-zero
value. Fix this by recognizing such overlap, and forcing the
PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN bytes to zero while retaining
the adjacent bytes returned by the host/HW.

Cc: stable@vger.kernel.org
Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for Microsoft Hyper-V VMs")
Co-developed-by: Asher Kariv <askariv@microsoft.com>
Signed-off-by: Asher Kariv <askariv@microsoft.com>
Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
Signed-off-by: Wei Liu <wei.liu@kernel.org>
Signed-off-by: Hamza Mahfooz <hamza@kernel.org>
---
v2:
- Fix a compilation error
v3:
- Capitalize "Hardwire" in the subject. (Michael)
- Add description/comment clarifications. (Michael)
- Also hardwire PCI_INTERRUPT_LINE to 0 for 16 and 32 bit reads. (Michael)
- Emulate 16 bit reads of PCI_INTERRUPT_LINE/PCI_INTERRUPT_PIN, and clear
  the low 16 bits of 32 bit reads instead of writing through a char
  pointer.
---
 drivers/pci/controller/pci-hyperv.c | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c
index 824cf27e85e6..05a528df7a51 100644
--- a/drivers/pci/controller/pci-hyperv.c
+++ b/drivers/pci/controller/pci-hyperv.c
@@ -1213,8 +1213,7 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
 		   PCI_CAPABILITY_LIST) {
 		/* ROM BARs are unimplemented */
 		*val = 0;
-	} else if ((where >= PCI_INTERRUPT_LINE && where + size <= PCI_INTERRUPT_PIN) ||
-		   (where >= PCI_INTERRUPT_PIN && where + size <= PCI_MIN_GNT)) {
+	} else if (where >= PCI_INTERRUPT_LINE && where + size <= PCI_MIN_GNT) {
 		/*
 		 * Interrupt Line and Interrupt PIN are hard-wired to zero
 		 * because this front-end only supports message-signaled
@@ -1256,6 +1255,14 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
 			mb();
 		}
 		spin_unlock_irqrestore(&hbus->config_lock, flags);
+
+		/*
+		 * Make sure PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN are
+		 * hard-wired to 0, since they may be included in a 32 bit
+		 * read, which is skipped by the above emulation.
+		 */
+		if (where == PCI_INTERRUPT_LINE)
+			*val &= ~0xffff;
 	} else {
 		dev_err(dev, "Attempt to read beyond a function's config space.\n");
 	}
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0
  2026-12-02 14:43 [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0 Hamza Mahfooz
@ 2026-12-02 21:06 ` Laurence Oberman
  0 siblings, 0 replies; 2+ messages in thread
From: Laurence Oberman @ 2026-12-02 21:06 UTC (permalink / raw)
  To: Hamza Mahfooz, linux-hyperv
  Cc: Haiyang Zhang, Wei Liu, Dexuan Cui, Lorenzo Pieralisi,
	Krzysztof Wilczyński, Manivannan Sadhasivam, Rob Herring,
	Bjorn Helgaas, Jake Oshins, linux-pci, Michael Kelley, stable,
	Asher Kariv, Mukesh R, njavali, GR-QLogic-Storage-Upstream,
	linux-scsi

On Wed, 2026-12-02 at 09:43 -0500, Hamza Mahfooz wrote:
> Hyper-V Discrete Device Assignment (DDA) does not support legacy
> (INTx)
> interrupts.
> 
> The current code recognizes PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN
> reads and forces a zero value, but only for 8 bit reads. If a 16 or
> 32
> bit read overlaps these fields, they may be returned as a non-zero
> value. Fix this by recognizing such overlap, and forcing the
> PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN bytes to zero while
> retaining
> the adjacent bytes returned by the host/HW.
> 
> Cc: stable@vger.kernel.org
> Fixes: 4daace0d8ce8 ("PCI: hv: Add paravirtual PCI front-end for
> Microsoft Hyper-V VMs")
> Co-developed-by: Asher Kariv <askariv@microsoft.com>
> Signed-off-by: Asher Kariv <askariv@microsoft.com>
> Signed-off-by: Mukesh R <mrathor@linux.microsoft.com>
> Signed-off-by: Wei Liu <wei.liu@kernel.org>
> Signed-off-by: Hamza Mahfooz <hamza@kernel.org>
> ---
> v2:
> - Fix a compilation error
> v3:
> - Capitalize "Hardwire" in the subject. (Michael)
> - Add description/comment clarifications. (Michael)
> - Also hardwire PCI_INTERRUPT_LINE to 0 for 16 and 32 bit reads.
> (Michael)
> - Emulate 16 bit reads of PCI_INTERRUPT_LINE/PCI_INTERRUPT_PIN, and
> clear
>   the low 16 bits of 32 bit reads instead of writing through a char
>   pointer.
> ---
>  drivers/pci/controller/pci-hyperv.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/controller/pci-hyperv.c
> b/drivers/pci/controller/pci-hyperv.c
> index 824cf27e85e6..05a528df7a51 100644
> --- a/drivers/pci/controller/pci-hyperv.c
> +++ b/drivers/pci/controller/pci-hyperv.c
> @@ -1213,8 +1213,7 @@ static void _hv_pcifront_read_config(struct
> hv_pci_dev *hpdev, int where,
>  		   PCI_CAPABILITY_LIST) {
>  		/* ROM BARs are unimplemented */
>  		*val = 0;
> -	} else if ((where >= PCI_INTERRUPT_LINE && where + size <=
> PCI_INTERRUPT_PIN) ||
> -		   (where >= PCI_INTERRUPT_PIN && where + size <=
> PCI_MIN_GNT)) {
> +	} else if (where >= PCI_INTERRUPT_LINE && where + size <=
> PCI_MIN_GNT) {
>  		/*
>  		 * Interrupt Line and Interrupt PIN are hard-wired
> to zero
>  		 * because this front-end only supports message-
> signaled
> @@ -1256,6 +1255,14 @@ static void _hv_pcifront_read_config(struct
> hv_pci_dev *hpdev, int where,
>  			mb();
>  		}
>  		spin_unlock_irqrestore(&hbus->config_lock, flags);
> +
> +		/*
> +		 * Make sure PCI_INTERRUPT_LINE and
> PCI_INTERRUPT_PIN are
> +		 * hard-wired to 0, since they may be included in a
> 32 bit
> +		 * read, which is skipped by the above emulation.
> +		 */
> +		if (where == PCI_INTERRUPT_LINE)
> +			*val &= ~0xffff;
>  	} else {
>  		dev_err(dev, "Attempt to read beyond a function's
> config space.\n");
>  	}
Hi Hamza,

No objection to this change.

For the record, it affects qla2xxx under DDA. The driver uses
PCI_INTERRUPT_PIN to identify the physical port of a multi-port HBA,
which selects that port's NVRAM and WWPN. With the pin reading 0 and
every function presented as function 0, all ports get port 0's WWPN.
I described this earlier in [1].

Nilesh (Marvell, Cc'd) has a qla2xxx fix that reads the physical port
from the ISP control/status register in the HBA's MMIO space instead of
from PCI config space, so it is not affected by this patch. I tested it
today on an ISP2281 with the DDA conditions simulated (pin and function
forced to 0): with the fix each port gets its own WWPN; without it both
ports report port 0's WWPN and the second port never comes up on the
fabric. Nilesh will post it to linux-scsi.

Since this patch is tagged for stable, the qla2xxx fix should go to
stable as well. Otherwise multi-port QLogic HBAs in DDA guests on
stable kernels will end up with duplicate WWPNs.

[1] https://lore.kernel.org/linux-hyperv/<your RFC message-id>/

Thanks,
Laurence

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 14:43 [PATCH v3] PCI: hv: Hardwire PCI_INTERRUPT_LINE and PCI_INTERRUPT_PIN to 0 Hamza Mahfooz
2026-12-02 21:06 ` Laurence Oberman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox