MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1394

When there is no PCI option ROM exists, today's logic still creates
virtual BAR for option ROM using Length = 0, Alignment = (-1).
It causes the final MEM32 alignment requirement is as big as
0xFFFFFFFF_FFFFFFFF.

The patch fixes this issue by only creating virtual BAR for option
ROM when there is PCI option ROM.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Cc: Chiu Chasel <chasel.chiu@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Tested-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Chasel Chiu <chasel.chiu@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@redhat.com>
This commit is contained in:
Ruiyu Ni 2018-12-11 17:49:17 +08:00
parent c8c3c53669
commit 736c436e53
1 changed files with 6 additions and 4 deletions

View File

@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator (
// All devices' Option ROM share the same MEM32 resource. // All devices' Option ROM share the same MEM32 resource.
// //
MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev); MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev);
RootBridgeDev->PciBar[0].BarType = PciBarTypeOpRom; if (MaxOptionRomSize != 0) {
RootBridgeDev->PciBar[0].Length = MaxOptionRomSize; RootBridgeDev->PciBar[0].BarType = PciBarTypeOpRom;
RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1; RootBridgeDev->PciBar[0].Length = MaxOptionRomSize;
GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge); RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1;
GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge);
}
// //
// Create resourcemap by going through all the devices subject to this root bridge // Create resourcemap by going through all the devices subject to this root bridge