Workaround page fault with ASSERT()

This commit is contained in:
Satoshi Tanda
2020-03-05 07:21:47 -08:00
parent f6937071b3
commit 297af25c93
4 changed files with 24 additions and 2 deletions

View File

@@ -11,6 +11,7 @@
#include "HostUtils.h"
#include "Platform.h"
#include "MemoryManager.h"
#include "Logger.h"
/*!
@brief Split a 2MB EPT PDE to 512 EPT PTEs.

View File

@@ -26,12 +26,31 @@
#define MV_DEBUG_BREAK()
#define MV_SECTION_INIT
#define MV_SECTION_PAGED
#define MV_ASSERT(x) ASSERT(x)
/*!
@brief Custom ASSERT.
@details This is a workaround of that the EFI standard ASSERT can cause page
fault (null pointer access) when it fires in the host code. The author
has not been able to find out the root cause and a fix.
*/
#if !defined(MDEPKG_NDEBUG)
#define MV_VERIFY(x) ASSERT(x)
#define MV_ASSERT(x) \
if (!(x)) \
{ \
LOG_ERROR("ASSERT %a(%d): %a", __FILE__, __LINE__, #x); \
MV_PANIC(); \
} (VOID*)NULL
#else
#define MV_ASSERT(x)
#endif
#if !defined(MDEPKG_NDEBUG)
#define MV_VERIFY(x) MV_ASSERT(x)
#else
#define MV_VERIFY(x) (x)
#endif
#define MV_MAX(x, y) MAX((x), (y))
#define MV_MIN(x, y) MIN((x), (y))

View File

@@ -34,6 +34,7 @@
#include "EfiAsm.h"
#include "EfiPlatform.h"
#include "../../Utils.h"
#include "EfiLogger.h"
//
// The format of the IDT.

View File

@@ -10,6 +10,7 @@
*/
#include "Utils.h"
#include "Asm.h"
#include "Logger.h"
_Use_decl_annotations_
UINT64