Skip to contentSkip to conversation

PCI: hv: hardwire PCI_INTERRUPT_PIN to 0

PATCH Superseded [email protected] 2 participants 4 messages Sep 13

Subsystems (4)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 PCI: hv: hardwire PCI_INTERRUPT_PIN to 0

From: Mukesh R <[email protected]>

Hyper-V Discrete Device Assignment (DDA) does not support legacy (INTX) interrupts. When PCI_INTERRUPT_PIN is read, the pci-hyperv controller, which captures configuration space accesses, returns 0 to the caller.

However, the current code only captures 8bit read access, thus 16bit/32bit are missed, forwarded to the host/HW, and may yield a non zero value.

This fix addresses this issue, and makes sure that PCI_INTERRUPT_PIN is hardwired to 0, while the other bytes, are those returned by the host/HW.

---
 drivers/pci/controller/pci-hyperv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pci/controller/pci-hyperv.c +10 -0
index 89816a2bd7cd..e6db82413add 100644
@@ -1240,6 +1240,16 @@ 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_PIN is hard-wired to 0, since it
+		 * may be read using a 32bit read, which is skipped by the
+		 * above emulation.
+		 */
+		if (where <= PCI_INTERRUPT_PIN &&
+		    PCI_INTERRUPT_PIN < (where + size))
+			*((char *)val + PCI_INTERRUPT_PIN - where) = 0;
+		}
 	} else {
 		dev_err(dev, "Attempt to read beyond a function's config space.\n");
 	}
Signature · 1 line
2.53.0
#1 lore raw
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider: - [Medium] The patch fails to hard-wire `PCI_INTERRUPT_LINE` to 0 during 16/32-bit reads, introducing…

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The patch fails to hard-wire PCI_INTERRUPT_LINE to 0 during 16/32-bit reads, introducing inconsistent emulation behavior.
- [Medium] Modifying the returned integer via char * pointer arithmetic is broken on big-endian architectures.
- [Low] Extraneous closing brace causes a syntax error and breaks compilation.
--

commit 34dba20e549ad1a394e94eeb91577f3b24614432
Author: Mukesh R <[email protected]>

PCI: hv: hardwire PCI_INTERRUPT_PIN to 0

This commit hardwires PCI_INTERRUPT_PIN to 0 for Hyper-V Discrete Device Assignment, as it does not support legacy (INTx) interrupts. It addresses an issue where 16-bit or 32-bit reads miss the previous 8-bit emulation and yield non-zero values.

Quoted 6 lines
drivers/pci/controller/pci-hyperv.c +0 -0
index 89816a2bd7cd3..e6db82413addb 100644
@@ -1240,6 +1240,16 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
 			mb();

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1250

Quoted 10 lines
drivers/pci/controller/pci-hyperv.c +8 -0
 		}
 		spin_unlock_irqrestore(&hbus->config_lock, flags);
+
+		/*
+		 * Make sure PCI_INTERRUPT_PIN is hard-wired to 0, since it
+		 * may be read using a 32bit read, which is skipped by the
+		 * above emulation.
+		 */
+		if (where <= PCI_INTERRUPT_PIN &&
+		    PCI_INTERRUPT_PIN < (where + size))

[Severity: Medium]
Does this logic miss PCI_INTERRUPT_LINE?

The previous emulation blocks in _hv_pcifront_read_config() explicitly hard-wire the 8-bit read of PCI_INTERRUPT_LINE to 0.

It seems a 16-bit or 32-bit config read encompassing PCI_INTERRUPT_LINE would leak the hardware's non-zero value, violating the design intent to hide legacy interrupts.

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1251

Quoted 1 line
drivers/pci/controller/pci-hyperv.c +1 -0
+			*((char *)val + PCI_INTERRUPT_PIN - where) = 0;

[Severity: Medium]
Will modifying the returned integer via char * pointer arithmetic work on big-endian architectures?

For a 32-bit read on big-endian systems, casting a u32 * to char * and indexing by byte offset modifies the wrong byte in memory.

This could fail to clear PCI_INTERRUPT_PIN and might accidentally zero another byte like PCI_MIN_GNT.

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1252

Quoted 1 line
drivers/pci/controller/pci-hyperv.c +1 -0
+		}

[Severity: Low]
Could this extraneous closing brace cause a compilation failure?

It doesn't appear to match any opening brace in the added block, which would break the block structure and lead to a syntax error.

