diff options
author | Michael D Kinney <michael.d.kinney@intel.com> | 2020-02-12 13:17:24 -0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2020-02-13 01:42:50 +0000 |
commit | 02b7b861b18afd1744f462878060abda38eccb44 (patch) | |
tree | c3e57e79a341bde4a4189ae731f096a767800dd7 /MdePkg/Library | |
parent | ec97412b7c413573a681e275d55f50dea490fb24 (diff) | |
download | edk2-02b7b861b18afd1744f462878060abda38eccb44.tar.gz edk2-02b7b861b18afd1744f462878060abda38eccb44.tar.bz2 edk2-02b7b861b18afd1744f462878060abda38eccb44.zip |
MdePkg/BaseSafeIntLib: Fix VS20xx IA32 link failures
https://bugzilla.tianocore.org/show_bug.cgi?id=2525
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 <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: Bret Barkelew <bret.barkelew@microsoft.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Diffstat (limited to 'MdePkg/Library')
-rw-r--r-- | MdePkg/Library/BaseSafeIntLib/SafeIntLib.c | 6 |
1 files changed, 3 insertions, 3 deletions
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 = (((UINT64)DwordA) *(UINT64)DwordD);
+ ProductAD = MultU64x64 ((UINT64)DwordA, (UINT64)DwordD);
if ((ProductAD & 0xffffffff00000000) == 0) {
DwordB = (UINT32)Multiplicand;
//
// b * c must be less than 2^32 or there would be bits set in the high 64-bits
//
- ProductBC = (((UINT64)DwordB) *(UINT64)DwordC);
+ ProductBC = MultU64x64 ((UINT64)DwordB, (UINT64)DwordC);
if ((ProductBC & 0xffffffff00000000) == 0) {
//
// now sum them all up checking for overflow.
@@ -3397,7 +3397,7 @@ SafeUint64Mult ( //
// b * d
//
- ProductBD = (((UINT64)DwordB) *(UINT64)DwordD);
+ ProductBD = MultU64x64 ((UINT64)DwordB, (UINT64)DwordD);
if (!RETURN_ERROR (SafeUint64Add (UnsignedResult, ProductBD, &UnsignedResult))) {
*Result = UnsignedResult;
|