Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactoring the MM implementation to support both Standalone MM and Traditional MM #461

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion PolicyServicePkg/Library/MmPolicyLib/MmPolicyLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
FILE_GUID = C2A9C781-8D58-46DA-BC39-5385AB8D5C8A
MODULE_TYPE = MM_STANDALONE
VERSION_STRING = 1.0
LIBRARY_CLASS = PolicyLib | MM_STANDALONE
LIBRARY_CLASS = PolicyLib | DXE_SMM_DRIVER MM_STANDALONE

[Sources]
../PolicyLibCommon.c
Expand Down
13 changes: 4 additions & 9 deletions PolicyServicePkg/PolicyService/DxeMm/PolicyMm.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/** @file
Implements the Standalone MM policy protocol, providing services to publish and
Implements the MM policy protocol, providing services to publish and
access system policy.

Copyright (c) Microsoft Corporation
Expand Down Expand Up @@ -87,20 +87,15 @@ InstallPolicyIndicatorProtocol (
}

/**
Entry to the Standalone MM policy service module.

@param[in] ImageHandle The image handle.
@param[in] SystemTable The system table.
Common Entry of the MM policy service module.

@retval Status From internal routine or boot object, should not fail
**/
EFI_STATUS
EFIAPI
PolicyStandaloneEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_MM_SYSTEM_TABLE *SystemTable
PolicyMmCommonEntry (
VOID
)

{
EFI_STATUS Status;

Expand Down
3 changes: 2 additions & 1 deletion PolicyServicePkg/PolicyService/DxeMm/PolicyMm.inf
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
FILE_GUID = 9FF65AAD-5982-4609-9702-05EFD584148C
MODULE_TYPE = MM_STANDALONE
VERSION_STRING = 1.0
ENTRY_POINT = PolicyStandaloneEntry
ENTRY_POINT = PolicyStandaloneMmEntry

[Sources]
PolicyStandaloneMm.c
PolicyMm.c
PolicyCommon.c
PolicyCommon.h
Expand Down
40 changes: 40 additions & 0 deletions PolicyServicePkg/PolicyService/DxeMm/PolicyStandaloneMm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/** @file
Implements the Standalone MM policy protocol, providing services to publish and
access system policy.

Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Uefi.h>
#include <Library/MmServicesTableLib.h>

/**
Common Entry of the MM policy service module.

@retval Status From internal routine or boot object, should not fail
**/
EFI_STATUS
EFIAPI
PolicyMmCommonEntry (
VOID
);

/**
Entry to the Standalone MM policy service module.

@param[in] ImageHandle The image handle.
@param[in] SystemTable The system table.

@retval Status From internal routine or boot object, should not fail
**/
EFI_STATUS
EFIAPI
PolicyStandaloneMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_MM_SYSTEM_TABLE *SystemTable
)
{
return PolicyMmCommonEntry ();
}
39 changes: 39 additions & 0 deletions PolicyServicePkg/PolicyService/DxeMm/PolicyTraditionalMm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/** @file
Implements the Traditional MM policy protocol, providing services to publish and
access system policy.

Copyright (c) Microsoft Corporation
SPDX-License-Identifier: BSD-2-Clause-Patent

**/

#include <Uefi.h>

/**
Common Entry of the MM policy service module.

@retval Status From internal routine or boot object, should not fail
**/
EFI_STATUS
EFIAPI
PolicyMmCommonEntry (
VOID
);

/**
Entry to the Traditional MM policy service module.

@param[in] ImageHandle The image handle.
@param[in] SystemTable The system table.

@retval Status From internal routine or boot object, should not fail
**/
EFI_STATUS
EFIAPI
PolicyTraditionalMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
return PolicyMmCommonEntry ();
}
47 changes: 47 additions & 0 deletions PolicyServicePkg/PolicyService/DxeMm/PolicyTraditionalMm.inf
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
## @file
#
# This is a driver for Traditional MM policy service module.
#
# Copyright (C) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010017
PI_SPECIFICATION_VERSION = 0x00010032
BASE_NAME = PolicyTraditionalMm
FILE_GUID = 51084E31-393D-4D06-A867-BDE321D4E4F5
MODULE_TYPE = DXE_SMM_DRIVER
VERSION_STRING = 1.0
ENTRY_POINT = PolicyTraditionalMmEntry

