/* we need to detect all attempts to write to the EBC entry point argument stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. */
EFI_STATUS VmWriteMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
/* we need to detect all attempts to write to the EBC entry point argument stack area and adjust the address (which will initially point into the VM stack) to point into the EBC entry point arguments. */
EFI_STATUS VmWriteMemN(IN VM_CONTEXT *VmPtr, IN UINTN Addr, IN UINTN Data)
{
  EFI_STATUS  Status;
  UINTN       Index;
  Status = EFI_SUCCESS;
  Addr = ConvertStackAddr (VmPtr, Addr);
  if (ADDRESS_IS_ALIGNED (Addr, sizeof (UINTN))) {
    *(UINTN *)Addr = Data;
  } else {
    for (Index = 0; Index < sizeof (UINTN) / sizeof (UINT32); Index++) {
      MemoryFence ();
      Status = VmWriteMem32 (VmPtr, Addr + Index * sizeof (UINT32), (UINT32)Data);
      MemoryFence ();
      Data = (UINTN)RShiftU64 ((UINT64)Data, 32);
    }
  }
  return Status;
}