-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support Standalone MM in ConfigKnobShimLib and Autogen (#183)
# Preface Please ensure you have read the [contribution docs](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md) prior to submitting the pull request. In particular, [pull request guidelines](https://github.com/microsoft/mu/blob/master/CONTRIBUTING.md#pull-request-best-practices). ## Description Add Standalone MM support to ConfigKnobShimLib and the autogenerated headers so that standalone MM modules can use the configuration interfaces provided by mu_feature_config. This switches to using PolicyLib as the interface to policy code in the autogenerated header and adds a standalone MM appropriate get variable interface to ConfigKnobShimLib. For each item, place an "x" in between `[` and `]` if true. Example: `[x]`. _(you can also check items in the GitHub UI)_ - [x] Impacts functionality? - **Functionality** - Does the change ultimately impact how firmware functions? - Examples: Add a new library, publish a new PPI, update an algorithm, ... - [ ] Impacts security? - **Security** - Does the change have a direct security impact on an application, flow, or firmware? - Examples: Crypto algorithm change, buffer overflow fix, parameter validation improvement, ... - [ ] Breaking change? - **Breaking change** - Will anyone consuming this change experience a break in build or boot behavior? - Examples: Add a new library class, move a module to a different repo, call a function in a new library class in a pre-existing module, ... - [x] Includes tests? - **Tests** - Does the change include any explicit test code? - Examples: Unit tests, integration tests, robot tests, ... - [x] Includes documentation? - **Documentation** - Does the change contain explicit documentation additions outside direct code modifications (and comments)? - Examples: Update readme file, add feature readme file, link to documentation on an a separate Web page, ... ## How This Was Tested Tested on a physical platform with standalone MM config knobs enabled. ## Integration Instructions Follow the integration instructions inthe docs section of this repository, ensuring there is a separate config XML for standalone MM.
- Loading branch information
Showing
18 changed files
with
329 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Library/ConfigKnobShimLib/ConfigKnobShimDxeLib/UnitTest/ConfigKnobShimDxeLibUnitTest.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
.../Library/ConfigKnobShimLib/ConfigKnobShimPeiLib/UnitTest/ConfigKnobShimPeiLibUnitTest.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
80 changes: 80 additions & 0 deletions
80
...g/Library/ConfigKnobShimLib/ConfigKnobShimStandaloneMmLib/ConfigKnobShimStandaloneMmLib.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** @file ConfigKnobShimStandaloneMmLib.c | ||
Library interface for an OEM config policy creator to call into to fetch overrides for config values. | ||
Copyright (c) Microsoft Corporation. | ||
SPDX-License-Identifier: BSD-2-Clause-Patent | ||
**/ | ||
#include <PiPei.h> | ||
#include <Uefi.h> | ||
#include <Library/BaseLib.h> | ||
#include <Library/DebugLib.h> | ||
#include <Library/PeiServicesLib.h> | ||
#include <Library/MmServicesTableLib.h> | ||
#include <Protocol/SmmVariable.h> | ||
|
||
#include "../ConfigKnobShimLibCommon.h" | ||
|
||
/** | ||
GetConfigKnobFromVariable returns the configuration knob from variable storage if it exists. This function is | ||
abstracted to work with PEI, DXE, and Standalone MM. | ||
This function is only expected to be called by GetConfigKnobOverride. | ||
@param[in] ConfigKnobGuid The GUID of the requested config knob. | ||
@param[in] ConfigKnobName The name of the requested config knob. | ||
@param[out] ConfigKnobData The retrieved data of the requested config knob. The caller will allocate memory for | ||
this buffer and is responsible for freeing it. This parameter is acceptable to be | ||
NULL if the data size is all that is requested. | ||
@param[in out] ConfigKnobDataSize The allocated size of ConfigKnobData. This is expected to be set to the correct | ||
value for the size of ConfigKnobData. If this size is too small for the config knob, | ||
EFI_BUFFER_TOO_SMALL will be returned. This represents a mismatch in the profile | ||
expected size and what is stored in variable storage, so the profile value will | ||
take precedence. | ||
@retval EFI_NOT_FOUND The requested config knob was not found in the policy cache or variable storage. This | ||
is expected when the config knob has not been updated from the profile default. | ||
@retval EFI_BUFFER_TOO_SMALL ConfigKnobDataSize as passed in was too small for this config knob. This is expected | ||
if stale variables exist in flash. | ||
@retval EFI_NOT_READY Variable Services not available. | ||
@retval !EFI_SUCCESS Failed to read variable from variable storage. | ||
@retval EFI_SUCCESS The operation succeeds. | ||
**/ | ||
EFI_STATUS | ||
GetConfigKnobFromVariable ( | ||
IN EFI_GUID *ConfigKnobGuid, | ||
IN CHAR16 *ConfigKnobName, | ||
OUT VOID *ConfigKnobData, | ||
IN OUT UINTN *ConfigKnobDataSize | ||
) | ||
{ | ||
EFI_STATUS Status; | ||
EFI_SMM_VARIABLE_PROTOCOL *MmVariableServices; | ||
|
||
Status = gMmst->MmLocateProtocol ( | ||
&gEfiSmmVariableProtocolGuid, | ||
NULL, | ||
(VOID **)&MmVariableServices | ||
); | ||
|
||
if (EFI_ERROR (Status)) { | ||
DEBUG (( | ||
DEBUG_ERROR, | ||
"%a: Failed to locate variable services with status %r, falling back to profile value for config knob %a\n", | ||
__FUNCTION__, | ||
Status, | ||
ConfigKnobName | ||
)); | ||
|
||
return Status; | ||
} | ||
|
||
return MmVariableServices->SmmGetVariable ( | ||
ConfigKnobName, | ||
ConfigKnobGuid, | ||
NULL, | ||
ConfigKnobDataSize, | ||
ConfigKnobData | ||
); | ||
} |
46 changes: 46 additions & 0 deletions
46
...Library/ConfigKnobShimLib/ConfigKnobShimStandaloneMmLib/ConfigKnobShimStandaloneMmLib.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
## @file | ||
# Library interface for an OEM config policy creator to call into to fetch overrides for config values. | ||
# | ||
# Copyright (c) Microsoft Corporation | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
# | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010017 | ||
BASE_NAME = ConfigKnobShimStandaloneMmLib | ||
FILE_GUID = 675EE92E-8771-413A-8BBE-B87152B910E2 | ||
VERSION_STRING = 1.0 | ||
MODULE_TYPE = MM_STANDALONE | ||
LIBRARY_CLASS = ConfigKnobShimLib | ||
PI_SPECIFICATION_VERSION = 0x00010032 | ||
|
||
# | ||
# The following information is for reference only and not required by the | ||
# build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 AARCH64 | ||
# | ||
|
||
[Sources] | ||
ConfigKnobShimStandaloneMmLib.c | ||
../ConfigKnobShimLibCommon.c | ||
../ConfigKnobShimLibCommon.h | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
SetupDataPkg/SetupDataPkg.dec | ||
|
||
[LibraryClasses] | ||
BaseLib | ||
DebugLib | ||
BaseMemoryLib | ||
MmServicesTableLib | ||
|
||
[Protocols] | ||
gEfiSmmVariableProtocolGuid ## CONSUMES | ||
|
||
[Depex] | ||
# Platforms can decide whether variable services are a requirement for config or not | ||
gEfiSmmVariableProtocolGuid |
40 changes: 40 additions & 0 deletions
40
...bShimLib/ConfigKnobShimStandaloneMmLib/UnitTest/ConfigKnobShimStandaloneMmLibUnitTest.inf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
## @file | ||
# Unit tests of the ConfigKnobShimExampleStandaloneMmLib instance. | ||
# | ||
# Copyright (c) Microsoft Corporation. | ||
# SPDX-License-Identifier: BSD-2-Clause-Patent | ||
## | ||
|
||
[Defines] | ||
INF_VERSION = 0x00010017 | ||
BASE_NAME = ConfigKnobShimStandaloneMmUnitTest | ||
FILE_GUID = EA4B9417-78FC-474E-AC35-44AFF09E9099 | ||
MODULE_TYPE = HOST_APPLICATION | ||
VERSION_STRING = 1.0 | ||
|
||
# | ||
# The following information is for reference only and not required by the build tools. | ||
# | ||
# VALID_ARCHITECTURES = IA32 X64 AARCH64 | ||
# | ||
|
||
[Sources] | ||
../../UnitTest/ConfigKnobShimLibUnitTestCommon.c | ||
../ConfigKnobShimStandaloneMmLib.c | ||
../../ConfigKnobShimLibCommon.c | ||
|
||
[Packages] | ||
MdePkg/MdePkg.dec | ||
MdeModulePkg/MdeModulePkg.dec | ||
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec | ||
SetupDataPkg/SetupDataPkg.dec | ||
|
||
[LibraryClasses] | ||
BaseLib | ||
BaseMemoryLib | ||
DebugLib | ||
MmServicesTableLib | ||
UnitTestLib | ||
|
||
[Protocols] | ||
gEfiSmmVariableProtocolGuid ## CONSUMES |
Oops, something went wrong.