while ((Hob.Raw = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, Hob.Raw)) != NULL) {\r
if (CompareGuid (&gEfiHobMemoryAllocStackGuid, &(Hob.MemoryAllocationStack->AllocDescriptor.Name))) {\r
//\r
- // Build a new memory allocation HOB with old stack info with EfiConventionalMemory type\r
- // to be reclaimed by DXE core.\r
+ // Build a new memory allocation HOB with old stack info with EfiBootServicesData type. Need to \r
+ // avoid this region be reclaimed by DXE core as the IDT built in SEC might be on stack, and some \r
+ // PEIMs may also keep key information on stack\r
//\r
BuildMemoryAllocationHob (\r
Hob.MemoryAllocationStack->AllocDescriptor.MemoryBaseAddress,\r
Hob.MemoryAllocationStack->AllocDescriptor.MemoryLength,\r
- EfiConventionalMemory\r
+ EfiBootServicesData\r
);\r
//\r
// Update the BSP Stack Hob to reflect the new stack info.\r