Commit Graph

161 Commits

Author SHA1 Message Date
Oliver Smith-Denny 7b4b1d2bd3 StandaloneMmPkg: Add StackCheckLib
Remove the old stack check lib now that MdeLibs.inc includes
the new one.

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-13 03:58:46 +00:00
Oliver Smith-Denny 8f74b95a21 MdePkg: Move CompilerIntrinsicsLib from ArmPkg
As per the emailed RFC in
https://edk2.groups.io/g/devel/topic/rfc_move/107675828,
this patch moves CompilerIntrinsicsLib from ArmPkg to
MdePkg as this library provides compiler intrinsics, which
are industry standard.

This aligns with the goal of integrating ArmPkg into existing
packages: https://bugzilla.tianocore.org/show_bug.cgi?id=4121.

The newly placed CompilerIntrinsicsLib is added to MdeLibs.dsc.inc
as every DSC that builds ARM/AARCH64 needs this library added. The
old location is removed from every DSC in edk2 in this commit also
to not break bisectability with minimal hoop jumping.

Continuous-integration-options: PatchCheck.ignore-multi-package

Signed-off-by: Oliver Smith-Denny <osde@linux.microsoft.com>
2024-09-12 19:36:59 +00:00
Hongbin1 Zhang 58b4bf7b7e StandaloneMmPkg/MmIpl: Correct unblocked memory regions attribute
When CPU smm profile feature was enabled, unblocked memory should
not set logging attribute when building resource 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>
2024-09-11 08:29:46 +00:00
Joey Vagedes 6e727ed9dd StandaloneMmPkg/StandaloneMmPkg.ci.yaml: Add PrEval CI config
Adds an entry to the package's CI configuration file that enable policy
5 for stuart_pr_eval. With this Policy, all INFs used by the package are
extracted from the provided DSC file and compared against the list of
changed *.inf (INF) files in the PR. If there is a match, stuart_pr_eval
will specify that this package is affected by the PR and needs to be
tested.

Signed-off-by: Joey Vagedes <joey.vagedes@gmail.com>
2024-09-02 23:20:35 +00:00
Wei6 Xu d5c7bba504 StandaloneMmPkg: Restart dispatcher once MM entry is registered for X64
X64 arch needs to restart the MM dispatcher once MM entry point is
registered, therefore set PcdRestartMmDispatcherOnceMmEntryRegistered
to TRUE by default for X64 only.

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>
2024-08-30 18:27:36 +00:00
Wei6 Xu cfaccc89a2 StandaloneMmPkg/Core: Migrate Memory Allocation Hob into MMRAM
If a Memory Allocation Hob with EfiBootServicesData memory type is
reported into MM Hob List and it also has a non-zero GUID name, then the
HOB is used by MM driver and needs to migrate the memory into MMRAM.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 6b69f564a9 StandaloneMmPkg/Core: Add MemoryAttributes support
The MM memory attribute table is ported from SMM Core.

The new file StandaloneMmPkg/Core/MemoryAttributesTable.c, the new code
in StandaloneMmPkg/Core/Page.c and StandaloneMmPkg/Core/Pool.c are
almost identical to MdeModulePkg/Core/PiSmmCore/MemoryAttributesTable.c,
MdeModulePkg/Core/PiSmmCore/Page.c and
MdeModulePkg/Core/PiSmmCore/Pool.c, but changing the word 'SMM' to 'MM'.

Different from SMM Core, Standalone MM Core produces MM MemoryAttributes
table at the end of MmDriverDispatchHandler() when all the drivers are
dispatched, rather than at the MmEndOfDxe event.

Then the MM CPU driver will consumes the table to set memory attribute
in page table.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu b7931cafea StandaloneMmPkg/Core: Install protocol to notify MmEndOfPei event
When the EndOfPei event is signaled, installs the MM EndOfPei Protocol
so MM Drivers are informed that EndOfPei event is signaled.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu c8df60801f StandaloneMmPkg: Support using gEfiSmmSmramMemoryGuid to get MMRAM range
Add the support using gEfiSmmSmramMemoryGuid to get MMRAM ranges.
If gEfiSmmSmramMemoryGuid HOB is not found, then try to get MMRAM ranges
from gEfiMmPeiMmramMemoryReserveGuid HOB.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 487fa274c4 StandaloneMmPkg/Core: Restart dispatcher once MmEntryPoint is registered
Defer the dispatch of the remaining MM drivers once the CPU driver has
been dispatched.

In MmDispatcher, return immediately if the MM Entry Point was registered.
Then the MM IPL will reinvoke the MM Core Dispatcher. This is required
so MM Mode may be enabled as soon as all the dependent MM Drivers for MM
Mode have been dispatched.