Quoted 3 lines
drivers/pci/controller/pci-hyperv.c +0 -0
 	} else {
 		dev_err(dev, "Attempt to read beyond a function's config space.\n");
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#2 lore raw
Quoted 36 lines · On Sun, Sep 13, 2026 at 10:19:39PM +0000, [email protected] wrote:

Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
- [Medium] The patch fails to hard-wire PCI_INTERRUPT_LINE to 0 during 16/32-bit reads, introducing inconsistent emulation behavior.
- [Medium] Modifying the returned integer via char * pointer arithmetic is broken on big-endian architectures.
- [Low] Extraneous closing brace causes a syntax error and breaks compilation.
--

commit 34dba20e549ad1a394e94eeb91577f3b24614432
Author: Mukesh R <[email protected]>

PCI: hv: hardwire PCI_INTERRUPT_PIN to 0

This commit hardwires PCI_INTERRUPT_PIN to 0 for Hyper-V Discrete Device Assignment, as it does not support legacy (INTx) interrupts. It addresses an issue where 16-bit or 32-bit reads miss the previous 8-bit emulation and yield non-zero values.

Quoted 6 lines
drivers/pci/controller/pci-hyperv.c +0 -0
index 89816a2bd7cd3..e6db82413addb 100644
@@ -1240,6 +1240,16 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
 			mb();

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1250

Quoted 10 lines
drivers/pci/controller/pci-hyperv.c +8 -0
 		}
 		spin_unlock_irqrestore(&hbus->config_lock, flags);
+
+		/*
+		 * Make sure PCI_INTERRUPT_PIN is hard-wired to 0, since it
+		 * may be read using a 32bit read, which is skipped by the
+		 * above emulation.
+		 */
+		if (where <= PCI_INTERRUPT_PIN &&
+		    PCI_INTERRUPT_PIN < (where + size))

[Severity: Medium]
Does this logic miss PCI_INTERRUPT_LINE?

Quoted 7 lines

The previous emulation blocks in _hv_pcifront_read_config() explicitly hard-wire the 8-bit read of PCI_INTERRUPT_LINE to 0.

It seems a 16-bit or 32-bit config read encompassing PCI_INTERRUPT_LINE would leak the hardware's non-zero value, violating the design intent to hide legacy interrupts.

We have not seen this in practice.

Quoted 6 lines

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1251

Quoted 1 line
drivers/pci/controller/pci-hyperv.c +1 -0
+			*((char *)val + PCI_INTERRUPT_PIN - where) = 0;

[Severity: Medium]
Will modifying the returned integer via char * pointer arithmetic work on big-endian architectures?

We don't support big-endian.

Quoted 8 lines

For a 32-bit read on big-endian systems, casting a u32 * to char * and indexing by byte offset modifies the wrong byte in memory.

This could fail to clear PCI_INTERRUPT_PIN and might accidentally zero another byte like PCI_MIN_GNT.

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1252

Quoted 1 line
drivers/pci/controller/pci-hyperv.c +1 -0
+		}

Oops. I had somehow deleted the opening brace when cleaning up the patch.

A new version will be sent out.

Wei

Quoted 12 lines

[Severity: Low]
Could this extraneous closing brace cause a compilation failure?

It doesn't appear to match any opening brace in the added block, which would break the block structure and lead to a syntax error.

Quoted 3 lines
drivers/pci/controller/pci-hyperv.c +0 -0
 	} else {
 		dev_err(dev, "Attempt to read beyond a function's config space.\n");
 	}
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
author maintainer
#3 lore raw
In reply to [email protected]
Quoted 27 lines · On Sun, Sep 13, 2026 at 03:10:39PM -0700, [email protected] wrote:

From: Mukesh R <[email protected]>

Hyper-V Discrete Device Assignment (DDA) does not support legacy (INTX) interrupts. When PCI_INTERRUPT_PIN is read, the pci-hyperv controller, which captures configuration space accesses, returns 0 to the caller.

However, the current code only captures 8bit read access, thus 16bit/32bit are missed, forwarded to the host/HW, and may yield a non zero value.

This fix addresses this issue, and makes sure that PCI_INTERRUPT_PIN is hardwired to 0, while the other bytes, are those returned by the host/HW.

---
 drivers/pci/controller/pci-hyperv.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/pci/controller/pci-hyperv.c +0 -0
index 89816a2bd7cd..e6db82413add 100644
@@ -1240,6 +1240,16 @@ static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where,
 			mb();
 		}
 		spin_unlock_irqrestore(&hbus->config_lock, flags);

drivers/pci/controller/pci-hyperv.c static void _hv_pcifront_read_config(struct hv_pci_dev *hpdev, int where, · line 1252

Quoted 10 lines
drivers/pci/controller/pci-hyperv.c +10 -0
+
+		/*
+		 * Make sure PCI_INTERRUPT_PIN is hard-wired to 0, since it
+		 * may be read using a 32bit read, which is skipped by the
+		 * above emulation.
+		 */
+		if (where <= PCI_INTERRUPT_PIN &&
+		    PCI_INTERRUPT_PIN < (where + size))
+			*((char *)val + PCI_INTERRUPT_PIN - where) = 0;
+		}

Please ignore this version. A new version will be sent out to add back the opening brace.

Wei

Quoted 6 lines
drivers/pci/controller/pci-hyperv.c +0 -0
 	} else {
 		dev_err(dev, "Attempt to read beyond a function's config space.\n");
 	}
Signature · 1 line
2.53.0