extern BOOLEAN gDispatcherRunning;\r
extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;\r
\r
+extern BOOLEAN gMemoryAttributesTableForwardCfi;\r
+\r
extern EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLE gLoadModuleAtFixAddressConfigurationTable;\r
extern BOOLEAN gLoadFixedAddressCodeMemoryReady;\r
//\r
CoreNewDebugImageInfoEntry (EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, &Image->Info, Image->Handle);\r
}\r
\r
+ //\r
+ // Check whether we are loading a runtime image that lacks support for\r
+ // IBT/BTI landing pads.\r
+ //\r
+ if ((Image->ImageContext.ImageCodeMemoryType == EfiRuntimeServicesCode) &&\r
+ ((Image->ImageContext.DllCharacteristicsEx & EFI_IMAGE_DLLCHARACTERISTICS_EX_FORWARD_CFI_COMPAT) == 0))\r
+ {\r
+ gMemoryAttributesTableForwardCfi = FALSE;\r
+ }\r
+\r
//\r
// Reinstall loaded image protocol to fire any notifications\r
//\r
BOOLEAN mMemoryAttributesTableEndOfDxe = FALSE;\r
EFI_MEMORY_ATTRIBUTES_TABLE *mMemoryAttributesTable = NULL;\r
BOOLEAN mMemoryAttributesTableReadyToBoot = FALSE;\r
+BOOLEAN gMemoryAttributesTableForwardCfi = TRUE;\r
\r
/**\r
Install MemoryAttributesTable.\r
MemoryAttributesTable->Version = EFI_MEMORY_ATTRIBUTES_TABLE_VERSION;\r
MemoryAttributesTable->NumberOfEntries = RuntimeEntryCount;\r
MemoryAttributesTable->DescriptorSize = (UINT32)DescriptorSize;\r
- MemoryAttributesTable->Flags = 0;\r
+ if (gMemoryAttributesTableForwardCfi) {\r
+ MemoryAttributesTable->Flags = EFI_MEMORY_ATTRIBUTES_FLAGS_RT_FORWARD_CONTROL_FLOW_GUARD;\r
+ } else {\r
+ MemoryAttributesTable->Flags = 0;\r
+ }\r
+\r
DEBUG ((DEBUG_VERBOSE, "MemoryAttributesTable:\n"));\r
DEBUG ((DEBUG_VERBOSE, " Version - 0x%08x\n", MemoryAttributesTable->Version));\r
DEBUG ((DEBUG_VERBOSE, " NumberOfEntries - 0x%08x\n", MemoryAttributesTable->NumberOfEntries));\r