Introduce a FeatureFlag PCD to control if MmDispatcher returns or not
when MmEntryPointPoint is registered. Default value is FALSE.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 003a4d4ef4 StandaloneMmPkg/Core: Remove unused mMmramRanges and mMmramRangeCount
mMmramRanges and mMmramRangeCount are the global variables that are
used to cache the MMRAM Ranges info, but they are not used in MM Core.
Therefore, remove mMmramRanges and mMmramRangeCount.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu f0254c9a1c StandaloneMmPkg: Remove definition for MM_CORE_PRIVATE_DATA
MM_CORE_PRIVATE_DATA is not used as shared structures between MM IPL
and MM Core, therefore clean up definition for MM_CORE_PRIVATE_DATA.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 0f89005d71 StandaloneMmMemLib: Drop MM_CORE_PRIVATE_DATA
MM_CORE_PRIVATE_DATA is not used as shared structures between MM IPL
and MM Core, therefore clean up the code related to gMmCorePrivate.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 189398dcf8 StandaloneMmCoreMemoryAllocationLib: Drop MM_CORE_PRIVATE_DATA
MM_CORE_PRIVATE_DATA is not used as shared structures between MM IPL
and MM Core, therefore clean up the code related to gMmCorePrivate.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 18591343b2 StandaloneMmPkg/Core: Drop MM_CORE_PRIVATE_DATA
MM_CORE_PRIVATE_DATA is not used as shared structures between MM IPL
and MM Core, therefore clean up the code related to gMmCorePrivate.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 24e41d1fa3 StandaloneMmPkg/Core: Introduce MM Communication Buffer
Get the MM Communication context from the MM Communication Buffer,
instead of the pointer inside gMmCorePrivate.
In the MmEntryPoint, check IsCommBufferValid from MM_COMM_BUFFER to
decide whether the MMI is Synchronous MMI or Asynchronous MMI. If it
is a Synchronous MMI, MM Core shadows the communication buffer into
a internal copy, then invokes the MMI handlers, lastly copies data
back to the MM Communication Buffer and set the return status.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 68487b4736 StandaloneMmPkg/Core: Switch to MM HobList after MM HostList is ready
Switch to MM HobList as soon as MM HostList is initialized to avoid
StandaloneMmCore still using the HobList which is outside of MMRAM.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu dd775aa4d4 StandaloneMmPkg/Core: Install Loaded Image Protocol for MM Core
Retrieves the MM Core image info from Memory Allocation HOB reported
by MM IPL. Then install Loaded Image Protocol for MM Core with the
image info from HOB.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu a44830727a StandaloneMmPkg/Core: Install Loaded Image Protocol for MM drivers
Install Loaded Image Protocol into MM handle database for each MM
driver.
Change EFI_MM_DRIVER_ENTRY structure definition to hold the Loaded
Image Protocol data directly, instead a pointer to the protocol, to
avoid allocating pool for each MM driver.

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>
2024-08-28 15:25:27 +00:00
Wei6 Xu 6dc14fb5b4 StandaloneMmPkg/Core: Remove traditional MM driver support
StandaloneMmCore should not support dispatching traditional MM
driver which has dependency on UEFI services. Therefore, remove
the related code that supports traditional MM driver.

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>
2024-08-28 15:25:27 +00:00
Zhang Hongbin 6855567d52 StandaloneMmPkg/MmIpl: Create memory resource HOBs
If PcdCpuSmmRestrictedMemoryAccess is TRUE, only unblocked memory
Regions are available, if FALSE, all system memory is available.

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>
2024-08-28 15:25:27 +00:00
Zhang Hongbin 378aff173c StandaloneMmPkg/MmIpl: Create MM profile data HOBs
Create memory allocation and resource HOB for MM profile data

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>
2024-08-28 15:25:27 +00:00
Zhang Hongbin c775cc762e StandaloneMmPkg/MmIpl: Create misc HOBs for CPU
Create misc HOBs for CPU, it included MM ACPI S3 Enable HOB,
MM CPU sync configuration HOB, CPU SMM base HOB, SMRAM memory HOB,
MP Information2 HOB and ACPI variable 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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang 0d91ebd96f StandaloneMmPkg/MmIpl: Create standalone MM foundation related HOBs
Create the HobList which included the HOBs Standalone MM foundation needed,
it included communication buffer HOB, StandaloneMm Core module HOB and
StandaloneMm Core FV 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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang 5aa5ecd5ff StandaloneMmPkg/MmIpl: Dispatch StandaloneMm drivers in MM
MmIpl will issue a SWSMI by MM communicate to call gEventMmDispatchGuid
handler to dispatch all StandaloneMm drivers

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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang 3ac296def1 StandaloneMmPkg/MmIpl: Install end of PEI notify PPI
Install end of PEI notify PPI for issue gEfiMmEndOfPeiProtocol
Handler in MM

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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang e98eca076a StandaloneMmPkg/MmIpl: Install MmCommunicationPpi
Install MmCommunicationPpi under PEI stage, PEIM could
use this PPI to communicate with MM handler

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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang 8d764088ea StandaloneMmPkg/MmIpl: load MM Core and execute MM Core in MM RAM
StandaloneMmIplPei will search the MM Core driver in all FV and relocate
it to MM RAM, and enter MM Core entrypoint to run MM Core.

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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang d7e6b863a1 StandaloneMmPkg/MmIpl: build MM communication buffer HOB
MM communication buffer HOB data is for StandaloneMm Core and
MM communicate DXE driver.

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>
2024-08-28 15:25:27 +00:00
Hongbin1 Zhang e363c0b729 StandaloneMmPkg/MmIpl: StandaloneMmIplPei driver entrypoint
StandaloneMmIplPei driver entrypoint for adding StandaloneMm
Ipl feature code under PEI stage.

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>
2024-08-28 15:25:27 +00:00
Dun Tan d64766bde6 StandaloneMmPkg: Create some notification of protocol and Event
Create the notifications of some protocols and event that
the Standalone Mm requires in MmCommunicationDxe:
   gEfiDxeMmReadyToLockProtocolGuid
   gEfiEventExitBootServicesGuid
   gEfiEventVirtualAddressChangeGuid
   gEfiEndOfDxeEventGroupGuid
   gEfiEventReadyToBootGuid

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-08-28 15:25:27 +00:00
Dun Tan a2a8558958 StandaloneMmPkg: Install gEfiMmCommunicationProtocolGuid
Install gEfiMmCommunicationProtocolGuid instance in the
MmCommunicationDxe driver.

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-08-28 15:25:27 +00:00
Dun Tan cf9b568405 StandaloneMmPkg: Install gEfiMmCommunication2ProtocolGuid
Install gEfiMmCommunication2ProtocolGuid in the
MmCommunicationDxe driver.

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-08-28 15:25:27 +00:00
Dun Tan eef29d5100 StandaloneMmPkg: Add a new MmCommunicationDxe driver
Add a new MmCommunicationDxe driver. The driver is to:
  
