VOID *HobStart;\r
VOID *TeData;\r
UINTN TeDataSize;\r
+ EFI_PHYSICAL_ADDRESS ImageBase;\r
\r
// Get Secure Partition Manager Version Information\r
Status = GetSpmVersion ();\r
Status = GetStandaloneMmCorePeCoffSections (\r
TeData,\r
&ImageContext,\r
+ &ImageBase,\r
&SectionHeaderOffset,\r
&NumberOfSections\r
);\r
goto finish;\r
}\r
\r
+ //\r
+ // ImageBase may deviate from ImageContext.ImageAddress if we are dealing\r
+ // with a TE image, in which case the latter points to the actual offset\r
+ // of the image, whereas ImageBase refers to the address where the image\r
+ // would start if the stripped PE headers were still in place. In either\r
+ // case, we need to fix up ImageBase so it refers to the actual current\r
+ // load address.\r
+ //\r
+ ImageBase += (UINTN)TeData - ImageContext.ImageAddress;\r
+\r
// Update the memory access permissions of individual sections in the\r
// Standalone MM core module\r
Status = UpdateMmFoundationPeCoffPermissions (\r
&ImageContext,\r
+ ImageBase,\r
SectionHeaderOffset,\r
NumberOfSections,\r
ArmSetMemoryRegionNoExec,\r
goto finish;\r
}\r
\r
+ if (ImageContext.ImageAddress != (UINTN)TeData) {\r
+ ImageContext.ImageAddress = (UINTN)TeData;\r
+ ArmSetMemoryRegionNoExec (ImageBase, SIZE_4KB);\r
+ ArmClearMemoryRegionReadOnly (ImageBase, SIZE_4KB);\r
+\r
+ Status = PeCoffLoaderRelocateImage (&ImageContext);\r
+ ASSERT_EFI_ERROR (Status);\r
+ }\r
+\r
//\r
// Create Hoblist based upon boot information passed by privileged software\r
//\r