/* Figures out if we are running inside Xen HVM. */
BOOLEAN XenDetect(VOID)
/* Figures out if we are running inside Xen HVM. */
BOOLEAN XenDetect(VOID)
{
  UINT8  Signature[13];
  if (mXenLeaf != 0) {
    return TRUE;
  }
  Signature[12] = '\0';
  for (mXenLeaf = 0x40000000; mXenLeaf < 0x40010000; mXenLeaf += 0x100) {
    AsmCpuid (
      mXenLeaf,
      NULL,
      (UINT32 *)&Signature[0],
      (UINT32 *)&Signature[4],
      (UINT32 *)&Signature[8]
      );
    if (!AsciiStrCmp ((CHAR8 *)Signature, "XenVMMXenVMM")) {
      return TRUE;
    }
  }
  mXenLeaf = 0;
  return FALSE;
}