]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/XenSupport: remove usage of prefetchable PCI host bridge aperture
authorIgor Druzhinin <igor.druzhinin@citrix.com>
Thu, 25 Apr 2019 20:23:56 +0000 (21:23 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 30 Apr 2019 16:41:57 +0000 (18:41 +0200)
This aperture doesn't exist in QEMU-XEN and hvmloader places BARs
in arbitrary order disregarding prefetchable bit. This makes
prefetchable and non-prefetchable BARs to follow each other that's
quite likely with PCI passthrough devices. In that case, the existing
code, that tries to work out aperture boundaries by reading hvmloader
BAR placement, will report a bogus prefetchable aperture which overlaps
with the regular one. It will eventually trigger an assertion in
DXE PCI initialization code.

Do the same thing as OVMF on QEMU-KVM and pass a non-existing aperture
there. It's not necessary to pass additional allocation flags as we set
ResourceAssigned flag on the root bridge which means they will be ignored.

Reviewed-by: Anthony PERARD <anthony.perard@citrix.com>
Signed-off-by: Igor Druzhinin <igor.druzhinin@citrix.com>
OvmfPkg/Library/PciHostBridgeLib/XenSupport.c

index afb2c5e204792968c5caf68d9c9b05e652c7dae1..354b0a5e275fbeea84445435b2830c38264300a1 100644 (file)
@@ -60,9 +60,7 @@ PcatPciRootBridgeParseBars (
   IN UINTN                          BarOffsetEnd,\r
   IN PCI_ROOT_BRIDGE_APERTURE       *Io,\r
   IN PCI_ROOT_BRIDGE_APERTURE       *Mem,\r
-  IN PCI_ROOT_BRIDGE_APERTURE       *MemAbove4G,\r
-  IN PCI_ROOT_BRIDGE_APERTURE       *PMem,\r
-  IN PCI_ROOT_BRIDGE_APERTURE       *PMemAbove4G\r
+  IN PCI_ROOT_BRIDGE_APERTURE       *MemAbove4G\r
 \r
 )\r
 {\r
@@ -123,11 +121,7 @@ PcatPciRootBridgeParseBars (
           //\r
           Length = ((~Length) + 1) & 0xffffffff;\r
 \r
-          if ((Value & BIT3) == BIT3) {\r
-            MemAperture = PMem;\r
-          } else {\r
-            MemAperture = Mem;\r
-          }\r
+          MemAperture = Mem;\r
         } else {\r
           //\r
           // 64bit\r
@@ -143,11 +137,7 @@ PcatPciRootBridgeParseBars (
           Length = Length | LShiftU64 ((UINT64) UpperValue, 32);\r
           Length = (~Length) + 1;\r
 \r
-          if ((Value & BIT3) == BIT3) {\r
-            MemAperture = PMemAbove4G;\r
-          } else {\r
-            MemAperture = MemAbove4G;\r
-          }\r
+          MemAperture = MemAbove4G;\r
         }\r
 \r
         Limit = Base + Length - 1;\r
@@ -164,6 +154,8 @@ PcatPciRootBridgeParseBars (
   }\r
 }\r
 \r
+STATIC PCI_ROOT_BRIDGE_APERTURE mNonExistAperture = { MAX_UINT64, 0 };\r
+\r
 PCI_ROOT_BRIDGE *\r
 ScanForRootBridges (\r
   UINTN      *NumberOfRootBridges\r
@@ -180,7 +172,7 @@ ScanForRootBridges (
   UINT64     Base;\r
   UINT64     Limit;\r
   UINT64     Value;\r
-  PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, PMem, PMemAbove4G, *MemAperture;\r
+  PCI_ROOT_BRIDGE_APERTURE Io, Mem, MemAbove4G, *MemAperture;\r
   PCI_ROOT_BRIDGE *RootBridges;\r
   UINTN      BarOffsetEnd;\r
 \r
@@ -200,9 +192,7 @@ ScanForRootBridges (
     ZeroMem (&Io, sizeof (Io));\r
     ZeroMem (&Mem, sizeof (Mem));\r
     ZeroMem (&MemAbove4G, sizeof (MemAbove4G));\r
-    ZeroMem (&PMem, sizeof (PMem));\r
-    ZeroMem (&PMemAbove4G, sizeof (PMemAbove4G));\r
-    Io.Base = Mem.Base = MemAbove4G.Base = PMem.Base = PMemAbove4G.Base = MAX_UINT64;\r
+    Io.Base = Mem.Base = MemAbove4G.Base = MAX_UINT64;\r
     //\r
     // Scan all the PCI devices on the primary bus of the PCI root bridge\r
     //\r
@@ -307,16 +297,17 @@ ScanForRootBridges (
 \r
           //\r
           // Get the Prefetchable Memory range that the PPB is decoding\r
+          // and merge it into Memory range\r
           //\r
           Value = Pci.Bridge.PrefetchableMemoryBase & 0x0f;\r
           Base = ((UINT32) Pci.Bridge.PrefetchableMemoryBase & 0xfff0) << 16;\r
           Limit = (((UINT32) Pci.Bridge.PrefetchableMemoryLimit & 0xfff0)\r
                    << 16) | 0xfffff;\r
-          MemAperture = &PMem;\r
+          MemAperture = &Mem;\r
           if (Value == BIT0) {\r
             Base |= LShiftU64 (Pci.Bridge.PrefetchableBaseUpper32, 32);\r
             Limit |= LShiftU64 (Pci.Bridge.PrefetchableLimitUpper32, 32);\r
-            MemAperture = &PMemAbove4G;\r
+            MemAperture = &MemAbove4G;\r
           }\r
           if (Base < Limit) {\r
             if (MemAperture->Base > Base) {\r
@@ -367,8 +358,7 @@ ScanForRootBridges (
           OFFSET_OF (PCI_TYPE00, Device.Bar),\r
           BarOffsetEnd,\r
           &Io,\r
-          &Mem, &MemAbove4G,\r
-          &PMem, &PMemAbove4G\r
+          &Mem, &MemAbove4G\r
         );\r
 \r
         //\r
@@ -440,7 +430,7 @@ ScanForRootBridges (
       InitRootBridge (\r
         Attributes, Attributes, 0,\r
         (UINT8) PrimaryBus, (UINT8) SubBus,\r
-        &Io, &Mem, &MemAbove4G, &PMem, &PMemAbove4G,\r
+        &Io, &Mem, &MemAbove4G, &mNonExistAperture, &mNonExistAperture,\r
         &RootBridges[*NumberOfRootBridges]\r
       );\r
       RootBridges[*NumberOfRootBridges].ResourceAssigned = TRUE;\r