]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c
MdeModulePkg/PciHostBridge: Fix a bug that prevents PMEM access
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciHostBridgeDxe / PciRootBridgeIo.c
index 2c373e41de4d24a92ad9e9def016505a704a40d6..87385aa1726c8ef01d90bc782ec1d2711af0531a 100644 (file)
@@ -413,12 +413,18 @@ RootBridgeIoCheckParameter (
     // By comparing the Address against Limit we know which range to be used\r
     // for checking\r
     //\r
-    if (Address + Length <= RootBridge->Mem.Limit + 1) {\r
-      Base = RootBridge->Mem.Base;\r
+    if ((Address >= RootBridge->Mem.Base) && (Address + Length <= RootBridge->Mem.Limit + 1)) {\r
+      Base  = RootBridge->Mem.Base;\r
       Limit = RootBridge->Mem.Limit;\r
-    } else {\r
-      Base = RootBridge->MemAbove4G.Base;\r
+    } else if ((Address >= RootBridge->PMem.Base) && (Address + Length <= RootBridge->PMem.Limit + 1)) {\r
+      Base  = RootBridge->PMem.Base;\r
+      Limit = RootBridge->PMem.Limit;\r
+    } else if ((Address >= RootBridge->MemAbove4G.Base) && (Address + Length <= RootBridge->MemAbove4G.Limit + 1)) {\r
+      Base  = RootBridge->MemAbove4G.Base;\r
       Limit = RootBridge->MemAbove4G.Limit;\r
+    } else {\r
+      Base  = RootBridge->PMemAbove4G.Base;\r
+      Limit = RootBridge->PMemAbove4G.Limit;\r
     }\r
   } else {\r
     PciRbAddr = (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS*) &Address;\r