From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id AED40941110 for ; Mon, 21 Aug 2023 03:54:27 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=DgsFTrx2s4DjRLI5NReMRREnPKtgAAOiwtANu0Xu+0k=; c=relaxed/simple; d=groups.io; h=ARC-Seal:ARC-Message-Signature:ARC-Authentication-Results:From:To:Cc:Subject:Date:Message-Id:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding:Content-Type; s=20140610; t=1692590066; v=1; b=at7prHyYjlD116flxtjAJ2BJJwBqauhjU/+xtJJbos5yltlk9/Q+9ZvOTrOZeSxkLVw5r92e A4k8anOAfV1NajQq88kfO9Z3RDMeZ7aXeuRkP2gx10Pr5tJuCd0REiuszc5lxQvptUhr/hCvSlS H4UrskkgJ9etfWcp79Hw8IzA= X-Received: by 127.0.0.2 with SMTP id 28fCYY7687511xalfPuVv3BY; Sun, 20 Aug 2023 20:54:26 -0700 X-Received: from NAM11-BN8-obe.outbound.protection.outlook.com (NAM11-BN8-obe.outbound.protection.outlook.com [40.107.236.100]) by mx.groups.io with SMTP id smtpd.web10.3788.1692590065366388357 for ; Sun, 20 Aug 2023 20:54:25 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JME77QUoVSpv/i3/kZ7Z2UKCLZhZarsIJ3orwFGVoHo1BnBC+k5lz58OSt/x08266sr1eOwiZIEouRFvPwG1Tk/nhYBfuXqCt0VGsU0rFND7NBTy1PilYgWFTHgbuUQNOaPJq7QZAcZpmeXTb1w0adXi+7Yw3CF/QARByzhw9y7pex1C7uySJGApCUf973bI1ZBVIK/DR2DNEAzwsisq+z8oh0uTr5i0itWMRGMo2032yRUsD0r3ldxEqAtOPcr/khbk3dBNI8XKFbwmM8YPykFzdJK/h/r2+p6+CJypOhKZfP+1hNBtdL0QXisOztnoL/ysukWUwNw+brm10a1kFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=dI49zjbheWL1S8mKY3NQp/5QTS82YR+A9yj0lhKkNF4=; b=eOLWerZKayBS+2mCfob8XrldMkjRM8GxigPTt+1u5WH/3ftiC4YmZnUMWaHBPCWoaRXkDXARhI/xC3zT2PdPy4Ry3QeGH4Xlpo9SV1LNmhqHsw1zY6EhTzMFG+abSUajN3Pp5GsMrIiWK85Lqs7yMdMb01lP542//Z3Lp332YmAhAN2JP0z/JYx6+Ig7n0SfFMGaTQud2AhEs24Neh+ntx1LZCdWK+5MnRPo9yWKwWpfjLa5mbmLW7FRn+FUbhi3/Rl0UfFm1PIlgXrKMUE5mvt+UsctGqgkHbVqtxQOIuQdG8mAr2Y4buXpk3DqQuGJmCxCH1+AKH+UD1DZvgfRHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none X-Received: from PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) by DM4PR01MB7882.prod.exchangelabs.com (2603:10b6:8:6d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Mon, 21 Aug 2023 03:54:23 +0000 X-Received: from PH0PR01MB7287.prod.exchangelabs.com ([fe80::47db:e2da:2ade:2e19]) by PH0PR01MB7287.prod.exchangelabs.com ([fe80::47db:e2da:2ade:2e19%5]) with mapi id 15.20.6699.022; Mon, 21 Aug 2023 03:54:22 +0000 From: "Nhi Pham via groups.io" To: devel@edk2.groups.io Cc: Nhi Pham , Jian J Wang , Liming Gao , Hao A Wu , Ray Ni Subject: [edk2-devel] [RESEND][PATCH 1/1] MdeModulePkg/PciBusDxe: Fix boot hang with faulty PCI Option ROM Date: Mon, 21 Aug 2023 10:52:25 +0700 Message-Id: <20230821035225.49255-1-nhi@os.amperecomputing.com> X-ClientProxiedBy: SI1PR02CA0039.apcprd02.prod.outlook.com (2603:1096:4:1f6::9) To PH0PR01MB7287.prod.exchangelabs.com (2603:10b6:510:10a::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PH0PR01MB7287:EE_|DM4PR01MB7882:EE_ X-MS-Office365-Filtering-Correlation-Id: 886ce9b4-b090-4e85-a6cb-08dba1fa4e07 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Message-Info: T2Z5dl0TzVK5Rqk6mDhJk9/wk44lAeF6XE74kSF9FgQJlK5V/ct/HXI1AU7S7EKS1dxbCeilr8vVFPpcocHTs66u/t7/PAPJx+NYqs/nETWillquIWw4smU5wU5sMGnJUf/3mok5swUjwlUcTUzcjXpOp0YO94q7fGLlFT+k9nCP86kwU0mrwKlfGZIF/WYBmg5F//XkpvAmAPMAmEV2R25iKDa8icwrbQ0WRTzbl1BX6a5ZowlPabRy8iJLVzhE/yh+aiN5d3nIVOZnVUofLw4bDyQIFZ32GiKYbThjT55XiUB99DEQCgQNKwSvXtgYSOIk/aPa3VZKsgBopvo8E4D9ObLVw6qGdmkiFeGFujAtl0GbxUHVOA2mauajcg6VEd2F/Xke/alr0iqs8VC68Xu9DCK/NCHkuiHSEX0QM8pCXXb0aqvI92kl/I7VCMy7W4Hr8F49cjtgffwaDrE4A/9Us4vrfvxrxXsXz/uKtY5+A6x76BthWchAKuS8fEj+HniFkURRBUdfK8TCEedwnJyXvxNykV57QBo2dCYDfouJKSKYsNviBx1gvKcz7KDXFn3mxvUIGFPlKK3CvV00lJzGfssHdkv4uMtQ1nK5E+GNdVXbpeNYpdiczhtTp809 X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?us-ascii?Q?vU7ic8TAQ8CH/dC158Yw5sA268IEzlMhOJRiKQKdaDxLvqsHXkLBjWIIFnI6?= =?us-ascii?Q?DJsoAWV0d4oIM/vSI0ocmM/j9V9quY2v6A/OfsJbcj0GQQbMNuSmvSzO0teM?= =?us-ascii?Q?TtEYt84X5/Bv2+s8vZhi38PdzwVmlKCt3CevWh6hmUD7x0Q+tDtgSx+SnWda?= =?us-ascii?Q?OcT3KhNJfhUi59uIxq0fsfcs+bx3mYel3HqliDllSntV9/rxlsmpWG1Yczem?= =?us-ascii?Q?In4TPHpxXcJlscWstGahTp3qvIqdxxNoao57i+V7UQkMq3mWOEe6PdLEEq6r?= =?us-ascii?Q?d6AtcgZbYULDLb5i4/M1XcvTndsIDlnCPQnl6BB5QHX6GWmXXKB573JSYEPH?= =?us-ascii?Q?r7MhxAlhGnryXkKVm6wYRdIYps+sXiis9tY3Zrvg8u8sDyNpj22h+Wb4/iB7?= =?us-ascii?Q?vUUFCPuNRjVwDFsjZvS2Jp+kEDYosLdA4ZF9iVD1tC32iTMqnh0zNDj6WZve?= =?us-ascii?Q?xFnTBX92Y9LwwZG8QDiiwajIdfNqTglaifjNLGOPYQwgeQ7mv5fknthY6ZIp?= =?us-ascii?Q?7kIYI1IlBDhteozXUosWPbpS9LRqmVETQGrRb/9Dl0VoHh47twnqD4PTC2in?= =?us-ascii?Q?e6S0mAxvhioW+LFQIbhi/Bg+BXeaKM8kJjSchog2uFG0u07+bObGG0/UGJrZ?= =?us-ascii?Q?QlkPPUZ4pcvUl2MXkV0dyr6Jd3BT0jcVnfWiD6Y3RoVNgRTB8lMQmJsLJzQV?= =?us-ascii?Q?/vwogwIpITd1JonlnCjUbH9kmOH0vGTd+YkyZZ8hOIns3pTETnlGi7F0hgHk?= =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os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 886ce9b4-b090-4e85-a6cb-08dba1fa4e07 X-MS-Exchange-CrossTenant-AuthSource: PH0PR01MB7287.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Aug 2023 03:54:22.8672 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: vYZEb8JiT8nBziBS/OgvaTQOhCWLa/TmP19KKayx/xR9G+WQDqCxYC67TDXst4trxgo97RdRsZK6+Gy59h9PxqX+DSJCZQjVpT0EW20EycI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR01MB7882 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nhi@os.amperecomputing.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: tg6P8nO4NZTcRDV1LND9S2r1x7686176AA= Content-Transfer-Encoding: quoted-printable Content-Type: text/plain X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b=at7prHyY; dmarc=none; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io A faulty PCI device has the Option ROM image size set to 0. UEFI reads two headers PCI_EXPANSION_ROM_HEADER and PCI_DATA_STRUCTURE to get the Option ROM information. Because the image size is 0, the Option ROM header address never changes. As a result, UEFI keeps reading the same two headers definitely. This patch is intended to fix it. Cc: Jian J Wang Cc: Liming Gao Cc: Hao A Wu Cc: Ray Ni Signed-off-by: Nhi Pham --- MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c b/MdeModu= lePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c index 89f5f64101a5..bd5ace18f6e4 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciOptionRomSupport.c @@ -506,13 +506,13 @@ LoadOpRomImage ( Indicator =3D RomPcir->Indicator; RomImageSize =3D RomImageSize + RomPcir->ImageLength * 512; RomBarOffset =3D RomBarOffset + RomPcir->ImageLength * 512; - } while (((Indicator & 0x80) =3D=3D 0x00) && ((RomBarOffset - RomBar) < = RomSize)); + } while (((Indicator & 0x80) =3D=3D 0x00) && ((RomBarOffset - RomBar) < = RomSize) && (RomImageSize > 0)); =20 // // Some Legacy Cards do not report the correct ImageLength so used the m= aximum // of the legacy length and the PCIR Image Length // - if (CodeType =3D=3D PCI_CODE_TYPE_PCAT_IMAGE) { + if ((RomImageSize > 0) && (CodeType =3D=3D PCI_CODE_TYPE_PCAT_IMAGE)) { RomImageSize =3D MAX (RomImageSize, LegacyImageLength); } =20 --=20 2.25.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#107909): https://edk2.groups.io/g/devel/message/107909 Mute This Topic: https://groups.io/mt/100867193/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-