Entry point to the Standalone MM Foundation when initialized during the SEC\r
phase on ARM platforms\r
\r
-Copyright (c) 2017 - 2018, ARM Ltd. All rights reserved.<BR>\r
-This program and the accompanying materials\r
-are licensed and made available under the terms and conditions of the BSD License\r
-which accompanies this distribution. The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2017 - 2021, Arm Ltd. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#define SPM_MINOR_VER_MASK 0x0000FFFF\r
#define SPM_MAJOR_VER_SHIFT 16\r
\r
-CONST UINT32 SPM_MAJOR_VER = 0;\r
-CONST UINT32 SPM_MINOR_VER = 1;\r
+#define SPM_MAJOR_VER 0\r
+#define SPM_MINOR_VER 1\r
\r
-CONST UINT8 BOOT_PAYLOAD_VERSION = 1;\r
+#define BOOT_PAYLOAD_VERSION 1\r
\r
PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT CpuDriverEntryPoint = NULL;\r
\r
/**\r
Retrieve a pointer to and print the boot information passed by privileged\r
- secure firmware\r
+ secure firmware.\r
\r
- @param SharedBufAddress The pointer memory shared with privileged firmware\r
+ @param [in] SharedBufAddress The pointer memory shared with privileged\r
+ firmware.\r
\r
**/\r
EFI_SECURE_PARTITION_BOOT_INFO *\r
return PayloadBootInfo;\r
}\r
\r
+/**\r
+ A loop to delegated events.\r
+\r
+ @param [in] EventCompleteSvcArgs Pointer to the event completion arguments.\r
+\r
+**/\r
VOID\r
EFIAPI\r
DelegatedEventLoop (\r
}\r
}\r
\r
+/**\r
+ Query the SPM version, check compatibility and return success if compatible.\r
+\r
+ @retval EFI_SUCCESS SPM versions compatible.\r
+ @retval EFI_UNSUPPORTED SPM versions not compatible.\r
+**/\r
STATIC\r
EFI_STATUS\r
GetSpmVersion (VOID)\r
/**\r
The entry point of Standalone MM Foundation.\r
\r
- @param SharedBufAddress Pointer to the Buffer between SPM and SP.\r
- @param cookie1.\r
- @param cookie2.\r
+ @param [in] SharedBufAddress Pointer to the Buffer between SPM and SP.\r
+ @param [in] SharedBufSize Size of the shared buffer.\r
+ @param [in] cookie1 Cookie 1\r
+ @param [in] cookie2 Cookie 2\r
\r
**/\r
VOID\r
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