From: Michael Brown Date: Thu, 2 Nov 2023 15:05:15 +0000 (+0000) Subject: [pci] Handle non-zero starting bus in ECAM allocations X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74ec00a9f336152fccf8df9cc9c5a46ab1a649b4;p=thirdparty%2Fipxe.git [pci] Handle non-zero starting bus in ECAM allocations The base address provided in the PCI ECAM allocation within the ACPI MCFG table is the base address for the segment as a whole, not for the starting bus within that allocation. On machines that provide ECAM allocations with a non-zero starting bus number (observed with an AWS EC2 m7a.large instance), this will result in iPXE accessing the wrong memory addresses within the ECAM region. Fix by adding the appropriate starting bus offset to the base address. Signed-off-by: Michael Brown --- diff --git a/src/drivers/bus/ecam.c b/src/drivers/bus/ecam.c index 376f34957..dd3e1e514 100644 --- a/src/drivers/bus/ecam.c +++ b/src/drivers/bus/ecam.c @@ -150,6 +150,7 @@ static int ecam_access ( struct pci_device *pci ) { /* Map configuration space for this allocation */ base = le64_to_cpu ( ecam.alloc.base ); + base += ( ecam.alloc.start * ECAM_SIZE * PCI_BUSDEVFN ( 0, 1, 0, 0 ) ); len = ( ecam.range.count * ECAM_SIZE ); ecam.regs = ioremap ( base, len ); if ( ! ecam.regs ) {