From nobody Wed May 8 21:02:25 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+54309+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+54309+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1581547515425602.0851498334127; Wed, 12 Feb 2020 14:45:15 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id P40sYY1788612xABJTsxhERS; Wed, 12 Feb 2020 14:45:14 -0800 X-Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by mx.groups.io with SMTP id smtpd.web10.374.1581547513794661819 for ; Wed, 12 Feb 2020 14:45:13 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Feb 2020 14:45:12 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.70,434,1574150400"; d="scan'208";a="434217166" X-Received: from unknown (HELO mdkinney-MOBL2.amr.corp.intel.com) ([10.241.98.74]) by fmsmga006.fm.intel.com with ESMTP; 12 Feb 2020 14:45:12 -0800 From: "Michael D Kinney" To: devel@edk2.groups.io Cc: Liming Gao , Sean Brogan , Bret Barkelew Subject: [edk2-devel] [Patch] MdePkg/BaseSafeIntLib: Fix VS20xx IA32 link failures Date: Wed, 12 Feb 2020 14:45:11 -0800 Message-Id: <20200212224511.27164-1-michael.d.kinney@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,michael.d.kinney@intel.com X-Gm-Message-State: Ga19BldWaW45FqUH8kWKjlnqx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1581547514; bh=KMMW1GJ2DSMHftISadQ2Av1tC0ib0NPictI+3Z7gOvM=; h=Cc:Date:From:Reply-To:Subject:To; b=tO743if57Y1L2vWKSkOx5VKTZura8f3ObdHVvI80Im1ZNGnGsTGjts9y8MWMOGuNypb zOE53oQAvcmsm3wAzL+FEkvPp9SqUgnLLUDI54VvtI9RyGZczm0FRlx7xLFaKUlpQGgvV +LyfKxrandMuFHuG9XHZJTh2hPe9xPvwWOM= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" https://bugzilla.tianocore.org/show_bug.cgi?id=3D2525 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. 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. Cc: Liming Gao Cc: Sean Brogan Cc: Bret Barkelew Signed-off-by: Michael D Kinney Reviewed-by: Bret Barkelew Reviewed-by: Liming Gao --- MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MdePkg/Library/BaseSafeIntLib/SafeIntLib.c b/MdePkg/Library/Ba= seSafeIntLib/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 hi= gh 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 the = 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; --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54309): https://edk2.groups.io/g/devel/message/54309 Mute This Topic: https://groups.io/mt/71226620/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-