[Sources]
PolicyTraditionalMm.c
PolicyMm.c
PolicyCommon.c
PolicyCommon.h

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
PolicyServicePkg/PolicyServicePkg.dec

[LibraryClasses]
BaseLib
DebugLib
HobLib
UefiDriverEntryPoint
MmServicesTableLib
MemoryAllocationLib

[Pcd]

[Guids]
gPolicyHobGuid

[Protocols]
gMmPolicyProtocolGuid ## PRODUCES

[Depex]
TRUE
1 change: 1 addition & 0 deletions PolicyServicePkg/PolicyServicePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
[Protocols]
## Include/Protocol/Policy.h
gPolicyProtocolGuid = { 0xd7c9b744, 0x13a5, 0x4377, { 0x8d, 0x2a, 0x6b, 0x37, 0xad, 0x1f, 0xd8, 0x2a } }
## Include/Protocol/MmPolicy.h
gMmPolicyProtocolGuid = { 0xe55ad3a1, 0xbd34, 0x46f4, { 0xbb, 0x6e, 0x72, 0x28, 0x0b, 0xdc, 0xbf, 0xd9 } }
9 changes: 8 additions & 1 deletion PolicyServicePkg/PolicyServicePkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,24 @@
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
PolicyLib|PolicyServicePkg/Library/DxePolicyLib/DxePolicyLib.inf

[LibraryClasses.common.DXE_SMM_DRIVER]
MemoryAllocationLib|MdePkg/Library/SmmMemoryAllocationLib/SmmMemoryAllocationLib.inf
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf

[LibraryClasses.common.MM_STANDALONE]
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
HobLib|StandaloneMmPkg/Library/StandaloneMmHobLib/StandaloneMmHobLib.inf
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
PolicyLib|PolicyServicePkg/Library/MmPolicyLib/MmPolicyLib.inf

[Components]
PolicyServicePkg/PolicyService/DxeMm/PolicyDxe.inf
PolicyServicePkg/PolicyService/DxeMm/PolicyMm.inf
PolicyServicePkg/PolicyService/DxeMm/PolicyTraditionalMm.inf
PolicyServicePkg/PolicyService/Pei/PolicyPei.inf
PolicyServicePkg/Library/DxePolicyLib/DxePolicyLib.inf
PolicyServicePkg/Library/PeiPolicyLib/PeiPolicyLib.inf
Expand Down
6 changes: 3 additions & 3 deletions PolicyServicePkg/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -207,19 +207,19 @@ Like the PEIM, the DXE driver will install/reinstall a NULL protocol with the
given policies GUID when it is created or updated to allow for notification and
dispatch on the policy availability.

### Standalone MM
### Traditional/Standalone MM

Like the DXE phase, the MM policy service will ingest any policies from the HOB
list for architectures. The MM policy service is implemented identically to the
DXE phase module with the exception of using the MM specific protocols.

Policies in the MM service are isolated from PEI and DXE. The MM module will ingest
any policies available in the hob list from PEI where applicable but no policies
created or modified by PEI or DXE after Standalone MM has been launched will be
created or modified by PEI or DXE after Traditional/Standalone MM has been launched will be
available from the MM policy service. Similarly, no policy created or edited in
the MM policy service will be readable from the PEI or DXE policies services.

Policies are not shared with the standalone MM module after initialization. Any
Policies are not shared with the traditional/standalone MM module after initialization. Any
policy created in MM will not be readable by DXE and PEI, and any policy made after
MM initialization will not be readable from MM.

Expand Down