When a PCI bridge is not enabled, the secondary bus may still be zero.
This causes an infinite recursive call to enumerate bus 0 which results
in a stack overflow.  The easy fix is to have PciDevicePresent return
EFI_NOT_FOUND for devices which are not enabled either for memory or I/O
accesses.

TEST=Build and run CorebootPayloadPkg on Quark/Galileo Gen2

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Lee Leahy <[email protected]>
---
 DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c 
b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
index 80b2b6b..648d17c 100644
--- a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
+++ b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
@@ -166,7 +166,14 @@ Returns:
                                     Pci
                                     );
 
-    return EFI_SUCCESS;
+    //
+    // Only return success if the device is enabled
+    //
+    if (Pci->Hdr.Command & (EFI_PCI_COMMAND_IO_SPACE
+      | EFI_PCI_COMMAND_MEMORY_SPACE)) {
+
+      return EFI_SUCCESS;
+    }
   }
 
   return EFI_NOT_FOUND;
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to