summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg
Commit message (Collapse)AuthorAgeFilesLines
* StandaloneMmPkg: Add two new APIs in HobLibDun Tan2 days2-0/+140
| | | | | | | | | | | | | | | | | This commit is to add two new APIs in StandaloneMmPkg StandaloneMmHobLib and StandaloneMmCoreHobLib: 1.The GetNextMemoryAllocationGuidHob () returns the next instance of the Memory Allocation HOB with the matched GUID from a starting HOB pointer. 2.The TagMemoryAllocationHobWithGuid () searchs the HOB list for the Memory Allocation HOB with a matching base address and set the Name GUID. Then the instance of the tagged Memory Allocation HOB with matched base address is returned. Signed-off-by: Dun Tan <dun.tan@intel.com>
* ArmPkg: ArmFfaLib: Move ArmFfaLib implementation to MdeModulePkgKun Qin10 days1-2/+1
| | | | | | | | | | | | | | ArmFfaLib is an implementation of an industry specification-defined interface with UEFI specific method of handling Rx/Tx buffer sharing across multiple boot phases, which is more appropriately placed in MdeModulePkg. This update relocates the implementation of ArmFfaLib to MdeModulePkg, thereby supporting the FFA call primitives for all other packages that depend on this interface. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Kun Qin <kun.qin@microsoft.com>
* ArmPkg: ArmSvcLib: Move ArmSvcLib to MdePkgKun Qin10 days1-1/+1
| | | | | | | | | | | | As an implementation of an industry specification-defined interface, ArmSvcLib is more appropriately placed in MdePkg. This update relocates both the header definition and the implementation of ArmSvcLib to MdePkg, thereby supporting the supervisor call primitives for all other packages that depend on this interface. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Kun Qin <kun.qin@microsoft.com>
* ArmPkg: ArmSmcLib: Move ArmSmcLib to MdePkgKun Qin10 days1-1/+1
| | | | | | | | | | | | As an implementation of an industry specification-defined interface, ArmSmcLib is more appropriately placed in MdePkg. This update relocates both the header definition and the implementation of ArmSmcLib to MdePkg, thereby supporting the monitor call primitives for all other packages that depend on this interface. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Kun Qin <kun.qin@microsoft.com>
* StandaloneMmPkg/Core: Performance logging for MM driver load and startWei6 Xu11 days4-1/+41
| | | | | | | | | | Include PerformanceLib for StandaloneMmCore, add performance logging for MM driver loading and starting. Add FV_FILEPATH_DEVICE_PATH into Loaded Image protocol for MM driver, then StandaloneMmCorePerformanceLib can get the FILE_GUID from the device path. Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
* StandaloneMmPkg: MmCommunicationDxe: Add EFI_MM_COMMUNICATION3_PROTOCOLKun Qin13 days3-5/+94
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3430 This change added support of installing `EFI_MM_COMMUNICATION3_PROTOCOL`. MmCommunicate v3 routine will no longer need to supply buffer length in the input parameters but instead inference from the returned communicate buffer. Signed-off-by: Kun Qin <kuqin12@gmail.com>
* StandaloneMmPkg: StandaloneMmIplPei: Add EFI_PEI_MM_COMMUNICATION3_PPIKun Qin13 days3-7/+150
| | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3430 This change added support of installing `EFI_PEI_MM_COMMUNICATION3_PPI`. MmCommunicate v3 routine will no longer need to supply buffer length in the input parameters but instead inference from the returned communicate buffer. Signed-off-by: Kun Qin <kuqin12@gmail.com>
* StandaloneMmPkg: StandaloneMmCore: Parsing new MM communicate headerKun Qin13 days2-16/+34
| | | | | | | | | | | | | | | REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3398 REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3430 MM communicate protocols are expanded with EFI_MM_COMMUNICATE_HEADER_V3 structure that cooperates with updated field types and flexible array. The PiSmmCore implementation is updated to detect and process incoming data accordingly. Two checks are also performed to prevent legacy communicate data or unsupported data is fed into MM core under agreed header guid. Signed-off-by: Kun Qin <kuqin12@gmail.com>
* StandaloneMmPkg: Produce gMmStatusCodeUseSerialHobGuid HOBJiaxin Wu2025-03-274-0/+49
| | | | | | | Produce gMmStatusCodeUseSerialHobGuid as MM Foundation HOB to describe the status code use serial port or not. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
* StandaloneMmPkg: Add gMmStatusCodeUseSerialHobGuid HOB definitionJiaxin Wu2025-03-272-0/+38
| | | | | | | | | PcdStatusCodeUseSerial can be the dynamic PCD, which can't be used in MM drivers. So, defines gMmStatusCodeUseSerialHobGuid HOB to indicate StatusCode is reported via serial port or not. The value shall match with the PcdStatusCodeUseSerial. Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
* StandaloneMmPkg: Disable assert when gMmCommBufferHobGuid not found.Kun Qin2025-03-141-1/+2
| | | | | | | | | | | | | | | | | | For AARCH64 using StandaloneMmPkg, gMmCommBufferHobGuid will not exist. Aarch64 makes use of their own Root MmiHandler that will get the communication buffer out of a separate buffer, and will call MmiMange directly with the information. For x64, where gMmCommBufferHobGuid is expected to be supplied in the hob list passed to StandaloneCore, if the hob does not exist, print out a debug message describing the failure scenario. Its important to note that a mising gMmCommBufferHobGuid will mean non-root MmiHandlers will not be dispatched in the x64 scenario, but that root MmiHandlers will still be dispatched. Signed-off-by: Aaron Pop <aaronpop@microsoft.com> Co-authored-by: Aaron Pop <aaronpop@microsoft.com>
* StandaloneMmPkg/Library: Print warning message if GUID HOB not foundJiaxin Wu2025-03-111-0/+4
| | | | | | This patch is to print the warning message if GUID HOB not found Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
* StandaloneMmPkg/MmIpl : Add EFI_HOB_HANDOFF_INFO_TABLE to MM HOB listHongbin1 Zhang2025-02-263-5/+58
| | | | | | | | | | | | | | | GetBootModeHob function need to add EFI_HOB_HANDOFF_INFO_TABLE in MM hob data base. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg: Produce StandaloneMM Entry/Exit Notify Protocol.Diat Siah Yap2025-02-253-2/+40
| | | | | | | | | | | | | | | | Produce StandaloneMM Entry/Exit Notify Protocol for PlatformHook. This replaces the SMM core platform hook implementation in the traditional SMM (Edk2\MdeModulePkg\Include\Library\SmmCorePlatformHookLib.h). Unlike traditional SMM, Standalone MM prefers a more generic method to perform platform-specific tasks before and after the SMI handler. Therefore, it introduces the gMmEntryNotifyProtocolGuid and gMmExitNotifyProtocolGuid protocols to notify the SMM entry and exit. This approach is more flexible for the platform, eliminating the need to place all tasks in PlatformHookBeforeSmmDispatch() and PlatformHookAfterSmmDispatch(), thus platform code can depend on the protocol notification to perform platform-specific tasks. Signed-off-by: Diat Siah Yap <diat.siah.yap@intel.com>
* StandaloneMmPkg/Core: dump HOB list in MMRAMDun Tan2025-02-241-4/+4
| | | | | | | | | | | This commit is to dump finaled HOB list in MMRAM. In previous commit, we verify the HOB list and initialize a new HOB list in MMRAM before we call the library constructor. Since we might migrate some memory allocation HOB into MMRAM, it's cleared to dump information in finaled HOB list. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/Core: pass HOB list in MMRAM to library constructorDun Tan2025-02-246-126/+12
| | | | | | | | | | | | | | | | | | | The commit changes the code to initializes new HOB list in MMRAM before the ProcessLibraryConstructorList() and pass the MMRAM HOB list to lib constructor. Previously, the HOB list in non-MMRAM range is passed to the lib constructor. Then code in the library constructor would consume unverified HOB list in non-MMRAM buffer. With this commit, the HOB validation and memory allocation HOB migration are doned before the library constructor. Since the HOB list initialization needs to allocate memory in MMRAM, we also need to call the MmInitializeMemoryServices() before the HOB list initialization. Then the duplicated code in the StandaloneMmCore MemoryAllocationLib can also be removed. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg StandaloneMmCoreMemoryAllocationLib: Rename gMmstStar Zeng2025-02-111-12/+12
| | | | | | | | | | | | | | | | | StandaloneMmCoreMemoryAllocationLib.c and StandaloneMmServicesTableLib.c are both defining gMmst, StandaloneMmCoreMemoryAllocationLib will be linked to StandaloneMmCore directly, StandaloneMmServicesTableLib may be linked to StandaloneMmCore indirectly, when they are both linked to StandaloneMmCore, there will be "lld-link: error: duplicate symbol: gMmst" build error with Clang compiler. gMmst is declared in MmServicesTableLib.h and its definition should be owned by MmServicesTableLib. This patch renames gMmst in StandaloneMmCoreMemoryAllocationLib.c to mMemoryAllocationMmst to avoid this build error. Signed-off-by: Star Zeng <star.zeng@intel.com>
* StandaloneMmPkg: Consume X64 StandaloneMmCoreEntryPoint From MdePkgOliver Smith-Denny2025-02-075-214/+1
| | | | | | | | Now that the X64 StandaloneMmCoreEntryPoint has been moved to MdePkg, it can be removed from StandaloneMmPkg and consumed from MdePpkg. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
* StandaloneMmPkg: Introduce a PCD to disable shadow boot FVLevi Yun2025-01-203-10/+40
| | | | | | | | | | | | | | | | On some Arm platforms the boot firmware volume passed in the HOB by the secure world firmware (TF-A) is never freed and is always mapped as read-only. On such platforms the heap memory can be saved by disabling the shadow copy of the boot firmware volume. This is useful as on some platforms the amount of memory available is limited. Therefore, introduce a PCD PcdShadowBfv that platforms can configure to disable the shadow boot FV. This PCD is set to TRUE by default. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: move core entry point lib and cpu driver to ArmPkgLevi Yun2025-01-1713-2889/+5
| | | | | | | | | | | | StandaloneMmCpu driver is only used for Arm architecture and StandaloneMmCoreEntryPointLib for Arm has specific implementation with StandaloneMmCpu driver. Move StandaloneMmCpu Driver and StandaloneMmCoreEntryPointLib for Arm to ArmPkg. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: introduce StandaloneMmExtractGuidedSectionLibLevi Yun2025-01-174-1/+446
| | | | | | | | | | | | | | The default ExtractGuidedSectionLib used by Standalone MM is the implementation in EmbeddedPkg. However, the ExtractGuidedSectionLib implementation in EmbeddedPkg builds HOBs to save the extract handler information. Since StandaloneMm is consumer of HOB, not a HOB producer, introduce a StandaloneMmExtraGuidedSectionLib implementation that saves the extract handler information in the ConfigurationTable. This StandaloneMmExtraGuidedSectionLib can be used by MM_STANDALONE and MM_CORE_STANDALONE modules. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: remove per-cpu feature on StandaloneMmLevi Yun2025-01-175-315/+51
| | | | | | | | | StandaloneMm in Arm is UP-migratable which means StandaloneMm cannot run concurrently. Therefore, remove per-cpu feature in StandaloneMm. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: Move sanity check for comm buffer to entrypointLevi Yun2025-01-175-107/+125
| | | | | | | | | | | | | | | | | | Arm has three types of communication buffer - Non secure communication buffer: shared buffer with NS partition - Secure communication buffer: shared buffer with Secure partition - Internal Misc service buffer: For misc service i.e. for services that do not use MmCommunication protocol, a buffer is created and populated internally. Since, internal Misc service buffer is allocated dynamically in StandaloneMm there is no additional check required for the Misc service buffer. This patch move sanity check of communication buffer from StandaloneMmCpu Driver to StandaloneMmEntryPoint. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: Apply embedded stack in StandaloneMmEntryPointLevi Yun2025-01-175-4/+464
| | | | | | | | | | | | | | | | | | | | | | | | | There are 2 communication interfaces between the SPMC and StandaloneMM 1. SpmMM 2. FF-A When SpmMM is enabled, TF-A acts as the SPMC at EL3 and the stack is setup by TF-A for use by StandaloneMm. However, when FF-A is enabled, the SPMC does not setup the stack for StandaloneMm and it is expected that the StandaloneMm code will setup its own stack. Therefore, reserve an area in the data region for use as the stack for StandaloneMM. This stack will be used in both the scenarios described above, i.e. when either SpmMM or FF-A is enabled. Although the stack is reserved from the data section which is expected to be Read-Write enabled, when TF-A maps the StandaloneMM binary into the DRAM it configures the entire StandaloneMM memory as Read-Only. Therefore, before the stack can be utilised, the PE Coff sections need to be scanned to change the the stack region from Read-Only to Read-Write. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmCore: Change log level when mCommunicationBuffer is NULLLevi Yun2025-01-171-1/+1
| | | | | | | | | | | | | | | | | | On Arm all requests are handled as Asynchronous events by the Root MMI handler. Since the communication data is conveyed using either the NS shared buffer or the Secure shared buffer, the Arm implementation does not setup the mCommunicationBuffer. Therefore, the mCommunicationBuffer being NULL is not an error case. Moreover, the existing code switches to Asynchronous event processing when the mCommunicationBuffer is NULL, which means that the log is an info log rather than an error. Therefore, change the log level from ERROR to INFO when the mCommunicationBuffer is NULL. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMm/Library: Apply FF-A v1.2 in StandaloneMmLevi Yun2025-01-174-183/+694
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | To support the service other than Mmcommunication service, StandaloneMm should use FF-A v1.2 or later [0]. For this, StandaloneMm needs to change: 1. apply FF-A boot protocol - FF-A uses its own boot protocol and it can deliver phit hob. So, StandaloneMm should understand FF-A boot protocol and get phit hob from it to initialize. 2. Use DIRECT_REQ2 / DIRECT_RESP2 - To support the other service via FF-A protocol than MmCommunication, StandaloneMm should use DIRECT_REQ2 / DIRECT_RESP2. In case of service provided with MmCommunication protocol, register x2/x3 value is set as gEfiMmCommunication2ProtocolGuid and register x4 value is set with MmCommunication Buffer (ServiceTypeMmCommunication). In case of service with each speicifiation via FF-A, register x2/x3 value is set as each service guid and StandaloneMmCoreEntryPoint genreates Mm communication header with passed arguments to dispatch this service provided by StandaloneMm. i.e) Tpm service, Firmware update service and etc. (ServiceTypeMisc) Link: https://developer.arm.com/documentation/den0077/latest/ [0] Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* ArmPkg: Add ArmFfaLib used in StandaloneMmLevi Yun2025-01-171-0/+1
| | | | | | | Add ArmFfaLib used in StandaloneMmCore/StandaloneMm Driver. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* ArmPkg: Remove PcdFfaEnabledLevi Yun2025-01-171-3/+0
| | | | | | | | | | PcdFfaEnabled is no more used because ArmFfaLib could find whether FF-A is supported dynamically. This patch removes usage of PcdFfaEnabled. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMm/Library: Apply transfer list boot protocol in StandaloneMmLevi Yun2025-01-175-449/+559
| | | | | | | | | | | | | | | To remove hob creation in StandaloneMm entrypoint, TF-A should pass PHIT hob information to StandaloneMm. When it passes PHIT hob, it passes according to firmware handoff specification[0]. This patch applies boot protocol using transfer list with firmware handoff specification and remove hob creation in StandaloneMm entrypoint. Link: https://github.com/FirmwareHandoff/firmware_handoff [0] Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* ArmPkg/IndustryStandard: Change naming convention in ArmMmSvc.hlevi.yun2025-01-171-9/+9
| | | | | | | | | | | | Change naming convention in ArmMmSvc.h with MM to SPM_MM This would make it clear to discern ABI protocol used to communicate with secure partition. Continuous-integration-options: PatchCheck.ignore-multi-package Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMm/Library: Remove Hob creation on Arm CoreHob Librarylevi.yun2025-01-174-434/+3
| | | | | | | | | | | By using transfer list passed by TF-A, StandaloneMmCore is no more producer of HOBs, But it is consumer. So, the Arm-specific implementation of StandaloneMmCoreHobLib is no longer needed. This change removes the Arm-specific HOB creation code and integrates the necessary adjustments. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: Introduce PI_MM_CPU_DRIVER_EP protocol.levi.yun2025-01-1710-75/+138
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch introduces a PI_MM_CPU_DRIVER_EP protocol to handle Mmcommunication request based on the CPU driver. Previously the CPU driver entry point was retrieved using the gEfiArmTfCpuDriverEntryPoint HOB. However, this practice is incorrect as StandaloneMM must be a HOB consumer and not a HOB producer. Therefore, remove the CPU entry HOB gEfiArmTfCpuDriverEntryPoint, and replace it with the CPU driver entry protocol EDKII_PI_MM_CPU_DRIVER_EP_PROTOCOL. The EDKII_PI_MM_CPU_DRIVER_EP_PROTOCOL installed in StandaloneMmCpuInitialize() will be used by the code in Arm/StandaloneMmCoreEntryPoint. This protocol is used like below: +=====+ |StandaloneMmCore| +=====+ | CEntryPoint() =================== | ProcessModuleEntryPointList() | +--> StandaloneMmMain() ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | // Load StandaloneMmCpu driver which implements | // CpuDriverEntryPoint used by DelegatedEventLoop(). | // and install the gEdkiiPiMmCpuDriverEpProtocolGuid. -------------- | ... // Get CpuDriverEntryPoint implemented by // StandaloneMmCpu driver with gEdkiiPiMmCpuDriverEpProtocolGuid | DelegatedEventLoop() // Handle request by delegating it to // CpuDriverEntryPoint. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg: Simplify returning event complete valueslevi.yun2025-01-171-76/+114
| | | | | | | | | | | | | | | | Communication with Stmm can be via SPM using MM or FF-A. However, some return values differ between these communication models. This patch adds helper functions to covert the return values based on the communication model. It also fixes an issue when using the SPM using MM model, wherein an error code value of -7 was being returned when an unknown error occurred. The -7 value is not defined in SPM using MM. Therefore, return an UNSUPPORTED code instead. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
* StandaloneMmPkg/MmIpl: Correct FV HOB check founctionHongbin1 Zhang2025-01-131-6/+3
| | | | | | | | | | | | | | | When at last hob, the FV HOB check function should exit from the loop Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg: Call PeCoffLoaderUnloadImage When Unloading ImageOliver Smith-Denny2025-01-091-29/+42
| | | | | | | | | | | | | | | | | | | | | | | | Today, StandaloneMmCore calls PeCoffLoaderRelocateImage() when loading images, which calls PeCoffLoaderRelocateImageExtraAction(). On AARCH64, this sets the image memory protections accordingly, RO + E on code sections, RW + NX on data sections. However, if an image fails to start (i.e. its entry point returns a failure) StandaloneMmCore does not call the corresponding PeCoffLoaderUnloadImage, which calls PeCoffLoaderUnloadImageExtraAction, which on AARCH64 undoes the memory protections on the image, setting the whole memory region back to RW + NX. The core then frees this memory and the next allocation attempts to use it, which results in a data abort if a read only memory region is attempted to be written to. Theoretically, other instances of the PeCoffExtraActionLib could take other actions and so regardless of architecture, the contract with the PeCoffLoader should be maintained. This patch calls PeCoffLoaderUnloadImage when an image's entry point returns a failure, before freeing the image memory. This meets the contract and follows the DXE core behavior. Signed-off-by: Oliver Smith-Denny <osde@microsoft.com>
* StandaloneMmPkg: Assert if dispatcher fails memory allocationGirish Mahadevan2025-01-091-0/+1
| | | | | | | | | If the Dispatcher fails to allocate memory for the driver that it is trying to load then ASSERT, else the Dispatcher silently stops loading subsequent drivers from the FV. Signed-off-by: Girish Mahadevan <gmahadevan@nvidia.com> Reviewed-by: Jeff Brasen <jbrasen@nvidia.com>
* StandaloneMmPkg/Core: Support to dispatch multiple standalone MM FVsWei6 Xu2024-12-204-39/+134
| | | | | | | Add support to dispatch multiple standalone MM FVs for StandaloneMmCore. Set the maximum supported FV count to 2. Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
* StandaloneMmPkg/MmIpl : Add MM core fv location PPI supportHongbin1 Zhang2024-12-203-6/+43
| | | | | | | | | | | | | | | MmIpl should locate MM core FV location PPI to find current MM FV location. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg : Add MM core fv location PPIHongbin1 Zhang2024-12-202-0/+37
| | | | | | | | | | | | | | | | Add MM core FV location PPI, it will include MM core FV location which could be in FSP-I or Bootloader MM FV. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg/MmIpl : Check if MM FV HOB was builtHongbin1 Zhang2024-12-201-4/+52
| | | | | | | | | | | | | | | Skip MM FV HOB build if MM platform HOB list already has the HOB. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg/MemLib: remove unnecessary checkDun Tan2024-11-055-162/+1
| | | | | | | | | | | | | | | Remove unnecessary check in API MmIsBufferOutsideMmValid of StandaloneMmMemLib. The API is used to check if a input buffer is outside MMRAM and inside a valid non-MMRAM range. Previously, the API only checks if the input buffer is overlapped with MMRAM range. In the last commit, we add logic to check if the input buffer is inside valid non-MMRAM ranges reported by the resource HOB. Since the resource HOB only covers valid non-MMRAM ranges, we doesn't need to check if the input buffer is inside the MMRAM anymore. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/Core: Check Resource HOB and Mmram rangesDun Tan2024-11-051-4/+36
| | | | | | | | | Check if the all the resource HOB in the input HOB list of MmCore entry only covers non-Mmram ranges. The Resource HOB is to describe the accessible non-Mmram range. All Resource HOB should not overlap with any Mmram range. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/Core: add a new InitializeMmHobList()Dun Tan2024-11-051-20/+27
| | | | | | | | Separate a function called InitializeMmHobList() to gather all the operations related to initializing HOB. It doesn't change any code logic. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/MemLib: Check if the non-MMRAM buffer is validDun Tan2024-11-054-1/+284
| | | | | | | | | | | | | | | Check if the non-MMRAM buffer is inside valid non-mmram range in API MmIsBufferOutsideMmValid of StandaloneMmMemLib. Previously, the API only checks if the input buffer is overlapped with MMRAM range. Currently, in the new standalone MM infrastructure, we limit the non-MMRAM access to the ranges reported by the resource HOB. To meet the new design, in this API, we cache all the memory ranges reported by the resource HOB and check if the input buffer is inside valid non-MMRAM ranges reported by the resource HOB. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/MemLib: Add an internal header fileDun Tan2024-11-055-48/+59
| | | | | | | | Add a internal header file for StandaloneMmMemLib. Move some common reference and declaration into StandaloneMmMemLibInternal.h. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/Core: Remove unneeded checkDun Tan2024-11-051-7/+1
| | | | | | | | | | | | | | | | | | | | Remove unneeded check MmIsBufferOutsideMmValid() when StandaloneMmCore checks if the BS data memory described by a memory allocation HOB needs to be migrated to Mmram. Currently, the API MmIsBufferOutsideMmValid() return TRUE when input memory range belongs to non-Mmram memory. Now the API will be changed in following 5 commits to return TRUE when a memory range belongs to non-Mmram memroy and the memory is inside a range described by resource HOB. This may cause PF when some SMI handler access the memory from a memory allocation HOB that is not migrated. To solve this issue, we can directly remove the check MmIsBufferOutsideMmValid() and always migrate the BS data memory described by a memory allocation HOB to Mmram. Signed-off-by: Dun Tan <dun.tan@intel.com>
* StandaloneMmPkg/MmIpl: Optimize hob pointer check flowHongbin1 Zhang2024-11-051-7/+6
| | | | | | | | | | | | | | | | Clang compile will optimize undefined behavior (UB) like a pointer with NULL + size, so it is better to check the pointer before using it. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg/MmIpl: Max physical address bits if disable 5 page levelHongbin1 Zhang2024-10-311-0/+55
| | | | | | | | | | | | | | | | | | | 4-level paging supports translating 48-bit linear addresses to 52-bit physical addresses. Since linear addresses are sign-extended, the linear-address space of 4-level paging is: [0, 2^47-1] and [0xffff8000_00000000, 0xffffffff_ffffffff]. So only [0, 2^47-1] linear-address range maps to the identical physical-address range when 5-Level paging is disabled. Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Cc: Wei6 Xu <wei6.xu@intel.com> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Supreeth Venkatesh <supreeth.venkatesh@arm.com>
* StandaloneMmPkg/Core: Shadow Standalone BFV into MMRAMWei6 Xu2024-10-304-17/+28
| | | | | | | | | | | | | | | | BFV is outside the MMRAM. Currently, StandaloneMmIplPei uses the API MmUnblockMemoryRequest() to unblock the access for the BFV. However, the BFV's memory might be gone after ExitBootService event. If any access to the memory, unexpected error would happen. To fix the above issue, StandaloneMmCore should shadow standalone BFV into MMRAM before processing it, then free the shadowed BFV after MM driver dispatch is done. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>
* StandaloneMmPkg/Core: Reset IsCommBufferValid to FALSE before MMI exitsWei6 Xu2024-10-291-4/+5
| | | | | | | | | | | | | | | | | | | In current implementation of MmCommunication, caller (StandaloneMmIplPei or MmCommunicationDxe) sets the IsCommBufferValid to TRUE and triggers synchronous MMI, then caller resets IsCommBufferValid to FLASE after MMI exits. If asynchronous MMI happens before caller resets the IsCommBufferValid to FALSE, StandaloneMmCore will mistakenly thought there is still a synchronous MMI and then update incorrect values into ReturnStatus and ReturnBufferSize. To fix the above issue, StandaloneMmCore should reset IsCommBufferValid to FALSE before MMI exits. Cc: Ard Biesheuvel <ardb+tianocore@kernel.org> Cc: Sami Mujawar <sami.mujawar@arm.com> Cc: Ray Ni <ray.ni@intel.com> Cc: Jiaxin Wu <jiaxin.wu@intel.com> Signed-off-by: Wei6 Xu <wei6.xu@intel.com>