EFI_CPU_ARCH_PROTOCOL *CpuArch;\r
EFI_STATUS SetAttrStatus;\r
EFI_SMRAM_DESCRIPTOR *SmramRangeSmmDriver;\r
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR MemDesc;\r
\r
//\r
// Fill in the image handle of the SMM IPL so the SMM Core can use this as the \r
\r
GetSmramCacheRange (mCurrentSmramRange, &mSmramCacheBase, &mSmramCacheSize);\r
//\r
- // If CPU AP is present, attempt to set SMRAM cacheability to WB\r
+ // If CPU AP is present, attempt to set SMRAM cacheability to WB and clear\r
+ // XP if it's set.\r
// Note that it is expected that cacheability of SMRAM has been set to WB if CPU AP\r
// is not available here.\r
//\r
);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((DEBUG_WARN, "SMM IPL failed to set SMRAM window to EFI_MEMORY_WB\n"));\r
- } \r
+ }\r
+\r
+ Status = gDS->GetMemorySpaceDescriptor(\r
+ mCurrentSmramRange->PhysicalStart,\r
+ &MemDesc\r
+ );\r
+ if (!EFI_ERROR (Status) && (MemDesc.Attributes & EFI_MEMORY_XP) != 0) {\r
+ gDS->SetMemorySpaceAttributes (\r
+ mCurrentSmramRange->PhysicalStart,\r
+ mCurrentSmramRange->PhysicalSize,\r
+ MemDesc.Attributes & (~EFI_MEMORY_XP)\r
+ );\r
+ }\r
}\r
//\r
// if Loading module at Fixed Address feature is enabled, save the SMRAM base to Load\r