/* DxeIpl may have enabled Execute Disable for BSP, APs need to get the status and sync up the settings. If BSP's CR0.Paging is not set, BSP execute Disble feature is not working actually. */
BOOLEAN IsBspExecuteDisableEnabled(VOID)
/* DxeIpl may have enabled Execute Disable for BSP, APs need to get the status and sync up the settings. If BSP's CR0.Paging is not set, BSP execute Disble feature is not working actually. */
BOOLEAN IsBspExecuteDisableEnabled(VOID)
{
  UINT32                      Eax;
  CPUID_EXTENDED_CPU_SIG_EDX  Edx;
  MSR_IA32_EFER_REGISTER      EferMsr;
  BOOLEAN                     Enabled;
  IA32_CR0                    Cr0;
  Enabled   = FALSE;
  Cr0.UintN = AsmReadCr0 ();
  if (Cr0.Bits.PG != 0) {
    AsmCpuid (CPUID_EXTENDED_FUNCTION, &Eax, NULL, NULL, NULL);
    if (Eax >= CPUID_EXTENDED_CPU_SIG) {
      AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, NULL, &Edx.Uint32);
      if (Edx.Bits.NX != 0) {
        EferMsr.Uint64 = AsmReadMsr64 (MSR_IA32_EFER);
        if (EferMsr.Bits.NXE != 0) {
          Enabled = TRUE;
        }
      }
    }
  }
  return Enabled;
}