Problem:
The NX bit in page table is not expected for new allocated EfiBootServicesCode
if bit7(EfiConventionalMemory) is zero and bit0(EfiReservedMemoryType) is one of PcdDxeNxMemoryProtectionPolicy.
Flow:
When bit0 of PcdDxeNxMemoryProtectionPolicy is set to 1, the EfiReservedMemoryType attribute is EFI_MEMORY_XP,
the NX bit is set for EfiReservedMemoryType memory in InitializeDxeNxMemoryProtectionPolicy().
In CoreInternalAllocatePages, if request a specific address but can't be found in current memory map,
it does a special “memory promotion”.
PromoteMemoryResource() is called to find memory resource and add UNTESTED memory region to be system memory.
The type of UNTESTED memory is EfiGcdMemoryTypeReserved.
In CoreAddRange(), the new memory resource is added to allocable system memory resource,
the new type is EfiConventionalMemory but the memory attribute is not really changed, NX bit is still set.
Before return to caller, ApplyMemoryProtectionPolicy() is used to convert memory attribute,
however, both bit7(EfiConventionalMemory) and bit3(EfiBootServicesCode) are zero, memory attribute is not changed.
NX bit is still set.
AllocatePages returns a EfiBootServicesCode memory but its NX bit is set.