Re: [edk2] [PATCH 08/10] StandaloneMmPkg: Add an AArch64 specific entry point library.
Hi Sughosh, Thanks a lot for picking this up. CIL.. On Tue, Jul 03, 2018 at 03:12:39PM +0530, Supreeth Venkatesh wrote: > The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard > Platforms and is initialised during the SEC phase. ARM Trusted firmware > in EL3 is responsible for initialising the architectural context for > S-EL0 and loading the Standalone MM image. The memory allocated to this > image is marked as RO+X. Heap memory is marked as RW+XN. > > Certain actions have to be completed prior to executing the generic code > in the Standalone MM Core module. These are: > > 1. Memory permission attributes for each section of the Standalone MM >Core module need to be changed prior to accessing any RW data. > > 2. A Hob list has to be created with information that allows the MM >environment to initialise and dispatch drivers. > > Furthermore, this module is responsible for handing over runtime MM > events to the Standalone MM CPU driver and returning control to ARM > Trusted Firmware upon event completion. Hence it needs to know the CPU > driver entry point. > > This patch implements an entry point module that ARM Trusted Firmware > jumps to in S-EL0. It then performs the above actions before calling the > Standalone MM Foundation entry point and handling subsequent MM events. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Achin Gupta > Signed-off-by: Supreeth Venkatesh > Cc: Jiewen Yao > Cc: Achin Gupta > --- > .../Library/AArch64/StandaloneMmCoreEntryPoint.h | 214 +++ > .../AArch64/CreateHobList.c| 200 ++ > .../AArch64/SetPermissions.c | 275 > .../AArch64/StandaloneMmCoreEntryPoint.c | 287 > + > .../StandaloneMmCoreEntryPoint.inf | 55 > 5 files changed, 1031 insertions(+) > create mode 100644 > StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h > create mode 100644 > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c > create mode 100644 > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c > create mode 100644 > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c > create mode 100644 > StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf > > diff --git > a/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h > b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h > new file mode 100644 > index 000..6eb74af > --- /dev/null > +++ b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h > @@ -0,0 +1,214 @@ > +/** @file > + Entry point to the Standalone MM Foundation when initialized during the SEC > + phase on ARM platforms > + > +Copyright (c) 2017 - 2018, ARM Ltd. All rights reserved. > +This program and the accompanying materials > +are licensed and made available under the terms and conditions of the BSD > License > +which accompanies this distribution. The full text of the license may be > found at > +http://opensource.org/licenses/bsd-license.php > + > +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. > + > +**/ > + > +#ifndef __STANDALONEMMCORE_ENTRY_POINT_H__ > +#define __STANDALONEMMCORE_ENTRY_POINT_H__ > + > +#include > +#include > + > +#define CPU_INFO_FLAG_PRIMARY_CPU 0x0001 > + > +typedef struct { > + UINT8 Type; /* type of the structure */ > + UINT8 Version;/* version of this structure */ > + UINT16 Size; /* size of this structure in bytes */ > + UINT32 Attr; /* attributes: unused bits SBZ */ > +} EFI_PARAM_HEADER; > + > +typedef struct { > + UINT64 Mpidr; > + UINT32 LinearId; > + UINT32 Flags; > +} EFI_SECURE_PARTITION_CPU_INFO; > + > +typedef struct { > + EFI_PARAM_HEADER Header; > + UINT64SpMemBase; > + UINT64SpMemLimit; > + UINT64SpImageBase; > + UINT64SpStackBase; > + UINT64SpHeapBase; > + UINT64SpNsCommBufBase; > + UINT64SpSharedBufBase; > + UINT64SpImageSize; > + UINT64SpPcpuStackSize; > + UINT64SpHeapSize; > + UINT64SpNsCommBufSize; > + UINT64SpPcpuSharedBufSize; > + UINT32NumSpMemRegions; > + UINT32NumCpus; > + EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; > +} EFI_SECURE_PARTITION_BOOT_INFO; > + > +typedef > +EFI_STATUS > +(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) ( > + IN UINTN EventId, > + IN UINTN CpuNumber, > + IN UINTN NsCommBufferAddr > + ); > + > +typedef struct { > +
[edk2] [PATCH 08/10] StandaloneMmPkg: Add an AArch64 specific entry point library.
The Standalone MM environment runs in S-EL0 in AArch64 on ARM Standard Platforms and is initialised during the SEC phase. ARM Trusted firmware in EL3 is responsible for initialising the architectural context for S-EL0 and loading the Standalone MM image. The memory allocated to this image is marked as RO+X. Heap memory is marked as RW+XN. Certain actions have to be completed prior to executing the generic code in the Standalone MM Core module. These are: 1. Memory permission attributes for each section of the Standalone MM Core module need to be changed prior to accessing any RW data. 2. A Hob list has to be created with information that allows the MM environment to initialise and dispatch drivers. Furthermore, this module is responsible for handing over runtime MM events to the Standalone MM CPU driver and returning control to ARM Trusted Firmware upon event completion. Hence it needs to know the CPU driver entry point. This patch implements an entry point module that ARM Trusted Firmware jumps to in S-EL0. It then performs the above actions before calling the Standalone MM Foundation entry point and handling subsequent MM events. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Achin Gupta Signed-off-by: Supreeth Venkatesh Cc: Jiewen Yao Cc: Achin Gupta --- .../Library/AArch64/StandaloneMmCoreEntryPoint.h | 214 +++ .../AArch64/CreateHobList.c| 200 ++ .../AArch64/SetPermissions.c | 275 .../AArch64/StandaloneMmCoreEntryPoint.c | 287 + .../StandaloneMmCoreEntryPoint.inf | 55 5 files changed, 1031 insertions(+) create mode 100644 StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/CreateHobList.c create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/SetPermissions.c create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/AArch64/StandaloneMmCoreEntryPoint.c create mode 100644 StandaloneMmPkg/Library/StandaloneMmCoreEntryPoint/StandaloneMmCoreEntryPoint.inf diff --git a/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h new file mode 100644 index 000..6eb74af --- /dev/null +++ b/StandaloneMmPkg/Include/Library/AArch64/StandaloneMmCoreEntryPoint.h @@ -0,0 +1,214 @@ +/** @file + Entry point to the Standalone MM Foundation when initialized during the SEC + phase on ARM platforms + +Copyright (c) 2017 - 2018, ARM Ltd. All rights reserved. +This program and the accompanying materials +are licensed and made available under the terms and conditions of the BSD License +which accompanies this distribution. The full text of the license may be found at +http://opensource.org/licenses/bsd-license.php + +THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#ifndef __STANDALONEMMCORE_ENTRY_POINT_H__ +#define __STANDALONEMMCORE_ENTRY_POINT_H__ + +#include +#include + +#define CPU_INFO_FLAG_PRIMARY_CPU 0x0001 + +typedef struct { + UINT8 Type; /* type of the structure */ + UINT8 Version;/* version of this structure */ + UINT16 Size; /* size of this structure in bytes */ + UINT32 Attr; /* attributes: unused bits SBZ */ +} EFI_PARAM_HEADER; + +typedef struct { + UINT64 Mpidr; + UINT32 LinearId; + UINT32 Flags; +} EFI_SECURE_PARTITION_CPU_INFO; + +typedef struct { + EFI_PARAM_HEADER Header; + UINT64SpMemBase; + UINT64SpMemLimit; + UINT64SpImageBase; + UINT64SpStackBase; + UINT64SpHeapBase; + UINT64SpNsCommBufBase; + UINT64SpSharedBufBase; + UINT64SpImageSize; + UINT64SpPcpuStackSize; + UINT64SpHeapSize; + UINT64SpNsCommBufSize; + UINT64SpPcpuSharedBufSize; + UINT32NumSpMemRegions; + UINT32NumCpus; + EFI_SECURE_PARTITION_CPU_INFO *CpuInfo; +} EFI_SECURE_PARTITION_BOOT_INFO; + +typedef +EFI_STATUS +(*PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT) ( + IN UINTN EventId, + IN UINTN CpuNumber, + IN UINTN NsCommBufferAddr + ); + +typedef struct { + PI_MM_ARM_TF_CPU_DRIVER_ENTRYPOINT *ArmTfCpuDriverEpPtr; +} ARM_TF_CPU_DRIVER_EP_DESCRIPTOR; + +typedef RETURN_STATUS (*REGION_PERMISSION_UPDATE_FUNC) ( + IN EFI_PHYSICAL_ADDRESS BaseAddress, + IN UINT64Length + ); + +/** + Privileged firmware assigns RO & Executable attributes to all memory occupied + by the Boot Firmware Volume. This