i2c-imc-skylake: guard branch - verify the ECAM page before trusting it

A miscomputed page would send every engine write to some other
function's config space - the exact failure mode the ECAM path exists
to remove.  Require word 0 to read back as 8086:2085 before using the
mapping; otherwise fall back to config cycles.
This commit is contained in:
Simone
2026-08-09 09:49:08 +02:00
parent 637717dad0
commit 1a897d7d24
+17
View File
@@ -276,6 +276,23 @@ static void __iomem *imc_map_ecam(struct pci_dev *pdev)
}
acpi_put_table(&mcfg->header);
if (!map)
return NULL;
/*
* A wrong page here would make every engine write land on some other
* function - the exact failure mode this path exists to remove.
* Word 0 is the one register whose value is known in advance; require
* it before trusting the mapping with writes.
*/
if (readl(map) != (PCU_DEVICE << 16 | PCI_VENDOR_ID_INTEL)) {
dev_warn(&pdev->dev,
"ECAM page does not identify as %04x:%04x; not using it\n",
PCI_VENDOR_ID_INTEL, PCU_DEVICE);
devm_iounmap(&pdev->dev, map);
return NULL;
}
return map;
}