From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 94CB32119BACC for ; Wed, 12 Dec 2018 07:08:37 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Dec 2018 07:08:36 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,344,1539673200"; d="scan'208";a="106878516" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.25]) by fmsmga007.fm.intel.com with ESMTP; 12 Dec 2018 07:08:34 -0800 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Chiu Chasel , Hao A Wu , Jian J Wang Date: Wed, 12 Dec 2018 23:10:15 +0800 Message-Id: <20181212151015.117308-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.16.1.windows.1 Subject: [PATCH] MdeModulePkg/PciBus: Fix system hang when no PCI Option ROM exists X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Dec 2018 15:08:37 -0000 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 Cc: Chiu Chasel Cc: Hao A Wu Cc: Jian J Wang --- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c index 7255bcfbbc..ee5c77147e 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -515,10 +515,12 @@ PciHostBridgeResourceAllocator ( // All devices' Option ROM share the same MEM32 resource. // MaxOptionRomSize = GetMaxOptionRomSize (RootBridgeDev); - RootBridgeDev->PciBar[0].BarType = PciBarTypeOpRom; - RootBridgeDev->PciBar[0].Length = MaxOptionRomSize; - RootBridgeDev->PciBar[0].Alignment = MaxOptionRomSize - 1; - GetResourceFromDevice (RootBridgeDev, IoBridge, Mem32Bridge, PMem32Bridge, Mem64Bridge, PMem64Bridge); + if (MaxOptionRomSize != 0) { + RootBridgeDev->PciBar[0].BarType = PciBarTypeOpRom; + RootBridgeDev->PciBar[0].Length = MaxOptionRomSize; + 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 -- 2.16.1.windows.1