]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[pci] Use runtime selectable PCI I/O API for EFI cloud builds
authorMichael Brown <mcb30@ipxe.org>
Mon, 24 Nov 2025 20:27:53 +0000 (20:27 +0000)
committerMichael Brown <mcb30@ipxe.org>
Mon, 24 Nov 2025 23:25:31 +0000 (23:25 +0000)
On some systems (observed on an AWS m8g.medium instance in eu-west-2),
the UEFI firmware omits the PCI host bridge drivers for all but the
first PCI bus.  The observable result is that any devices on other PCI
buses (such as the ENA network device) are not enumerated by the UEFI
firmware and are therefore unusable by iPXE.

Support these systems by switching to using PCIAPI_CLOUD for EFI cloud
builds, trying the EFI PCI I/O API first and falling back to direct
access (via ECAM) for devices that the UEFI firmware has failed to
enumerate itself.

Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/config/cloud/ioapi.h
src/config/config_pci.c
src/include/ipxe/pci_io.h
src/interface/efi/efi_pci.c

index bcd2459814bab13883641b541953bd2d98c9c761..3ab05082fda77c24c665ddc0141a0527400a2a7b 100644 (file)
@@ -8,3 +8,13 @@
 #define PCIAPI_RUNTIME_PCBIOS
 #define PCIAPI_RUNTIME_DIRECT
 #endif
+
+/* Work around missing PCI host bridge drivers in the cut-down UEFI found
+ * in some AWS EC2 instances.
+ */
+#ifdef PLATFORM_efi
+#undef PCIAPI_EFI
+#define PCIAPI_CLOUD
+#define PCIAPI_RUNTIME_EFI
+#define PCIAPI_RUNTIME_ECAM
+#endif
index 8ed9f6603cf5210918f90dc2a0ce3b986bd4df0b..b2adae995e7ca9b6e3777c7e4564bf47a9c9b2d0 100644 (file)
@@ -45,3 +45,6 @@ REQUIRE_OBJECT ( pcibios );
 #ifdef PCIAPI_RUNTIME_DIRECT
 REQUIRE_OBJECT ( pcidirect );
 #endif
+#ifdef PCIAPI_RUNTIME_EFI
+REQUIRE_OBJECT ( efi_pci );
+#endif
index 0d32adf81ed5175824d31c031ff071745cc3adbc..7ac09efb0dd6d4d737e1fac3458155d165ebb27d 100644 (file)
@@ -192,9 +192,10 @@ struct pci_api {
 #endif
 
 /* PCI runtime selectable API priorities */
-#define PCIAPI_PRIORITY_ECAM   01      /**< ACPI ECAM */
-#define PCIAPI_PRIORITY_PCBIOS 02      /**< PCI BIOS calls */
-#define PCIAPI_PRIORITY_DIRECT 03      /**< Direct Type 1 accesses */
+#define PCIAPI_PRIORITY_EFI    01      /**< EFI PCI I/O protocols */
+#define PCIAPI_PRIORITY_ECAM   02      /**< ACPI ECAM */
+#define PCIAPI_PRIORITY_PCBIOS 03      /**< PCI BIOS calls */
+#define PCIAPI_PRIORITY_DIRECT 04      /**< Direct Type 1 accesses */
 
 /** Provide a runtime selectable PCI I/O API */
 #define PROVIDE_PCIAPI_RUNTIME( subsys, priority )                        \
index fbf06300b74c1d8003ad2ab36cf41990a1d79f18..f4853c234ef32b98a102c94629e3131f23bbfb2e 100644 (file)
@@ -436,6 +436,7 @@ PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_byte );
 PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_word );
 PROVIDE_PCIAPI_INLINE ( efi, pci_write_config_dword );
 PROVIDE_PCIAPI ( efi, pci_ioremap, efipci_ioremap );
+PROVIDE_PCIAPI_RUNTIME ( efi, PCIAPI_PRIORITY_EFI );
 
 /******************************************************************************
  *