From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.2157.1581555130369868017 for ; Wed, 12 Feb 2020 16:52:10 -0800 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: liming.gao@intel.com) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2020 16:52:09 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,434,1574150400"; d="scan'208";a="237880052" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga006.jf.intel.com with ESMTP; 12 Feb 2020 16:52:09 -0800 Received: from shsmsx602.ccr.corp.intel.com (10.109.6.142) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.439.0; Wed, 12 Feb 2020 16:52:09 -0800 Received: from shsmsx606.ccr.corp.intel.com (10.109.6.216) by SHSMSX602.ccr.corp.intel.com (10.109.6.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Thu, 13 Feb 2020 08:52:07 +0800 Received: from shsmsx606.ccr.corp.intel.com ([10.109.6.216]) by SHSMSX606.ccr.corp.intel.com ([10.109.6.216]) with mapi id 15.01.1713.004; Thu, 13 Feb 2020 08:52:07 +0800 From: "Liming Gao" To: "Kinney, Michael D" , "devel@edk2.groups.io" CC: Sean Brogan , Bret Barkelew Subject: Re: [Patch] MdePkg/BaseSafeIntLib: Fix VS20xx IA32 link failures Thread-Topic: [Patch] MdePkg/BaseSafeIntLib: Fix VS20xx IA32 link failures Thread-Index: AQHV4fYe+B+4dtj2akOq+anqwbnsUqgYS7EA Date: Thu, 13 Feb 2020 00:52:07 +0000 Message-ID: References: <20200212224511.27164-1-michael.d.kinney@intel.com> In-Reply-To: <20200212224511.27164-1-michael.d.kinney@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.2.0.6 dlp-product: dlpe-windows dlp-reaction: no-action x-originating-ip: [10.239.127.36] MIME-Version: 1.0 Return-Path: liming.gao@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Liming Gao > -----Original Message----- > From: Kinney, Michael D > Sent: Thursday, February 13, 2020 6:45 AM > To: devel@edk2.groups.io > Cc: Gao, Liming ; Sean Brogan ; Bret Barkelew > Subject: [Patch] MdePkg/BaseSafeIntLib: Fix VS20xx IA32 link failures >=20 > https://bugzilla.tianocore.org/show_bug.cgi?id=3D2525 >=20 > SafeUint64Mult() looks for 64-bit overflows and performs > several 32-bit multiples with 64-bit results to check for > all possible overflow conditions. IA32 builds using VS20xx > with optimizations enabled are producing a reference to > the _allmull intrinsic. >=20 > The fix is to use MultU64x64() instead of '*' for > these operations. These are safe because the inputs > are guaranteed to have the upper 32-bits clear, which > means MultU64x64() can never overflow with those inputs. >=20 > Cc: Liming Gao > Cc: Sean Brogan > Cc: Bret Barkelew > Signed-off-by: Michael D Kinney > --- > MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) >=20 > diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/= BaseSafeIntLib/SafeIntLib.c > index 0f6be6e064..eec8ac1ffd 100644 > --- a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c > +++ b/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c > @@ -3380,14 +3380,14 @@ SafeUint64Mult ( > // > // a * d must be less than 2^32 or there would be bits set in the = high 64-bits > // > - ProductAD =3D (((UINT64)DwordA) *(UINT64)DwordD); > + ProductAD =3D MultU64x64 ((UINT64)DwordA, (UINT64)DwordD); > if ((ProductAD & 0xffffffff00000000) =3D=3D 0) { > DwordB =3D (UINT32)Multiplicand; >=20 > // > // b * c must be less than 2^32 or there would be bits set in th= e high 64-bits > // > - ProductBC =3D (((UINT64)DwordB) *(UINT64)DwordC); > + ProductBC =3D MultU64x64 ((UINT64)DwordB, (UINT64)DwordC); > if ((ProductBC & 0xffffffff00000000) =3D=3D 0) { > // > // now sum them all up checking for overflow. > @@ -3397,7 +3397,7 @@ SafeUint64Mult ( > // > // b * d > // > - ProductBD =3D (((UINT64)DwordB) *(UINT64)DwordD); > + ProductBD =3D MultU64x64 ((UINT64)DwordB, (UINT64)DwordD); >=20 > if (!RETURN_ERROR (SafeUint64Add (UnsignedResult, ProductBD,= &UnsignedResult))) { > *Result =3D UnsignedResult; > -- > 2.21.0.windows.1