Skip to contentSkip to conversation

pcie_aer: fix pci_set_long overflow into PCI_EXP_LNKCAP

PATCH New lirongqing 1 participant 1 message Sep 15

lore
Share & tools
lore

lirongqing

author
#0 lore raw

PATCH 1/1 pcie_aer: fix pci_set_long overflow into PCI_EXP_LNKCAP

From: Li RongQing <[email protected]>

pcie_aer_inject_uncor_error() wrote inj->devsta (a uint16_t) into PCI_EXP_DEVSTA using pci_set_long(), which writes 4 bytes. PCI_EXP_DEVSTA is a 16-bit register at offset 0x0a; the extra 2 bytes written by pci_set_long() land at offset 0x0c, the low half of PCI_EXP_LNKCAP, zeroing the link speed/width capability fields on every uncorrectable error injection.

Use pci_set_word() instead, matching the correctable error path in pcie_aer_inject_cor_error().

Fixes 34e65944c0351 ("pcie/aer: helper functions for pcie aer capability")
---
 hw/pci/pcie_aer.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
hw/pci/pcie_aer.c +1 -1
index 22497b1..43b14c1 100644
@@ -589,7 +589,7 @@ static bool pcie_aer_inject_uncor_error(PCIEAERInject *inj, bool is_fatal)
     if (inj->unsupported_request) {
         inj->devsta |= PCI_EXP_DEVSTA_URD;
     }
-    pci_set_long(dev->config + dev->exp.exp_cap + PCI_EXP_DEVSTA, inj->devsta);
+    pci_set_word(dev->config + dev->exp.exp_cap + PCI_EXP_DEVSTA, inj->devsta);
 
     if (inj->aer_cap) {
         uint32_t mask = pci_get_long(inj->aer_cap + PCI_ERR_UNCOR_MASK);
Signature · 1 line
2.9.4