1.Install gEfiMmCommunication2ProtocolGuid
  
2.Install gEfiMmCommunicationProtocolGuid
  
3.Create the notifications of some protocols and event that
    the Standalone Mm requires

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-08-28 15:25:27 +00:00
Dun Tan 0806fb60d4 StandaloneMmPkg: Create null instance for MmPlatformHobProducerLib
Create null instance MmPlatformHobProducerLibNull.inf for
MmPlatformHobProducerLib.

Signed-off-by: Dun Tan <dun.tan@intel.com>
2024-08-28 15:25:27 +00:00
Jiaxin Wu 630e819bf3 StandaloneMmPkg/StandaloneMmPkg.ci.yaml: Add UefiCpuPkg dependency
StandaloneMmPkg need to use header file defined under UefiCpuPkg
to support StandaloneMm features.

Signed-off-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
Acked-by: Jiaxin Wu <jiaxin.wu@intel.com>
2024-08-28 15:25:27 +00:00
Jiaxin Wu 56908fd4be StandaloneMmPkg/StandaloneMmPkg.dec: Add gEventMmDispatchGuid
MmIpl shall use gEventMmDispatchGuid to initialize
EFI_MM_COMMUNICATE_HEADER structure, and then communicate with MmCore
to dispatch all StandaloneMm drivers in SMM environment.

Signed-off-by: Jiaxin Wu <jiaxin.wu@intel.com>
Co-authored-by: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Co-Authored-by: Ray Ni <ray.ni@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Star Zeng <star.zeng@intel.com>
Co-Authored-by: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
2024-08-28 15:25:27 +00:00
Dun Tan 43e8801410 StandaloneMmPkg: Add MmPlatformHobProducerLib library class
CreateMmPlatformHob() is defined in the MmPlatformHobProducerLib
library class. The function is for StandaloneMm IPL to create all
Platform specific HOBs that required by the Standalone MM env.

Signed-off-by: Dun Tan <dun.tan@intel.com>
Co-authored-by: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Co-authored-by: Ray Ni <ray.ni@intel.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Yuanhao Xie <yuanhao.xie@intel.com>
2024-08-28 15:25:27 +00:00
xieyuanh a9158fe9a6 StandaloneMmPkg: Enable SmmLockBoxMmDependency.
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-07-31 19:49:24 +00:00
xieyuanh 3ada6c0db6 StandaloneMmPkg: Add LockBox Dependency Library
The LockBox Dependency Library is designed for standalone MM
environments where gBS are not accessible to indicates that LockBox API
is readyfor use.

