From nobody Mon Dec 23 09:15:12 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1518487743727307.8644138234837; Mon, 12 Feb 2018 18:09:03 -0800 (PST) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 0703221CF1CFA; Mon, 12 Feb 2018 18:03:12 -0800 (PST) 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 BBA9B21CF1CE5 for ; Mon, 12 Feb 2018 18:03:10 -0800 (PST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2018 18:09:00 -0800 Received: from shwdeopenpsi014.ccr.corp.intel.com ([10.239.9.10]) by fmsmga001.fm.intel.com with ESMTP; 12 Feb 2018 18:08:59 -0800 X-Original-To: edk2-devel@lists.01.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=hao.a.wu@intel.com; receiver=edk2-devel@lists.01.org X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,505,1511856000"; d="scan'208";a="30272490" From: Hao Wu To: edk2-devel@lists.01.org Date: Tue, 13 Feb 2018 10:08:56 +0800 Message-Id: <20180213020856.11328-1-hao.a.wu@intel.com> X-Mailer: git-send-email 2.12.0.windows.1 Subject: [edk2] [PATCH] MdePkg/BaseSafeIntLib: Fix VS IA32 NOOPT target build failure X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Hao Wu , Michael D Kinney , Jiewen Yao , Liming Gao MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The commit resolve the VS IA32 NOOPT target build failure for modules that use the BaseSafeIntLib. More specifically, corresponding BaseLib APIs should be used when performing shift & mulitiplication operations with signed/unsigned 64-bit operands. Cc: Michael D Kinney Cc: Sean Brogan Cc: Jiewen Yao Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu Reviewed-By: Bret Barkelew Bret.Barkelew@microsoft.com --- MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf | 3 +++ MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 13 +++++++++---- MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c | 3 ++- MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c | 3 ++- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf b/MdePkg/Libr= ary/BaseSafeIntLib/BaseSafeIntLib.inf index 20a83ed97b..8fbdafe748 100644 --- a/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf +++ b/MdePkg/Library/BaseSafeIntLib/BaseSafeIntLib.inf @@ -56,3 +56,6 @@ =20 [Packages] MdePkg/MdePkg.dec + +[LibraryClasses] + BaseLib diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/Ba= seSafeIntLib/SafeIntLib.c index d846160ba0..64b8bc4ad8 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c @@ -28,6 +28,7 @@ =20 #include #include +#include =20 =20 // @@ -3373,8 +3374,8 @@ SafeUint64Mult ( // b * c must be less than 2^32 or there would be bits in the high 64-bi= ts // then there must be no overflow of the resulting values summed up. // - DwordA =3D (UINT32)(Multiplicand >> 32); - DwordC =3D (UINT32)(Multiplier >> 32); + DwordA =3D (UINT32)RShiftU64 (Multiplicand, 32); + DwordC =3D (UINT32)RShiftU64 (Multiplier, 32); =20 // // common case -- if high dwords are both zero, no chance for overflow @@ -3409,7 +3410,11 @@ SafeUint64Mult ( // now sum them all up checking for overflow. // shifting is safe because we already checked for overflow above // - if (!RETURN_ERROR (SafeUint64Add (ProductBC << 32, ProductAD << = 32, &UnsignedResult))) { + if (!RETURN_ERROR (SafeUint64Add ( + LShiftU64 (ProductBC, 32), + LShiftU64 (ProductAD, 32), + &UnsignedResult + ))) { // // b * d // @@ -4011,7 +4016,7 @@ SafeInt32Mult ( OUT INT32 *Result ) { - return SafeInt64ToInt32 (((INT64)Multiplicand) *((INT64)Multiplier), Res= ult); + return SafeInt64ToInt32 (MultS64x64 ((INT64)Multiplicand, (INT64)Multipl= ier), Result); } =20 /** diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c b/MdePkg/Library/= BaseSafeIntLib/SafeIntLib32.c index 18bfb9e413..b3b7b802a1 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib32.c @@ -28,6 +28,7 @@ =20 #include #include +#include =20 /** INT32 -> UINTN conversion @@ -549,6 +550,6 @@ SafeIntnMult ( OUT INTN *Result ) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Resu= lt); + return SafeInt64ToIntn (MultS64x64 ((INT64)Multiplicand, (INT64)Multipli= er), Result); } =20 diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c b/MdePkg/Library= /BaseSafeIntLib/SafeIntLibEbc.c index 4478957b7e..e810ba59ef 100644 --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLibEbc.c @@ -28,6 +28,7 @@ =20 #include #include +#include =20 /** INT32 -> UINTN conversion @@ -607,7 +608,7 @@ SafeIntnMult ( ) { if (sizeof (UINTN) =3D=3D sizeof (UINT32)) { - return SafeInt64ToIntn (((INT64)Multiplicand) *((INT64)Multiplier), Re= sult); + return SafeInt64ToIntn (MultS64x64 ((INT64)Multiplicand, (INT64)Multip= lier), Result); } return SafeInt64Mult ((INT64)Multiplicand, (INT64)Multiplier, (INT64 *)R= esult); } --=20 2.12.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel