MdePkg: Redefined DEBUG_RAISE() to facilitate fuzzing.

This commit is contained in:
Mikhail Krichanov 2023-03-01 13:06:26 +03:00 committed by MikhailKrichanov
parent 2bb2e22db8
commit c9b10ce0c1
13 changed files with 38 additions and 5 deletions

View File

@ -885,8 +885,20 @@ STATIC_ASSERT (ALIGNOF (__VERIFY_UINT32_ENUM_SIZE) == sizeof (__VERIFY_UINT32_EN
**/ **/
#define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field))) #define BASE_CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - OFFSET_OF (TYPE, Field)))
// FIXME: Upstream general variants of these macros. #define DEBUG_RAISE() \
#define DEBUG_RAISE() ASSERT (FALSE) do { \
if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0) { \
DEBUG ((DEBUG_WARN, "DEBUG RAISE: Constraint violation in %a:%a:%u\n", __FILE__, __func__, __LINE__));\
} \
\
if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0) { \
ASSERT (FALSE); \
} \
\
if ((PcdGet8 (PcdDebugRaisePropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) { \
CpuBreakpoint (); \
} \
} while (FALSE)
/** /**
Checks whether a value is a power of two. Checks whether a value is a power of two.

View File

@ -47,3 +47,4 @@
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAllowMisalignedOffset gEfiMdePkgTokenSpaceGuid.PcdImageLoaderAllowMisalignedOffset
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -16,6 +16,7 @@
#include <IndustryStandard/PeImage2.h> #include <IndustryStandard/PeImage2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>

View File

@ -16,6 +16,7 @@
#include <Guid/WinCertificate.h> #include <Guid/WinCertificate.h>
#include <Library/BaseLib.h>
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>

View File

@ -15,6 +15,7 @@
#include <IndustryStandard/PeImage2.h> #include <IndustryStandard/PeImage2.h>
#include <Library/BaseLib.h>
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>

View File

@ -18,6 +18,7 @@
#include <Guid/WinCertificate.h> #include <Guid/WinCertificate.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>

View File

@ -16,6 +16,7 @@
#include <IndustryStandard/PeImage2.h> #include <IndustryStandard/PeImage2.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h> #include <Library/BaseMemoryLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/PcdLib.h> #include <Library/PcdLib.h>

View File

@ -29,3 +29,4 @@
[FixedPcd] [FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRelocTypePolicy gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRelocTypePolicy
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -37,3 +37,4 @@
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader gEfiMdePkgTokenSpaceGuid.PcdImageLoaderLoadHeader
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe gEfiMdePkgTokenSpaceGuid.PcdImageLoaderProhibitTe
gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX gEfiMdePkgTokenSpaceGuid.PcdImageLoaderRemoveXForWX
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -31,3 +31,6 @@
DebugLib DebugLib
MemoryAllocationLib MemoryAllocationLib
UeImageLib UeImageLib
[FixedPcd]
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask

View File

@ -10,9 +10,11 @@
#include <Uefi/UefiBaseType.h> #include <Uefi/UefiBaseType.h>
#include <Uefi/UefiSpec.h> #include <Uefi/UefiSpec.h>
#include <Library/BaseLib.h>
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/CacheMaintenanceLib.h> #include <Library/CacheMaintenanceLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiImageLib.h> #include <Library/UefiImageLib.h>
RETURN_STATUS RETURN_STATUS

View File

@ -7,6 +7,7 @@
#include <Library/BaseOverflowLib.h> #include <Library/BaseOverflowLib.h>
#include <Library/DebugLib.h> #include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h> #include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/UefiImageLib.h> #include <Library/UefiImageLib.h>
#include <Library/UeImageLib.h> #include <Library/UeImageLib.h>

View File

@ -2322,6 +2322,13 @@
# @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0 # @Expression 0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask & 0xC0) == 0
gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005 gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0|UINT8|0x00000005
## The mask is used to control DEBUG_RAISE() behavior.<BR><BR>
# BIT0 - Enable Debug Assert.<BR>
# BIT1 - Enable Debug Print.<BR>
# BIT4 - Enable BreakPoint as ASSERT.<BR>
# @Prompt DEBUG_RAISE() Property.
gEfiMdePkgTokenSpaceGuid.PcdDebugRaisePropertyMask|0x01|UINT8|0x0000001b
## This flag is used to control the print out Debug message.<BR><BR> ## This flag is used to control the print out Debug message.<BR><BR>
# BIT0 - Initialization message.<BR> # BIT0 - Initialization message.<BR>
# BIT1 - Warning message.<BR> # BIT1 - Warning message.<BR>