For DXE drivers use lockbox APIs via a communication mechanism
triggering an SMI, it's must to have the corresponding SMI handler
pre-installed for interrupt management. To ensure orderly operations
and proper notification, besides specified the guid in
the [Depex] section of the .inf file. The installation of smi handler,
along with the LockBox protocol marked by gEfiLockBoxProtocolGuid,
must be informed to the DXE driver. This protocol installation signifies
that the LockBox API is ready for use, and this functionality is
implemented in the constructor of this library.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Hongbin1 Zhang <hongbin1.zhang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Dun Tan <dun.tan@intel.com>

Reviewed-by: Jiaxin Wu <jiaxin.wu@intel.com>

Signed-off-by: Yuanhao Xie <yuanhao.xie@intel.com>
2024-07-31 19:49:24 +00:00
Wei6 Xu 049e12c03d StandaloneMmPkg/Core: Dump all HOB info in entrypoint
Print HOB information at top of StandaloneMmMain().

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>
2024-07-07 10:12:36 +00:00
Michael Kubacki 051c7bb434 StandaloneMmPkg: Fix section data length returned larger than actual data
This change fixes an issue where the returned section data length
is always 4 bytes larger than the actual section length. This could
cause an issue where the caller accesses the final 4 bytes which
would be invalid.

Co-authored-by: Kun Qin <kuqin@microsoft.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
2024-07-05 13:08:56 +00:00
Zhiguang Liu 30b6d08e27 StandaloneMmPkg: Initialize 'WillReturn' variable
The local variable 'WillReturn' was being used without prior
initialization in some code paths.
This patch ensures that 'WillReturn' is properly initialized
to prevent undefined behavior.

Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2024-05-30 01:57:35 +00:00
Zhiguang Liu 70892b13b2 StandaloneMmPkg: Support to unregister MMI handler in MMI handlers
This patch fix a use-after-free issue where unregistering an
MMI handler could lead to the deletion of the MMI_HANDLER while it is
still in use by MmiManage(). The fix involves modifying
MmiHandlerUnRegister() to detect whether it is being called from
within the MmiManage() stack. If so, the removal of the MMI_HANDLER
is deferred until MmiManage() has finished executing.
Additionally, due to the possibility of recursive MmiManage() calls,
the unregistration and subsequent removal of the MMI_HANDLER are
ensured to occur only after the outermost MmiManage() invocation has
completed.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2024-04-16 04:41:27 +00:00
Zhiguang Liu de95e919be Revert 049ff6c39c
This reverts commit "StandaloneMmPkg: Support to unregister
MMI handler inside MMI handler" for better design later.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2024-04-16 04:41:27 +00:00
Zhiguang Liu 31cd5ee8c0 Revert 2ec8f0c640
This reverts commit "StandaloneMmPkg: Disallow unregister MMI
handler in other MMI handler" for better design later.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
2024-04-16 04:41:27 +00:00
Zhiguang Liu 2ec8f0c640 StandaloneMmPkg: Disallow unregister MMI handler in other MMI handler
In last patch, we add code support to unregister MMI handler inside
itself. However, the code doesn't support unregister MMI handler
insider other MMI handler. While this is not a must-have usage.
So add check to disallow unregister MMI handler in other MMI handler.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Message-Id: <20240301030133.628-5-zhiguang.liu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2024-03-01 18:47:27 +00:00
Zhiguang Liu 049ff6c39c StandaloneMmPkg: Support to unregister MMI handler inside MMI handler
To support unregister MMI handler inside MMI handler itself,
get next node before MMI handler is executed, since LIST_ENTRY that
Link points to may be freed if unregister MMI handler in MMI handler
itself.

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Jiaxin Wu <jiaxin.wu@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Zhiguang Liu <zhiguang.liu@intel.com>
Message-Id: <20240301030133.628-4-zhiguang.liu@intel.com>
2024-03-01 18:47:27 +00:00
Tuan Phan ba9c3ceaf8 StandaloneMmPkg: Arm: Update to use the new StandaloneMmCpu driver
Update entry point library for Arm to use the new architecture independent
StandaloneMmCpu driver.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
Reviewed-by: levi.yun <yeoreum.yun@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2024-02-27 12:27:58 +00:00
Tuan Phan e7a7169446 StandaloneMmPkg: Make StandaloneMmCpu driver architecture independent
StandaloneMmCpu now can supports more architectures like RISC-V besides
ARM/AARCH64.

Signed-off-by: Tuan Phan <tphan@ventanamicro.com>
Reviewed-by: levi.yun <yeoreum.yun@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2024-02-27 12:27:58 +00:00