From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.93; helo=mga11.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 8960D211B76B1 for ; Mon, 28 Jan 2019 21:13:46 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 28 Jan 2019 21:13:46 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,536,1539673200"; d="scan'208";a="295260302" Received: from fmsmsx103.amr.corp.intel.com ([10.18.124.201]) by orsmga005.jf.intel.com with ESMTP; 28 Jan 2019 21:13:45 -0800 Received: from shsmsx103.ccr.corp.intel.com (10.239.4.69) by FMSMSX103.amr.corp.intel.com (10.18.124.201) with Microsoft SMTP Server (TLS) id 14.3.408.0; Mon, 28 Jan 2019 21:13:45 -0800 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.102]) by SHSMSX103.ccr.corp.intel.com ([169.254.4.194]) with mapi id 14.03.0415.000; Tue, 29 Jan 2019 13:13:43 +0800 From: "Bi, Dandan" To: "Hsueh, Hong-chihX" , "edk2-devel@lists.01.org" CC: "Kinney, Michael D" , "Gao, Liming" , Laszlo Ersek , "Bi, Dandan" Thread-Topic: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if relocation info is invalid. Thread-Index: AQHUtzkSt7im7nzmtkeO4P5kJxpfuqXFqllQ Date: Tue, 29 Jan 2019 05:13:42 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB40B8E138@SHSMSX104.ccr.corp.intel.com> References: <20190128184047.20792-1-hong-chihx.hsueh@intel.com> In-Reply-To: <20190128184047.20792-1-hong-chihx.hsueh@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if relocation info is invalid. 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: Tue, 29 Jan 2019 05:13:46 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Neo, Thank you very much for the patch. Some minor comments 1) Besides the skip check in this patch, could you help to add additional = check for RelocDir->Size before calling PeCoffLoaderImageAddress to calcula= te the RelocBase and RelocBaseEnd? Since when RelocDir->Size=3D=3D0, we can just return, don't need to do the = calculation. 2) Please use the PatchCheck.py in edk2\BaseTools\Scripts to check the patc= h format before committing the patch. Can refer following link for more info: https://github.com/tianocore/tianocore.github.io/wiki/Commit-Message-Format Thanks, Dandan > -----Original Message----- > From: Hsueh, Hong-chihX > Sent: Tuesday, January 29, 2019 2:41 AM > To: edk2-devel@lists.01.org > Cc: Kinney, Michael D ; Gao, Liming > ; Bi, Dandan ; Laszlo Ersek > > Subject: [PATCH] MdePkg/BasePeCoffLib: skip runtime relocation if > relocation info is invalid. >=20 > Skip runtime relocation for PE images that provide invalid relocation > infomation > (ex: RelocDir->Size =3D 0) to fix a hang observed while booting Windows. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 >=20 > Signed-off-by: Neo Hsueh > Cc: Michael D Kinney > Cc: Liming Gao > Cc: Dandan Bi > Cc: Laszlo Ersek > --- > MdePkg/Library/BasePeCoffLib/BasePeCoff.c | 6 ++++++ > 1 file changed, 6 insertions(+) >=20 > diff --git a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > index 1bd079ad6a..f01c691dea 100644 > --- a/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > +++ b/MdePkg/Library/BasePeCoffLib/BasePeCoff.c > @@ -1746,6 +1746,12 @@ PeCoffLoaderRelocateImageForRuntime ( > = RelocDir->VirtualAddress + RelocDir- > >Size - 1, > = 0 > = ); > + if (RelocBase =3D=3D NULL || RelocBaseEnd =3D=3D NULL || RelocBaseEn= d < > RelocBase) { > + // > + // relocation block is not valid, just return > + // > + return; > + } > } else { > // > // Cannot find relocations, cannot continue to relocate the image, A= SSERT > for this invalid image. > -- > 2.16.2.windows.1