summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg/Library
Commit message (Collapse)AuthorAgeFilesLines
* StandaloneMmPkg/StandaloneMmCoreEntryPoint: relocate StMM core on the flyArd Biesheuvel2020-06-162-3/+30
| | | | | | | | | | | | | | Apply PE/COFF fixups when starting up the standalone MM core, so that it can execute at any address regardless of the link time address. Note that this requires the PE/COFF image to be emitted with its relocation section preserved. Special care is taken to ensure that TE images are dealt with correctly as well. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com> Acked-by: Jiewen Yao <Jiewen.yao@intel.com> Reviewed-by: Sami Mujawar <sami.mujawar@arm.com> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* StandaloneMmPkg: generate position independent code for StMM coreArd Biesheuvel2020-06-161-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | The standalone MM core runs in a restricted environment that is set up by a higher privilege level, and which may not allow memory regions to be writable and executable at the same time. This means that making the StMM core self-relocatable requires that all the targets of the relocation fixups are outside of the executable region of the image, given that we cannot remap the executable code writable from the executable code itself without losing those execute permissions. So instead, use the existing toolchain support to ensure that position independent code is used where possible, and that all the remaining relocated quantities are emitted into the data section. (Note that staticallly initialized const pointers will be emitted into the .data.rel.ro section, which gets pulled into the .data section by our linker script) To ensure that we don't pick up any absolute references in executable code inadvertently (e.g., in assembler code), add the '-z text' linker option which will force the build to fail in this case. Signed-off-by: Ard Biesheuvel <ard.biesheuvel@arm.com> Acked-by: Jiewen Yao <Jiewen.yao@intel.com> Tested-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
* StandaloneMmPkg: Fix few typosAntoine Coeur2020-02-101-1/+1
| | | | | | | | | | | | | Fix few typos in comments. Cc: Achin Gupta <achin.gupta@arm.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Signed-off-by: Antoine Coeur <coeur@gmx.fr> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Signed-off-by: Philippe Mathieu-Daude <philmd@redhat.com> Message-Id: <20200207010831.9046-76-philmd@redhat.com>
* StandaloneMmPkg: Replace BSD License with BSD+Patent LicenseMichael D Kinney2019-04-0923-154/+23
| | | | | | | | | | | | | | | | | | | | https://bugzilla.tianocore.org/show_bug.cgi?id=1373 Replace BSD 2-Clause License with BSD+Patent License. This change is based on the following emails: https://lists.01.org/pipermail/edk2-devel/2019-February/036260.html https://lists.01.org/pipermail/edk2-devel/2018-October/030385.html RFCs with detailed process for the license change: V3: https://lists.01.org/pipermail/edk2-devel/2019-March/038116.html V2: https://lists.01.org/pipermail/edk2-devel/2019-March/037669.html V1: https://lists.01.org/pipermail/edk2-devel/2019-March/037500.html Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
* StandaloneMmPkg: remove redundant StandaloneMmDriverEntryPoint driverArd Biesheuvel2019-03-112-140/+0
| | | | | | | | | StandaloneMmDriverEntryPoint is implemented in MdePkg now, so let's drop the redundant StandaloneMmPkg version. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: "Yao, Jiewen" <jiewen.yao@intel.com>
* StandaloneMmPkg: drop unused PCD PcdStandaloneMmEnableArd Biesheuvel2019-03-111-3/+0
| | | | | | | | | | | | The PCD PcdStandaloneMmEnable is unused, and shouldn't exist in the first place since the value is implied by the context (it is never valid to set it to FALSE for standalone MM or TRUE for traditional MM). So drop it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/StandaloneMmCoreEntryPoint: drop explicit SerialPortLib callArd Biesheuvel2019-03-111-3/+0
| | | | | | | | | | | | | Sending DEBUG output to the serial port should only be done via DebugLib calls, which is in charge of initializing the serial port when appropriate. So drop the explicit SerialPortInitialize () invocation, and rely on normal constructor ordering to get the serial port into the appropriate state at the right time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/Library: Install Variable Arch ProtocolJagadeesh Ujja2019-03-112-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In a system implementing the variable store in MM, there are no variable arch protocol and variable write arch protocol installed into the DXE_SMM protocol database. On such systems, it is not required to locate these protocols by the DXE runtime variable drivers because it can be assumed that these protocols are already installed in the MM context. But then such an implementation will deviate from the existing traditional MM based variable driver implementation. So in order to maintain consistency with the traditional MM variable driver implementation, allow platforms to install these protocols into the DXE protocol database but these protocol will not be consumed by non-secure variable service runtime driver. The Platform which uses StandaloneMM based secure variable storage have to include this library Example In edk2-platforms/Platform/ARM/SgiPkg/SgiPlatform.dsc ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf { <LibraryClasses> NULL|StandaloneMmPkg/Library/VariableMmDependency/VariableMmDependency.inf } Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com> Acked-by "Yao, Jiewen" <jiewen.yao@intel.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
* StandaloneMmPkg/StandaloneMmCoreEntryPoint: permit the use of TE imagesArd Biesheuvel2019-01-211-61/+46
| | | | | | | | | | | TE images take up less space when using 4 KB section alignment, since the FFS/FV generation code optimizes away the redundant, nested padding. This saves 4 KB of space, which is a worthwhile improvement for code that executes in place in secure context. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/StandaloneMmPeCoffExtraActionLib: ignore runtime attributeArd Biesheuvel2019-01-211-7/+2
| | | | | | | | | | | | | The special handling of the EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER attribute is only necessary for images that are relocated twice, i.e., in the context of SetVirtualAddressMap (). This does not apply to standalone MM modules, so drop the check. Drop some redundant DEBUG output while at it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/StandaloneMmCoreEntryPoint: remove bogus ASSERT_EFI_ERROR()sArd Biesheuvel2019-01-211-2/+0
| | | | | | | | | | | | | ASSERT_EFI_ERROR (x) is a shorthand for ASSERT(!EFI_ERROR(x)), and so it should only be used with EFI_STATUS type expressions. So drop two instances that operate on other types, since neither looks particularly useful. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/StandaloneMmCoreEntryPoint: use %a modifier for ASCII stringsArd Biesheuvel2019-01-211-1/+1
| | | | | | | | | PE/COFF section names are ASCII strings so use %a not %s. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg/StandaloneMmCoreHobLib: restrict to MM_CORE_STANDALONEArd Biesheuvel2019-01-211-1/+1
| | | | | | | | | | | Remove MM_STANDALONE from the list of permitted modules for this library. It should only be used by the standalone MM core. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
* StandaloneMmPkg: add MM_STANDALONE MemoryAllocationLib implementationArd Biesheuvel2019-01-212-0/+863
| | | | | | | | | | | | | | This MemoryAllocationLib code is based on the staging implementation of StandaloneMmPkg, with the following changes: - use correct MODULE_TYPE - include MmServicesTableLib instead of declaring gMmst directly - update code comments referring to the MM core Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
* StandaloneMmPkg: add HobLib implementation for MM_STANDALONE modulesArd Biesheuvel2019-01-212-0/+694
| | | | | | | | | | | | | | This HobLib code is based on the staging implementation of StandaloneMmPkg, with the following changes: - drop the unused AArch64/StandaloneMmCoreHobLibInternal.c source file - remove hack from HobLibConstructor() - update code comments referring the MM core Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jagadeesh Ujja <jagadeesh.ujja@arm.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
* StandaloneMM: Update permissions for Standalone MM drivers memory areaSughosh Ganu2018-12-092-0/+267
| | | | | | | | | | | | | | | | The StandaloneMM image executes in S-EL0 on reference Arm platforms and is deployed by the trusted firmware as BL32 image. Memory for the Standalone MM drivers is marked as RW+XN initially, allowing the drivers to be loaded into the memory. Once loaded, the memory attributes need to be changed to RO+XN for rodata sections and RO+X for code sections. Achieve this through the extra action 'UpdatePeCoffPermissions' to request the privileged firmware in EL3 to update the permissions. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMM: Include the newly added library class for MMU functionsSughosh Ganu2018-12-091-1/+1
| | | | | | | | | | | The MMU functions needed for StandaloneMM image are now exported through a separate library class. Make the corresponding change in the core's entry point inf file so that it references the correct library class for modifying the MMU attributes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg: Zero data structure explicitlyAchin Gupta2018-12-091-1/+2
| | | | | | | | | | | | Introduction of the -mstrict-align flag results in GCC attempting to use memset to zero out the InitMmFoundationSvcArgs structure. In the absence of this C library function, this patch explicitly zeroes this data structure prior to use. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Achin Gupta <achin.gupta@arm.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg: Add an AArch64 specific entry point library.Supreeth Venkatesh2018-07-204-0/+859
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Sughosh Ganu <sughosh.ganu@arm.com> Signed-off-by: Achin Gupta <achin.gupta@arm.com> Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com>
* StandaloneMmPkg: MM driver entry point library.Supreeth Venkatesh2018-07-202-0/+140
| | | | | | | | | | | This patch implements module entry point library for Standalone management mode (MM) Drivers. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
* StandaloneMmPkg/HobLib: Add HOB Library for management mode.Supreeth Venkatesh2018-07-203-0/+719
| | | | | | | | | | | | | | | | | The Standalone MM environment is initialized during the SEC phase on ARM Standard Platforms. The MM Core driver implements an entry point module which is architecture specific and runs prior to the generic core driver code. The former creates a Hob list that the latter consumes. This happens in the same phase. This patch implements a Hob library that can be used by the entry point module to produce a Hob list and by the core driver code to consume it. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Achin Gupta <achin.gupta@arm.com> Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
* StandaloneMmPkg/MemoryAllocationLib: Add MM memory allocation library.Supreeth Venkatesh2018-07-203-0/+995
| | | | | | | | | | This patch implements management mode memory allocation services. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
* StandaloneMmPkg/MemLib: Add Standalone MM instance of memory check library.Supreeth Venkatesh2018-07-203-0/+368
| | | | | | | | | | | | | | | | | | | | MM memory check library library implementation. This library consumes MM_ACCESS_PROTOCOL to get MMRAM information. In order to use this library instance, the platform should produce all MMRAM range via MM_ACCESS_PROTOCOL, including the range for firmware (like MM Core and MM driver) and/or specific dedicated hardware. This patch provides services for MM Memory Operation. The management mode Mem Library provides function for checking if buffer is outside MMRAM and valid. It also provides functions for copy data from MMRAM to non-MMRAM, from non-MMRAM to MMRAM, from non-MMRAM to non-MMRAM, or set data in non-MMRAM. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>
* StandaloneMmPkg/FvLib: Add a common FV Library for management mode.Supreeth Venkatesh2018-07-202-0/+442
This patch implements a firmware volume library that can be used by the Standalone management mode core module to parse the firmware volume. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Supreeth Venkatesh <supreeth.venkatesh@arm.com> Reviewed-by: Achin Gupta <achin.gupta@arm.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com> Signed-off-by: Sughosh Ganu <sughosh.ganu@arm.com>