From: Jason1 Lin <jason1....@intel.com> REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3922
[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 possible nagative value. Signed-off-by: Jason1 Lin <jason1....@intel.com> Cc: Bob Feng <bob.c.f...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Yuwei Chen <yuwei.c...@intel.com> Cc: Dakota Chiang <dakota.chi...@intel.com> Cc: Vanessa Chuang <vanessa.chu...@intel.com> --- 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/FitGen/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, IN UINT32 Size ) +/*++ +Routine Description: + + Check wheather the input address and size is overlap with any BiosModule. + If happen overlap, need to be deal with this case. + --- +--------------+ <------ BiosModule A Base +--------------+ + | | | | | + | | | BiosModule | + | | | A | + | | | | + BiosModule A +--------------+ <------ [Input] Address ====> +--------------+ + Size | | | + | | | [Input] Size + +--------------+ ------ +--------------+ + | | | BiosModule | + | | | | B | + --- +--------------+ +--------------+ + +Arguments: + + Address - The address of the buffer that required to check. + Size - The size of the buffer that required to check. + +Returns: + + None + +--*/ { INTN Index; for (Index = 0; Index < (INTN)gFitTableContext.BiosModuleNumber; Index ++) { if ((gFitTableContext.BiosModule[Index].Address <= Address) && - ((gFitTableContext.BiosModule[Index].Size - Size) >= (Address - gFitTableContext.BiosModule[Index].Address))) { + ((INT64)((UINT64)gFitTableContext.BiosModule[Index].Size - (UINT64)Size) >= (INT64)((UINT64)Address - (UINT64)gFitTableContext.BiosModule[Index].Address))) { UINT32 TempSize; INT32 SubIndex; diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/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 // #define UTILITY_MAJOR_VERSION 0 -#define UTILITY_MINOR_VERSION 64 +#define UTILITY_MINOR_VERSION 65 #define UTILITY_DATE __DATE__ // -- 2.36.1.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90051): https://edk2.groups.io/g/devel/message/90051 Mute This Topic: https://groups.io/mt/91354490/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-