MdeModulePkg: PciHostBridgeDxe: don't assume extended config space
authorLaszlo Ersek <lersek@redhat.com>
Fri, 26 Feb 2016 22:09:46 +0000 (23:09 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Thu, 3 Mar 2016 09:00:24 +0000 (10:00 +0100)
The "pc" ("pc-i440fx-*") machine types of QEMU don't support extended
config space. Accordingly, OVMF will use the following library instances
in connection with the core PciHostBridgeDxe driver:

  BasePciSegmentLibPci [class: PciSegmentLib]
    BasePciLibCf8      [class: PciLib]
      BasePciCf8Lib    [class: PciCf8Lib]

Add a new field to the PCI_ROOT_BRIDGE structure so that
RootBridgeIoCheckParameter() can catch config space offsets above 0xFF on
such old (emulated) platforms.

Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Marcel Apfelbaum <marcel@redhat.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Michael Kinney <michael.d.kinney@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Marcel Apfelbaum <marcel@redhat.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridge.h
MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
MdeModulePkg/Include/Library/PciHostBridgeLib.h

index b1e83f1c9089f4f703101eb14b6738aea4543a77..aa3f43a511c4f5b2eaa461f478d7ec914daa79a4 100644 (file)
@@ -72,6 +72,7 @@ typedef struct {
   PCI_ROOT_BRIDGE_APERTURE          MemAbove4G;\r
   PCI_ROOT_BRIDGE_APERTURE          PMemAbove4G;\r
   BOOLEAN                           DmaAbove4G;\r
+  BOOLEAN                           NoExtendedConfigSpace;\r
   VOID                              *ConfigBuffer;\r
   EFI_DEVICE_PATH_PROTOCOL          *DevicePath;\r
   CHAR16                            *DevicePathStr;\r
index 932aefd5d621fe8593f2981240b3589a4a8e5b6c..cda9b49b39258cf895796f33f172e6fdd631f49a 100644 (file)
@@ -80,6 +80,7 @@ CreateRootBridge (
   DEBUG ((EFI_D_INFO, "%s\n", DevicePathStr = ConvertDevicePathToText (Bridge->DevicePath, FALSE, FALSE)));\r
   DEBUG ((EFI_D_INFO, "  Support/Attr: %lx / %lx\n", Bridge->Supports, Bridge->Attributes));\r
   DEBUG ((EFI_D_INFO, "    DmaAbove4G: %s\n", Bridge->DmaAbove4G ? L"Yes" : L"No"));\r
+  DEBUG ((EFI_D_INFO, "NoExtConfSpace: %s\n", Bridge->NoExtendedConfigSpace ? L"Yes" : L"No"));\r
   DEBUG ((EFI_D_INFO, "     AllocAttr: %lx (%s%s)\n", Bridge->AllocationAttributes,\r
           (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM) != 0 ? L"CombineMemPMem " : L"",\r
           (Bridge->AllocationAttributes & EFI_PCI_HOST_BRIDGE_MEM64_DECODE) != 0 ? L"Mem64Decode" : L""\r
@@ -155,6 +156,7 @@ CreateRootBridge (
   RootBridge->Supports = Bridge->Supports;\r
   RootBridge->Attributes = Bridge->Attributes;\r
   RootBridge->DmaAbove4G = Bridge->DmaAbove4G;\r
+  RootBridge->NoExtendedConfigSpace = Bridge->NoExtendedConfigSpace;\r
   RootBridge->AllocationAttributes = Bridge->AllocationAttributes;\r
   RootBridge->DevicePath = DuplicateDevicePath (Bridge->DevicePath);\r
   RootBridge->DevicePathStr = DevicePathStr;\r
@@ -351,7 +353,7 @@ RootBridgeIoCheckParameter (
       Address = PciRbAddr->Register;\r
     }\r
     Base = 0;\r
-    Limit = 0xFFF;\r
+    Limit = RootBridge->NoExtendedConfigSpace ? 0xFF : 0xFFF;\r
   }\r
 \r
   if (Address < Base) {\r
index 16ad104a9368a7511e03cf7be2603437165be085..b67ac5e17d48bfb91b8630458aab2e45fb8466e4 100644 (file)
@@ -34,6 +34,10 @@ typedef struct {
                                                   ///< and SetAttributes() in EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL.\r
   BOOLEAN                  DmaAbove4G;            ///< DMA above 4GB memory.\r
                                                   ///< Set to TRUE when root bridge supports DMA above 4GB memory.\r
+  BOOLEAN                  NoExtendedConfigSpace; ///< When FALSE, the root bridge supports\r
+                                                  ///< Extended (4096-byte) Configuration Space.\r
+                                                  ///< When TRUE, the root bridge supports\r
+                                                  ///< 256-byte Configuration Space only.\r
   UINT64                   AllocationAttributes;  ///< Allocation attributes.\r
                                                   ///< Refer to EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM and\r
                                                   ///< EFI_PCI_HOST_BRIDGE_MEM64_DECODE used by GetAllocAttributes()\r