/* Unset head Guard and tail Guard for the given memory range. */
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
/* Unset head Guard and tail Guard for the given memory range. */
VOID UnsetGuardForMemory(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
{
  EFI_PHYSICAL_ADDRESS  GuardPage;
  UINT64                GuardBitmap;
  if (NumberOfPages == 0) {
    return;
  }
  GuardPage   = Memory - EFI_PAGES_TO_SIZE (1);
  GuardBitmap = GetGuardedMemoryBits (Memory - EFI_PAGES_TO_SIZE (2), 2);
  if ((GuardBitmap & BIT1) == 0) {
    if ((GuardBitmap & BIT0) == 0) {
      UnsetGuardPage (GuardPage);
    }
  } else {
    SetGuardPage (Memory);
  }
  GuardPage   = Memory + EFI_PAGES_TO_SIZE (NumberOfPages);
  GuardBitmap = GetGuardedMemoryBits (GuardPage, 2);
  if ((GuardBitmap & BIT0) == 0) {
    if ((GuardBitmap & BIT1) == 0) {
      UnsetGuardPage (GuardPage);
    }
  } else {
    SetGuardPage (GuardPage - EFI_PAGES_TO_SIZE (1));
  }
  ClearGuardedMemoryBits (Memory, NumberOfPages);
}