From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web10.17165.1653550842117963391 for ; Thu, 26 May 2022 00:40:42 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=VnERaHtJ; spf=pass (domain: intel.com, ip: 134.134.136.20, mailfrom: jason1.lin@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1653550842; x=1685086842; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=JWTdFv2q2vn+6LYcXIC/GE6aTuSvMFzgeR/5FmEDdbg=; b=VnERaHtJ5jc/pSKEPSRDam0Xs3VWu7AyxT1PS3tcCaqT/ySHHWsFzKXI 9Z3YbIEmDbWJUiPFpHV1EngzPHgZALrSMj7ZT0Gipc+ll/xr4ZEBOXAJW zc7CWIfRPc7BuIOQLi8mubki7k0Uk5R2ap7ou1/NMjr9h4gPo+C6+/XJo P1/9BApBYxAsh/C113gB+Ci449e3ZDKjxisTySaxmbcYqV/TZJZeNfgBS IWlGzk0KXW6iCva6S5iQVd9tr5z5GYalNsyDVGMZm8rrHKUlq/e2wUlnp ZN2dKk/tEKWoeCsbVZBAij/zPzjuTv7uslEAzGzbimHr36HI/olBh7xMO w==; X-IronPort-AV: E=McAfee;i="6400,9594,10358"; a="261682595" X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="261682595" Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 26 May 2022 00:40:32 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.91,252,1647327600"; d="scan'208";a="718139475" Received: from gguo-desk.gar.corp.intel.com ([10.5.215.23]) by fmsmga001.fm.intel.com with ESMTP; 26 May 2022 00:40:30 -0700 From: jason1.lin@intel.com To: devel@edk2.groups.io Cc: Jason1 Lin , Bob Feng , Liming Gao , Yuwei Chen , Dakota Chiang , Vanessa Chuang Subject: [PATCH v1] [edk2-platforms] Silicon/Intel/FitGen: Fix CheckOverlap would do incorrect split BiosModule action in corner case Date: Thu, 26 May 2022 15:40:27 +0800 Message-Id: <20220526074027.218-1-jason1.lin@intel.com> X-Mailer: git-send-email 2.31.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Jason1 Lin REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D3922 [Description] CheckOverlap function would do incorrect split on the BiosModule which not happen overlap. This would cause incorrect value locate in FIT entry record. [Condition] - This BiosModule base address is lower than input address. - This BiosModule size is smaller than input size. [Resolution] - Do the type coversion to UINT64 to prevent overflow when the value shuld = be nagative. - Do the type coversion from UINT64 to INT64 to do the comparsion with poss= ible nagative value. Signed-off-by: Jason1 Lin Cc: Bob Feng Cc: Liming Gao Cc: Yuwei Chen Cc: Dakota Chiang Cc: Vanessa Chuang --- Silicon/Intel/Tools/FitGen/FitGen.c | 30 +++++++++++++++++++- Silicon/Intel/Tools/FitGen/FitGen.h | 2 +- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG= en/FitGen.c index 290e688f6e..9d7185dc55 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.c +++ b/Silicon/Intel/Tools/FitGen/FitGen.c @@ -755,12 +755,40 @@ CheckOverlap ( IN UINT32 Address,=0D IN UINT32 Size=0D )=0D +/*++=0D +Routine Description:=0D +=0D + Check wheather the input address and size is overlap with any BiosModule= .=0D + If happen overlap, need to be deal with this case.=0D + --- +--------------+ <------ BiosModule A Base +-----= ---------+=0D + | | | | = |=0D + | | | Bio= sModule |=0D + | | | = A |=0D + | | | = |=0D + BiosModule A +--------------+ <------ [Input] Address =3D=3D=3D=3D> = +--------------+=0D + Size | | |=0D + | | | [Input] Size=0D + +--------------+ ------ +-----= ---------+=0D + | | | Bio= sModule |=0D + | | | | = B |=0D + --- +--------------+ +-----= ---------+=0D +=0D +Arguments:=0D +=0D + Address - The address of the buffer that required to check.=0D + Size - The size of the buffer that required to check.=0D +=0D +Returns:=0D +=0D + None=0D +=0D +--*/=0D {=0D INTN Index;=0D =0D for (Index =3D 0; Index < (INTN)gFitTableContext.BiosModuleNumber; Index= ++) {=0D if ((gFitTableContext.BiosModule[Index].Address <=3D Address) &&=0D - ((gFitTableContext.BiosModule[Index].Size - Size) >=3D (Address - = gFitTableContext.BiosModule[Index].Address))) {=0D + ((INT64)((UINT64)gFitTableContext.BiosModule[Index].Size - (UINT64= )Size) >=3D (INT64)((UINT64)Address - (UINT64)gFitTableContext.BiosModule[I= ndex].Address))) {=0D UINT32 TempSize;=0D INT32 SubIndex;=0D =0D diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG= en/FitGen.h index 5add6a8870..4943ee259c 100644 --- a/Silicon/Intel/Tools/FitGen/FitGen.h +++ b/Silicon/Intel/Tools/FitGen/FitGen.h @@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent // Utility version information=0D //=0D #define UTILITY_MAJOR_VERSION 0=0D -#define UTILITY_MINOR_VERSION 64=0D +#define UTILITY_MINOR_VERSION 65=0D #define UTILITY_DATE __DATE__=0D =0D //=0D --=20 2.36.1.windows.1