From 36b2cea412a96a72097c6ef634c9e406834b162b Mon Sep 17 00:00:00 2001 From: Mike Beaton Date: Sat, 14 Oct 2023 20:02:26 +0100 Subject: [PATCH 1/2] OcBootManagementLib: Fix incorrect handling of optional DataLength parameter Introduced by 546aa5ba6415902ed05db02f8a5448c5e7ff67cf --- Changelog.md | 1 + Include/Acidanthera/Library/OcBootManagementLib.h | 4 ++-- Library/OcBootManagementLib/BootEntryInfo.c | 15 ++++++++++----- Library/OcBootManagementLib/BootEntryManagement.c | 1 + 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/Changelog.md b/Changelog.md index 1d76d1e1cb2..de3b144acc9 100644 --- a/Changelog.md +++ b/Changelog.md @@ -2,6 +2,7 @@ OpenCore Changelog ================== #### v0.9.6 - Updated builtin firmware versions for SMBIOS and the rest +- Fixed hang while generating boot entries on some systems #### v0.9.5 - Fixed GUID formatting for legacy NVRAM saving diff --git a/Include/Acidanthera/Library/OcBootManagementLib.h b/Include/Acidanthera/Library/OcBootManagementLib.h index 8632ad67b0f..b443863a85b 100644 --- a/Include/Acidanthera/Library/OcBootManagementLib.h +++ b/Include/Acidanthera/Library/OcBootManagementLib.h @@ -2186,7 +2186,7 @@ OcGetBootEntryFileFromDevicePath ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ); @@ -2218,7 +2218,7 @@ OcGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ); diff --git a/Library/OcBootManagementLib/BootEntryInfo.c b/Library/OcBootManagementLib/BootEntryInfo.c index b150ea334bb..e34e667a04c 100644 --- a/Library/OcBootManagementLib/BootEntryInfo.c +++ b/Library/OcBootManagementLib/BootEntryInfo.c @@ -401,6 +401,7 @@ OcGetBootEntryLabelImage ( OUT UINT32 *DataLength ) { + ASSERT (DataLength != NULL); return OcGetBootEntryFile ( BootEntry, Scale == 2 ? L".disk_label_2x" : L".disk_label", @@ -423,6 +424,7 @@ OcGetBootEntryIcon ( OUT UINT32 *DataLength ) { + ASSERT (DataLength != NULL); return OcGetBootEntryFile ( BootEntry, L".VolumeIcon.icns", @@ -446,7 +448,7 @@ InternalGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) @@ -458,9 +460,12 @@ InternalGetBootEntryFile ( ASSERT (SearchAtLeaf || SearchAtRoot); ASSERT (DevicePath != NULL); + ASSERT (FileData != NULL); - *FileData = NULL; - *DataLength = 0; + *FileData = NULL; + if (DataLength != NULL) { + *DataLength = 0; + } Status = OcBootPolicyDevicePathToDirPath ( DevicePath, @@ -564,7 +569,7 @@ OcGetBootEntryFileFromDevicePath ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) @@ -592,7 +597,7 @@ OcGetBootEntryFile ( IN UINT32 MaxFileSize, IN UINT32 MinFileSize, OUT VOID **FileData, - OUT UINT32 *DataLength, + OUT UINT32 *DataLength OPTIONAL, IN BOOLEAN SearchAtLeaf, IN BOOLEAN SearchAtRoot ) diff --git a/Library/OcBootManagementLib/BootEntryManagement.c b/Library/OcBootManagementLib/BootEntryManagement.c index f0a903ce1c9..6f6d62ee20f 100644 --- a/Library/OcBootManagementLib/BootEntryManagement.c +++ b/Library/OcBootManagementLib/BootEntryManagement.c @@ -192,6 +192,7 @@ ExpandShortFormBootPath ( /** Check boot entry visibility by device path. + @param[in] Context Picker context. @param[in] DevicePath Device path of the entry. @return Entry visibility From 5a7edbe32104e2ba882ffd4b74d1839c86d2824b Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 14 Oct 2023 23:59:53 +0300 Subject: [PATCH 2/2] OcGuardLib: Remove legacy code after BaseOverflowLib migration --- Include/Acidanthera/Library/OcGuardLib.h | 445 ----------------------- Library/OcGuardLib/Alignment.c | 36 -- Library/OcGuardLib/BitOverflow.c | 440 ---------------------- Library/OcGuardLib/GuardInternals.h | 50 --- Library/OcGuardLib/Math.c | 63 ---- Library/OcGuardLib/NativeOverflow.c | 154 -------- Library/OcGuardLib/OcGuardLib.inf | 6 - Library/OcGuardLib/TripleOverflow.c | 427 ---------------------- OpenCorePkg.dec | 3 - 9 files changed, 1624 deletions(-) delete mode 100644 Include/Acidanthera/Library/OcGuardLib.h delete mode 100644 Library/OcGuardLib/Alignment.c delete mode 100644 Library/OcGuardLib/BitOverflow.c delete mode 100644 Library/OcGuardLib/GuardInternals.h delete mode 100644 Library/OcGuardLib/Math.c delete mode 100644 Library/OcGuardLib/NativeOverflow.c delete mode 100644 Library/OcGuardLib/TripleOverflow.c diff --git a/Include/Acidanthera/Library/OcGuardLib.h b/Include/Acidanthera/Library/OcGuardLib.h deleted file mode 100644 index 9fc28fba7f8..00000000000 --- a/Include/Acidanthera/Library/OcGuardLib.h +++ /dev/null @@ -1,445 +0,0 @@ -/** @file - -OcGuardLib - -Copyright (c) 2018, vit9696 - -All rights reserved. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#ifndef OC_GUARD_LIB_H -#define OC_GUARD_LIB_H - -// -// The macros below provide pointer alignment checking interfaces. -// TypedPtr - pointer of a dedicated type, which alignment is to be checked. -// Align - valid alignment for the target platform (power of two so far). -// Type - valid complete typename. -// Ptr - raw pointer value, must fit into UINTN, meant to be uintptr_t equivalent. -// - -#define OC_ALIGNOF(Type) (_Alignof (Type)) -#define OC_POT_ALIGNED(Align, Ptr) (0ULL == (((UINTN) (Ptr)) & (Align-1U))) -#define OC_TYPE_ALIGNED(Type, Ptr) (OC_POT_ALIGNED (OC_ALIGNOF (Type), Ptr)) - -// -// Force member alignment for the structure. -// -#if (defined (__STDC__) && __STDC_VERSION__ >= 201112L) || defined (__GNUC__) || defined (__clang__) -#define OC_ALIGNAS(Alignment) _Alignas(Alignment) -#else -#define OC_ALIGNAS(Alignment) -#endif - -/** - Return the result of (Multiplicand * Multiplier / Divisor). - - @param Multiplicand A 64-bit unsigned value. - @param Multiplier A 64-bit unsigned value. - @param Divisor A 32-bit unsigned value. - @param Remainder A pointer to a 32-bit unsigned value. This parameter is - optional and may be NULL. - - @return Multiplicand * Multiplier / Divisor. - **/ -UINT64 -MultThenDivU64x64x32 ( - IN UINT64 Multiplicand, - IN UINT64 Multiplier, - IN UINT32 Divisor, - OUT UINT32 *Remainder OPTIONAL - ); - -// -// The interfaces below provide base safe arithmetics, reporting -// signed integer overflow and unsigned integer wraparound similarly to -// os/overflow.h in macOS SDK. -// -// Each interface may be implemented not only as an actual function, but -// a macro as well. Macro implementations are allowed to evaluate the -// expressions no more than once, and are supposed to provide faster -// compiler builtins if available. -// -// Each interface returns FALSE when the the stored result is equal to -// the infinite precision result, otherwise TRUE. The operands should -// be read left to right with the last argument representing a non-NULL -// pointer to the resulting value of the same type. -// -// More information could be found in Clang Extensions documentation: -// http://releases.llvm.org/7.0.0/tools/clang/docs/LanguageExtensions.html#checked-arithmetic-builtins -// - -// -// 32-bit integer addition, subtraction, multiplication, triple addition (A+B+C), -// triple multiplication (A*B*C), addition with multiplication ((A+B)*C), -// and multiplication with addition (A*B+C) support. -// - -BOOLEAN -OcOverflowAddU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ); - -BOOLEAN -OcOverflowSubU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ); - -BOOLEAN -OcOverflowMulU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ); - -BOOLEAN -OcOverflowAddU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ); - -BOOLEAN -OcOverflowSubU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ); - -BOOLEAN -OcOverflowMulU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ); - -BOOLEAN -OcOverflowTriAddU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ); - -BOOLEAN -OcOverflowTriMulU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ); - -BOOLEAN -OcOverflowAddMulU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ); - -BOOLEAN -OcOverflowMulAddU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ); - -BOOLEAN -OcOverflowAlignUpU32 ( - UINT32 Value, - UINT32 Alignment, - UINT32 *Result - ); - -BOOLEAN -OcOverflowAddS32 ( - INT32 A, - INT32 B, - INT32 *Result - ); - -BOOLEAN -OcOverflowSubS32 ( - INT32 A, - INT32 B, - INT32 *Result - ); - -BOOLEAN -OcOverflowMulS32 ( - INT32 A, - INT32 B, - INT32 *Result - ); - -BOOLEAN -OcOverflowTriAddS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ); - -BOOLEAN -OcOverflowTriMulS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ); - -BOOLEAN -OcOverflowAddMulS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ); - -BOOLEAN -OcOverflowMulAddS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ); - -// -// 64-bit integer addition, subtraction, multiplication, triple addition (A+B+C), -// triple multiplication (A*B*C), addition with multiplication ((A+B)*C), -// and multiplication with addition (A*B+C) support. -// - -BOOLEAN -OcOverflowAddU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ); - -BOOLEAN -OcOverflowSubU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ); - -BOOLEAN -OcOverflowMulU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ); - -BOOLEAN -OcOverflowTriAddU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ); - -BOOLEAN -OcOverflowTriMulU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ); - -BOOLEAN -OcOverflowAddMulU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ); - -BOOLEAN -OcOverflowMulAddU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ); - -BOOLEAN -OcOverflowAddS64 ( - INT64 A, - INT64 B, - INT64 *Result - ); - -BOOLEAN -OcOverflowSubS64 ( - INT64 A, - INT64 B, - INT64 *Result - ); - -BOOLEAN -OcOverflowMulS64 ( - INT64 A, - INT64 B, - INT64 *Result - ); - -BOOLEAN -OcOverflowTriAddS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ); - -BOOLEAN -OcOverflowTriMulS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ); - -BOOLEAN -OcOverflowAddMulS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ); - -BOOLEAN -OcOverflowMulAddS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ); - -// -// Native integer addition, subtraction, multiplication, triple addition (A+B+C), -// triple multiplication (A*B*C), addition with multiplication ((A+B)*C), -// and multiplication with addition (A*B+C) support. -// - -BOOLEAN -OcOverflowAddUN ( - UINTN A, - UINTN B, - UINTN *Result - ); - -BOOLEAN -OcOverflowSubUN ( - UINTN A, - UINTN B, - UINTN *Result - ); - -BOOLEAN -OcOverflowMulUN ( - UINTN A, - UINTN B, - UINTN *Result - ); - -BOOLEAN -OcOverflowTriAddUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ); - -BOOLEAN -OcOverflowTriMulUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ); - -BOOLEAN -OcOverflowAddMulUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ); - -BOOLEAN -OcOverflowMulAddUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ); - -BOOLEAN -OcOverflowAddSN ( - INTN A, - INTN B, - INTN *Result - ); - -BOOLEAN -OcOverflowSubSN ( - INTN A, - INTN B, - INTN *Result - ); - -BOOLEAN -OcOverflowMulSN ( - INTN A, - INTN B, - INTN *Result - ); - -BOOLEAN -OcOverflowTriAddSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ); - -BOOLEAN -OcOverflowTriMulSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ); - -BOOLEAN -OcOverflowAddMulSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ); - -BOOLEAN -OcOverflowMulAddSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ); - -#endif // OC_GUARD_LIB_H diff --git a/Library/OcGuardLib/Alignment.c b/Library/OcGuardLib/Alignment.c deleted file mode 100644 index 1590cb043c9..00000000000 --- a/Library/OcGuardLib/Alignment.c +++ /dev/null @@ -1,36 +0,0 @@ -/** @file - -OcGuardLib - -Copyright (c) 2020, Download-Fritz - -All rights reserved. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ -#include - -#include -#include - -BOOLEAN -OcOverflowAlignUpU32 ( - UINT32 Value, - UINT32 Alignment, - UINT32 *Result - ) -{ - BOOLEAN Status; - - Status = OcOverflowAddU32 (Value, Alignment - 1U, Result); - *Result &= ~(Alignment - 1U); - - return Status; -} diff --git a/Library/OcGuardLib/BitOverflow.c b/Library/OcGuardLib/BitOverflow.c deleted file mode 100644 index 6d7482f919d..00000000000 --- a/Library/OcGuardLib/BitOverflow.c +++ /dev/null @@ -1,440 +0,0 @@ -/** @file - -OcGuardLib - -Copyright (c) 2018, vit9696 - -All rights reserved. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "GuardInternals.h" - -// -// Software implementations provided try not to be obviously slow, but primarily -// target C99 compliance rather than performance. -// - -BOOLEAN -OcOverflowAddU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #else - UINT32 Temp; - - // - // I believe casting will be faster on X86 at least. - // - Temp = A + B; - *Result = (UINT16)Temp; - if (Temp <= MAX_UINT16) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowSubU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #else - *Result = (UINT16)(A - B); - - if (A >= B) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowMulU16 ( - UINT16 A, - UINT16 B, - UINT16 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #else - UINT32 Temp; - - Temp = (UINT32)A * B; - *Result = (UINT16)Temp; - if (Temp <= MAX_UINT32) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowAddU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_uadd_overflow (A, B, Result); - #else - UINT32 Temp; - - // - // I believe casting will be faster on X86 at least. - // - Temp = A + B; - *Result = Temp; - if (Temp >= A) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowSubU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_usub_overflow (A, B, Result); - #else - *Result = A - B; - if (B <= A) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowMulU32 ( - UINT32 A, - UINT32 B, - UINT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_umul_overflow (A, B, Result); - #else - UINT64 Temp; - - Temp = (UINT64)A * B; - *Result = (UINT32)Temp; - if (Temp <= MAX_UINT32) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowAddS32 ( - INT32 A, - INT32 B, - INT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_sadd_overflow (A, B, Result); - #else - INT64 Temp; - - Temp = (INT64)A + B; - *Result = (INT32)Temp; - if ((Temp >= MIN_INT32) && (Temp <= MAX_INT32)) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowSubS32 ( - INT32 A, - INT32 B, - INT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_ssub_overflow (A, B, Result); - #else - INT64 Temp; - - Temp = (INT64)A - B; - *Result = (INT32)Temp; - if ((Temp >= MIN_INT32) && (Temp <= MAX_INT32)) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowMulS32 ( - INT32 A, - INT32 B, - INT32 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_smul_overflow (A, B, Result); - #else - INT64 Temp; - - Temp = MultS64x64 (A, B); - *Result = (INT32)Temp; - if ((Temp >= MIN_INT32) && (Temp <= MAX_INT32)) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowAddU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_uaddll_overflow (A, B, Result); - #else - UINT64 Temp; - - Temp = A + B; - *Result = Temp; - if (Temp >= A) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowSubU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_usubll_overflow (A, B, Result); - #else - *Result = A - B; - if (B <= A) { - return FALSE; - } - - return TRUE; - #endif -} - -BOOLEAN -OcOverflowMulU64 ( - UINT64 A, - UINT64 B, - UINT64 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_umulll_overflow (A, B, Result); - #else - UINT64 AHi; - UINT64 ALo; - UINT64 BHi; - UINT64 BLo; - UINT64 LoBits; - UINT64 HiBits1; - UINT64 HiBits2; - BOOLEAN Overflow; - - // - // Based on the 2nd option written by Charphacy, believed to be the fastest portable on x86. - // See: https://stackoverflow.com/a/26320664 - // Implements overflow checking by a series of up to 3 multiplications. - // - - AHi = RShiftU64 (A, 32); - ALo = A & MAX_UINT32; - BHi = RShiftU64 (B, 32); - BLo = B & MAX_UINT32; - - LoBits = MultU64x64 (ALo, BLo); - if ((AHi == 0) && (BHi == 0)) { - *Result = LoBits; - return FALSE; - } - - Overflow = AHi > 0 && BHi > 0; - HiBits1 = MultU64x64 (ALo, BHi); - HiBits2 = MultU64x64 (AHi, BLo); - - *Result = LoBits + LShiftU64 (HiBits1 + HiBits2, 32); - return Overflow || *Result < LoBits || RShiftU64 (HiBits1, 32) != 0 || RShiftU64 (HiBits2, 32) != 0; - #endif -} - -BOOLEAN -OcOverflowAddS64 ( - INT64 A, - INT64 B, - INT64 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_saddll_overflow (A, B, Result); - #else - if (((B <= 0) || (A <= MAX_INT64 - B)) && ((B >= 0) || (A >= MIN_INT64 - B))) { - *Result = A + B; - return FALSE; - } - - // - // Assign some defined value to *Result. - // - *Result = 0; - return TRUE; - #endif -} - -BOOLEAN -OcOverflowSubS64 ( - INT64 A, - INT64 B, - INT64 *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) - return __builtin_ssubll_overflow (A, B, Result); - #else - if (((B >= 0) || (A <= MAX_INT64 + B)) && ((B <= 0) || (A >= MIN_INT64 + B))) { - *Result = A - B; - return FALSE; - } - - // - // Assign some defined value to *Result. - // - *Result = 0; - return TRUE; - #endif -} - -BOOLEAN -OcOverflowMulS64 ( - INT64 A, - INT64 B, - INT64 *Result - ) -{ - // - // Intel 32-bit architectures do not have hardware signed 64-bit - // multiplication with overflow. - // - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) && !defined (MDE_CPU_IA32) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS) && !defined (MDE_CPU_IA32) - return __builtin_smulll_overflow (A, B, Result); - #else - UINT64 AU; - UINT64 BU; - UINT64 ResultU; - - // - // It hurts to implement it without unsigned multiplication, maybe rewrite it one day. - // The idea taken from BaseSafeIntLib. - // - - #define OC_ABS_64(X) (((X) < 0) ? (((UINT64) (-((X) + 1))) + 1) : (UINT64) (X)) - - AU = OC_ABS_64 (A); - BU = OC_ABS_64 (B); - - if (OcOverflowMulU64 (AU, BU, &ResultU)) { - *Result = 0; - return TRUE; - } - - // - // Split into positive and negative results and check just one range. - // - if ((A < 0) == (B < 0)) { - if (ResultU <= MAX_INT64) { - *Result = (INT64)ResultU; - return FALSE; - } - } else { - if (ResultU < OC_ABS_64 (MIN_INT64)) { - *Result = -((INT64)ResultU); - return FALSE; - } else if (ResultU == OC_ABS_64 (MIN_INT64)) { - *Result = MIN_INT64; - return FALSE; - } - } - - #undef OC_ABS_64 - - *Result = 0; - return TRUE; - #endif -} diff --git a/Library/OcGuardLib/GuardInternals.h b/Library/OcGuardLib/GuardInternals.h deleted file mode 100644 index 000824b6703..00000000000 --- a/Library/OcGuardLib/GuardInternals.h +++ /dev/null @@ -1,50 +0,0 @@ -/** @file - This header provides internal OcGuardLib definitions. - - Copyright (c) 2020, vit9696. All rights reserved.
- SPDX-License-Identifier: BSD-3-Clause -**/ - -#ifndef OC_GUARD_INTERNALS_H -#define OC_GUARD_INTERNALS_H - -#if defined (__has_builtin) - #if __has_builtin (__builtin_add_overflow) && __has_builtin (__builtin_sub_overflow) && __has_builtin (__builtin_mul_overflow) -#define OC_HAS_TYPE_GENERIC_BUILTINS 1 - #endif -#endif - -#if defined (__GNUC__) || defined (__clang__) - #if defined (MDE_CPU_AARCH64) || defined (MDE_CPU_X64) -STATIC_ASSERT (sizeof (INTN) == 8, "INTN is expected to be 8 bytes"); -STATIC_ASSERT (sizeof (UINTN) == 8, "UINTN is expected to be 8 bytes"); -#define OC_HAS_TYPE_SPECIFIC_BUILTINS_64 1 - #elif defined (MDE_CPU_ARM) || defined (MDE_CPU_IA32) -STATIC_ASSERT (sizeof (INTN) == 4, "INTN is expected to be 4 bytes"); -STATIC_ASSERT (sizeof (UINTN) == 4, "UINTN is expected to be 4 bytes"); -#define OC_HAS_TYPE_SPECIFIC_BUILTINS_32 1 - #endif - -STATIC_ASSERT (sizeof (int) == 4, "int is expected to be 4 bytes"); -STATIC_ASSERT (sizeof (unsigned) == 4, "unsigned is expected to be 4 bytes"); -STATIC_ASSERT (sizeof (long long) == 8, "long long is expected to be 8 bytes"); -STATIC_ASSERT (sizeof (unsigned long long) == 8, "unsigned long long is expected to be 8 bytes"); -#define OC_HAS_TYPE_SPECIFIC_BUILTINS 1 -#endif - -// -// Currently no architectures provide UINTN and INTN different from 32-bit or 64-bit -// integers. For this reason they are the only variants supported and are enforced here. -// - -STATIC_ASSERT ( - sizeof (INTN) == sizeof (INT64) || sizeof (INTN) == sizeof (INT32), - "INTN must be 32 or 64 Bits wide." - ); - -STATIC_ASSERT ( - sizeof (UINTN) == sizeof (UINT64) || sizeof (UINTN) == sizeof (UINT32), - "UINTN must be 32 or 64 Bits wide." - ); - -#endif // OC_GUARD_INTERNALS_H diff --git a/Library/OcGuardLib/Math.c b/Library/OcGuardLib/Math.c deleted file mode 100644 index 826e87f6a66..00000000000 --- a/Library/OcGuardLib/Math.c +++ /dev/null @@ -1,63 +0,0 @@ -/** @file - Copyright (C) 2019, vit9696. All rights reserved. - - All rights reserved. - - This program and the accompanying materials - are licensed and made available under the terms and conditions of the BSD License - which accompanies this distribution. The full text of the license may be found at - http://opensource.org/licenses/bsd-license.php - - THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - **/ - -#include -#include - -/** - MultThenDivU64x64x32 is from MdeModulePkg's PciRootBridgeIo.c - - Copyright (c) 1999 - 2018, Intel Corporation. All rights reserved.
- SPDX-License-Identifier: BSD-2-Clause-Patent - **/ -UINT64 -MultThenDivU64x64x32 ( - IN UINT64 Multiplicand, - IN UINT64 Multiplier, - IN UINT32 Divisor, - OUT UINT32 *Remainder OPTIONAL - ) -{ - UINT64 Uint64; - UINT32 LocalRemainder; - UINT32 Uint32; - - if (Multiplicand > DivU64x64Remainder (MAX_UINT64, Multiplier, NULL)) { - // - // Make sure Multiplicand is the bigger one. - // - if (Multiplicand < Multiplier) { - Uint64 = Multiplicand; - Multiplicand = Multiplier; - Multiplier = Uint64; - } - - // - // Because Multiplicand * Multiplier overflows, - // Multiplicand * Multiplier / Divisor - // = (2 * Multiplicand' + 1) * Multiplier / Divisor - // = 2 * (Multiplicand' * Multiplier / Divisor) + Multiplier / Divisor - // - Uint64 = MultThenDivU64x64x32 (RShiftU64 (Multiplicand, 1), Multiplier, Divisor, &LocalRemainder); - Uint64 = LShiftU64 (Uint64, 1); - Uint32 = 0; - if ((Multiplicand & 0x1) == 1) { - Uint64 += DivU64x32Remainder (Multiplier, Divisor, &Uint32); - } - - return Uint64 + DivU64x32Remainder (Uint32 + LShiftU64 (LocalRemainder, 1), Divisor, Remainder); - } else { - return DivU64x32Remainder (MultU64x64 (Multiplicand, Multiplier), Divisor, Remainder); - } -} diff --git a/Library/OcGuardLib/NativeOverflow.c b/Library/OcGuardLib/NativeOverflow.c deleted file mode 100644 index 2b60bde4002..00000000000 --- a/Library/OcGuardLib/NativeOverflow.c +++ /dev/null @@ -1,154 +0,0 @@ -/** @file - -OcGuardLib - -Copyright (c) 2018, vit9696 - -All rights reserved. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include -#include - -#include "GuardInternals.h" - -BOOLEAN -OcOverflowAddUN ( - UINTN A, - UINTN B, - UINTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_uaddll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_uadd_overflow (A, B, Result); - #else - if (sizeof (UINTN) == sizeof (UINT64)) { - return OcOverflowAddU64 (A, B, (UINT64 *)Result); - } - - return OcOverflowAddU32 ((UINT32)A, (UINT32)B, (UINT32 *)Result); - #endif -} - -BOOLEAN -OcOverflowSubUN ( - UINTN A, - UINTN B, - UINTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_usubll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_usub_overflow (A, B, Result); - #else - if (sizeof (UINTN) == sizeof (UINT64)) { - return OcOverflowSubU64 (A, B, (UINT64 *)Result); - } - - return OcOverflowSubU32 ((UINT32)A, (UINT32)B, (UINT32 *)Result); - #endif -} - -BOOLEAN -OcOverflowMulUN ( - UINTN A, - UINTN B, - UINTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_umulll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_umul_overflow (A, B, Result); - #else - if (sizeof (UINTN) == sizeof (UINT64)) { - return OcOverflowMulU64 (A, B, (UINT64 *)Result); - } - - return OcOverflowMulU32 ((UINT32)A, (UINT32)B, (UINT32 *)Result); - #endif -} - -BOOLEAN -OcOverflowAddSN ( - INTN A, - INTN B, - INTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_add_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_saddll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_sadd_overflow (A, B, Result); - #else - if (sizeof (INTN) == sizeof (INT64)) { - return OcOverflowAddS64 (A, B, (INT64 *)Result); - } - - return OcOverflowAddS32 ((INT32)A, (INT32)B, (INT32 *)Result); - #endif -} - -BOOLEAN -OcOverflowSubSN ( - INTN A, - INTN B, - INTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_sub_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_ssubll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_ssub_overflow (A, B, Result); - #else - if (sizeof (INTN) == sizeof (INT64)) { - return OcOverflowSubS64 (A, B, (INT64 *)Result); - } - - return OcOverflowSubS32 ((INT32)A, (INT32)B, (INT32 *)Result); - #endif -} - -BOOLEAN -OcOverflowMulSN ( - INTN A, - INTN B, - INTN *Result - ) -{ - #if defined (OC_HAS_TYPE_GENERIC_BUILTINS) - return __builtin_mul_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_64) - return __builtin_smulll_overflow (A, B, Result); - #elif defined (OC_HAS_TYPE_SPECIFIC_BUILTINS_32) - return __builtin_smul_overflow (A, B, Result); - #else - if (sizeof (INTN) == sizeof (INT64)) { - return OcOverflowMulS64 (A, B, (INT64 *)Result); - } - - return OcOverflowMulS32 ((INT32)A, (INT32)B, (INT32 *)Result); - #endif -} diff --git a/Library/OcGuardLib/OcGuardLib.inf b/Library/OcGuardLib/OcGuardLib.inf index 28e9a693fab..f14636956e7 100644 --- a/Library/OcGuardLib/OcGuardLib.inf +++ b/Library/OcGuardLib/OcGuardLib.inf @@ -29,12 +29,6 @@ # [Sources] - Alignment.c - BitOverflow.c - GuardInternals.h - Math.c - NativeOverflow.c - TripleOverflow.c Ubsan.c Ubsan.h UbsanPrintf.c diff --git a/Library/OcGuardLib/TripleOverflow.c b/Library/OcGuardLib/TripleOverflow.c deleted file mode 100644 index 2462d22cdb2..00000000000 --- a/Library/OcGuardLib/TripleOverflow.c +++ /dev/null @@ -1,427 +0,0 @@ -/** @file - -OcGuardLib - -Copyright (c) 2018, vit9696 - -All rights reserved. - -This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. - -**/ - -#include - -BOOLEAN -OcOverflowTriAddU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ) -{ - UINT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddU32 (A, B, &OcTmp); - OcSecond = OcOverflowAddU32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ) -{ - UINT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulU32 (A, B, &OcTmp); - OcSecond = OcOverflowMulU32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ) -{ - UINT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddU32 (A, B, &OcTmp); - OcSecond = OcOverflowMulU32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddU32 ( - UINT32 A, - UINT32 B, - UINT32 C, - UINT32 *Result - ) -{ - UINT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulU32 (A, B, &OcTmp); - OcSecond = OcOverflowAddU32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriAddS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ) -{ - INT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddS32 (A, B, &OcTmp); - OcSecond = OcOverflowAddS32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ) -{ - INT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulS32 (A, B, &OcTmp); - OcSecond = OcOverflowMulS32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ) -{ - INT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddS32 (A, B, &OcTmp); - OcSecond = OcOverflowMulS32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddS32 ( - INT32 A, - INT32 B, - INT32 C, - INT32 *Result - ) -{ - INT32 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulS32 (A, B, &OcTmp); - OcSecond = OcOverflowAddS32 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriAddU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ) -{ - UINT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddU64 (A, B, &OcTmp); - OcSecond = OcOverflowAddU64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ) -{ - UINT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulU64 (A, B, &OcTmp); - OcSecond = OcOverflowMulU64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ) -{ - UINT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddU64 (A, B, &OcTmp); - OcSecond = OcOverflowMulU64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddU64 ( - UINT64 A, - UINT64 B, - UINT64 C, - UINT64 *Result - ) -{ - UINT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulU64 (A, B, &OcTmp); - OcSecond = OcOverflowAddU64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriAddS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ) -{ - INT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddS64 (A, B, &OcTmp); - OcSecond = OcOverflowAddS64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ) -{ - INT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulS64 (A, B, &OcTmp); - OcSecond = OcOverflowMulS64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ) -{ - INT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddS64 (A, B, &OcTmp); - OcSecond = OcOverflowMulS64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddS64 ( - INT64 A, - INT64 B, - INT64 C, - INT64 *Result - ) -{ - INT64 OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulS64 (A, B, &OcTmp); - OcSecond = OcOverflowAddS64 (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriAddUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ) -{ - UINTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddUN (A, B, &OcTmp); - OcSecond = OcOverflowAddUN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ) -{ - UINTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulUN (A, B, &OcTmp); - OcSecond = OcOverflowMulUN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ) -{ - UINTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddUN (A, B, &OcTmp); - OcSecond = OcOverflowMulUN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddUN ( - UINTN A, - UINTN B, - UINTN C, - UINTN *Result - ) -{ - UINTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulUN (A, B, &OcTmp); - OcSecond = OcOverflowAddUN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriAddSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ) -{ - INTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddSN (A, B, &OcTmp); - OcSecond = OcOverflowAddSN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowTriMulSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ) -{ - INTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulSN (A, B, &OcTmp); - OcSecond = OcOverflowMulSN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowAddMulSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ) -{ - INTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowAddSN (A, B, &OcTmp); - OcSecond = OcOverflowMulSN (OcTmp, C, Result); - return OcFirst | OcSecond; -} - -BOOLEAN -OcOverflowMulAddSN ( - INTN A, - INTN B, - INTN C, - INTN *Result - ) -{ - INTN OcTmp; - BOOLEAN OcFirst; - BOOLEAN OcSecond; - - OcFirst = OcOverflowMulSN (A, B, &OcTmp); - OcSecond = OcOverflowAddSN (OcTmp, C, Result); - return OcFirst | OcSecond; -} diff --git a/OpenCorePkg.dec b/OpenCorePkg.dec index d3c4f30d5b4..6576c2b055c 100755 --- a/OpenCorePkg.dec +++ b/OpenCorePkg.dec @@ -889,9 +889,6 @@ ## @libraryclass OcFlexArrayLib|Include/Acidanthera/Library/OcFlexArrayLib.h - ## @libraryclass - OcGuardLib|Include/Acidanthera/Library/OcGuardLib.h - ## @libraryclass OcHashServicesLib|Include/Acidanthera/Library/OcHashServicesLib.h