Skip to content

Commit

Permalink
Update TestPointStubDxeMm to correctly print MM test results when usi…
Browse files Browse the repository at this point in the history
…ng Standalone MM. (#176)

## Description

Currently when running the TestPointDump efi from the uefi shell only
PEI and DXE results will be printed out when using Standalone MM. This
change fixes the issue where the memory that stored the SMM testing
results structure consumed by TestPointDump wasn't being created.

This is due to the memory pages being blocked by MM and then trying to
use them in the MM user data buffer. This change unwinds that buffer as
it's essentially a pointer in the MM comm buffer. Now we use the comm
buffer itself to store the MM test point data that we report through the
TestPointStubDxeMm driver.

Additionally, identifiers are now being used in the tests when updating
verified features to fill the correct phase data structure. This makes
test reporting in the dump app more clear.

For each item, place an "x" in between `[` and `]` if true. Example:
`[x]`.
_(you can also check items in the GitHub UI)_

- [ ] 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, ...
- [ ] 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 several different silicon families using Standalone MM. The MM
test results are now being correctly published.

## Integration Instructions

N/A
  • Loading branch information
kenlautner authored Sep 21, 2023
1 parent 2e42b2e commit 6d81e0d
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 97 deletions.
12 changes: 6 additions & 6 deletions MinPlatformPkg/Include/Library/TestPointLib.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,12 @@ typedef struct {
// On output, actual data buffer size copied.
//
UINT64 DataSize;
PHYSICAL_ADDRESS DataBuffer;
//
// On input, data buffer offset to copy.
// On output, next time data buffer offset to copy.
//
UINT64 DataOffset;
// MU_CHANGE - START
// Empty array that represents the start of the
// data being stored in the comm buffer we're getting
// from the MM environment.
UINT8 Data[];
// MU_CHANGE - END
} MMI_HANDLER_TEST_POINT_PARAMETER_GET_DATA_BY_OFFSET;

extern EFI_GUID gAdapterInfoPlatformTestPointGuid;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Protocol/SmmAccess2.h>
#include <Protocol/MmAccess.h> // MU_CHANGE

CHAR8 *mSmramStateName[] = {
"Open",
Expand Down Expand Up @@ -110,13 +110,13 @@ TestPointCheckSmmInfo (
)
{
EFI_STATUS Status;
EFI_SMM_ACCESS2_PROTOCOL *SmmAccess;
EFI_MM_ACCESS_PROTOCOL *SmmAccess; // MU_CHANGE
UINTN Size;
EFI_SMRAM_DESCRIPTOR *SmramRanges;

DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmInfo - Enter\n"));

Status = gBS->LocateProtocol (&gEfiSmmAccess2ProtocolGuid, NULL, (VOID **)&SmmAccess);
Status = gBS->LocateProtocol (&gEfiMmAccessProtocolGuid, NULL, (VOID **)&SmmAccess); // MU_CHANGE
if (EFI_ERROR (Status)) {
goto Done ;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ TestPointPciEnumerationDonePciBusMasterDisabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_PCI_ENUMERATION_DONE_BUS_MASTER_DISABLED
);
Expand Down Expand Up @@ -255,7 +255,7 @@ TestPointPciEnumerationDonePciResourceAllocated (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_PCI_ENUMERATION_DONE_RESOURCE_ALLOCATED
);
Expand Down Expand Up @@ -305,7 +305,7 @@ TestPointEndOfDxeDmaAcpiTableFunctional (
} else {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_END_OF_DXE_DMA_ACPI_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -351,7 +351,7 @@ TestPointEndOfDxeDmaProtectionEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_END_OF_DXE_DMA_PROTECTION_ENABLED
);
Expand Down Expand Up @@ -396,7 +396,7 @@ TestPointEndOfDxeNoThirdPartyPciOptionRom (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_END_OF_DXE_NO_THIRD_PARTY_PCI_OPTION_ROM
);
Expand Down Expand Up @@ -441,7 +441,7 @@ TestPointDxeSmmReadyToLockSmramAligned (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
7,
TEST_POINT_BYTE7_DXE_SMM_READY_TO_LOCK_SMRAM_ALIGNED
);
Expand Down Expand Up @@ -492,7 +492,7 @@ TestPointDxeSmmReadyToLockWsmtTableFunctional (
} else {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
7,
TEST_POINT_BYTE7_DXE_SMM_READY_TO_LOCK_WSMT_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -689,7 +689,7 @@ TestPointDxeSmmReadyToBootSmiHandlerInstrument (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
7,
TEST_POINT_BYTE7_DXE_SMM_READY_TO_BOOT_SMI_HANDLER_INSTRUMENT
);
Expand Down Expand Up @@ -734,7 +734,7 @@ TestPointReadyToBootAcpiTableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_ACPI_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -779,7 +779,7 @@ TestPointReadyToBootGcdResourceFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_GCD_RESOURCE_FUNCTIONAL
);
Expand Down Expand Up @@ -830,7 +830,7 @@ TestPointReadyToBootMemoryTypeInformationFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_MEMORY_TYPE_INFORMATION_FUNCTIONAL
);
Expand Down Expand Up @@ -878,7 +878,7 @@ TestPointReadyToBootUefiMemoryAttributeTableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_MEMORY_ATTRIBUTE_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -925,7 +925,7 @@ TestPointReadyToBootUefiBootVariableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_BOOT_VARIABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -972,7 +972,7 @@ TestPointReadyToBootUefiConsoleVariableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
4,
TEST_POINT_BYTE4_READY_TO_BOOT_UEFI_CONSOLE_VARIABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -1017,7 +1017,7 @@ TestPointReadyToBootHstiTableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
8,
TEST_POINT_BYTE8_READY_TO_BOOT_HSTI_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -1062,7 +1062,7 @@ TestPointReadyToBootEsrtTableFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
8,
TEST_POINT_BYTE8_READY_TO_BOOT_ESRT_TABLE_FUNCTIONAL
);
Expand Down Expand Up @@ -1107,7 +1107,7 @@ TestPointReadyToBootUefiSecureBootEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
5,
TEST_POINT_BYTE5_READY_TO_BOOT_UEFI_SECURE_BOOT_ENABLED
);
Expand Down Expand Up @@ -1151,7 +1151,7 @@ TestPointReadyToBootPiSignedFvBootEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
5,
TEST_POINT_BYTE5_READY_TO_BOOT_PI_SIGNED_FV_BOOT_ENABLED
);
Expand Down Expand Up @@ -1196,7 +1196,7 @@ TestPointReadyToBootTcgTrustedBootEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
5,
TEST_POINT_BYTE5_READY_TO_BOOT_TCG_TRUSTED_BOOT_ENABLED
);
Expand Down Expand Up @@ -1241,7 +1241,7 @@ TestPointReadyToBootTcgMorEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
5,
TEST_POINT_BYTE5_READY_TO_BOOT_TCG_MOR_ENABLED
);
Expand Down Expand Up @@ -1301,7 +1301,7 @@ TestPointPciEnumerationDonePcieGenSpeed (
if (Result) {
Status = TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_DXE, // MU_CHANGE - StandaloneMm Support
3,
TEST_POINT_BYTE3_PCI_ENUMERATION_DONE_PCIE_GEN_SPEED
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
[Protocols]
gEfiPciIoProtocolGuid
gEfiPciRootBridgeIoProtocolGuid
gEfiSmmAccess2ProtocolGuid
gEfiMmAccessProtocolGuid #MU_CHANGE - Standalone MM support
gEdkiiVarCheckProtocolGuid
gEfiLoadedImageProtocolGuid
gEfiLoadedImageDevicePathProtocolGuid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ TestPointMmEndOfDxeSmrrFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM, // MU_CHANGE - Standalone Mm Support
TEST_POINT_INDEX_BYTE6_SMM,
TEST_POINT_BYTE6_SMM_END_OF_DXE_SMRR_FUNCTIONAL
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ TestPointDebugInitDone (
//
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
0,
TEST_POINT_BYTE0_TEMP_INIT_DONE
);
Expand All @@ -121,7 +121,7 @@ TestPointDebugInitDone (

TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
0,
TEST_POINT_BYTE0_DEBUG_INIT_DONE
);
Expand Down Expand Up @@ -171,7 +171,7 @@ TestPointMemoryDiscoveredMtrrFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
1,
TEST_POINT_BYTE1_MEMORY_DISCOVERED_MTRR_FUNCTIONAL
);
Expand Down Expand Up @@ -219,7 +219,7 @@ TestPointMemoryDiscoveredMemoryResourceFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
1,
TEST_POINT_BYTE1_MEMORY_DISCOVERED_MEMORY_RESOURCE_FUNCTIONAL
);
Expand Down Expand Up @@ -266,7 +266,7 @@ TestPointMemoryDiscoveredFvInfoFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
1,
TEST_POINT_BYTE1_MEMORY_DISCOVERED_FV_INFO_FUNCTIONAL
);
Expand Down Expand Up @@ -313,7 +313,7 @@ TestPointMemoryDiscoveredDmaProtectionEnabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
1,
TEST_POINT_BYTE1_MEMORY_DISCOVERED_DMA_PROTECTION_ENABLED
);
Expand Down Expand Up @@ -363,7 +363,7 @@ TestPointEndOfPeiSystemResourceFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
2,
TEST_POINT_BYTE2_END_OF_PEI_SYSTEM_RESOURCE_FUNCTIONAL
);
Expand Down Expand Up @@ -412,7 +412,7 @@ TestPointEndOfPeiMtrrFunctional (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
2,
TEST_POINT_BYTE2_END_OF_PEI_MTRR_FUNCTIONAL
);
Expand Down Expand Up @@ -459,7 +459,7 @@ TestPointEndOfPeiPciBusMasterDisabled (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_PEI, // MU_CHANGE - StandaloneMm Support
2,
TEST_POINT_BYTE2_END_OF_PEI_PCI_BUS_MASTER_DISABLED
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ TestPointReadyToBootMmPageProtection (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM, // MU_CHANGE - StandaloneMm Support
TEST_POINT_INDEX_BYTE6_SMM,
TEST_POINT_BYTE6_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION
);
Expand All @@ -111,7 +111,7 @@ TestPointReadyToBootMmPageProtection (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM, // MU_CHANGE - StandaloneMm Support
TEST_POINT_INDEX_BYTE6_SMM,
TEST_POINT_BYTE6_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
);
Expand Down Expand Up @@ -248,14 +248,14 @@ TestPointReadyToBootMmPageProtectionHandler (
if (Result) {
TestPointLibSetFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM, // MU_CHANGE - StandaloneMm Support
TEST_POINT_INDEX_BYTE6_SMM,
TEST_POINT_BYTE6_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
);
} else {
TestPointLibClearFeaturesVerified (
PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
NULL,
TEST_POINT_IMPLEMENTATION_ID_PLATFORM_SMM, // MU_CHANGE - StandaloneMm Support
TEST_POINT_INDEX_BYTE6_SMM,
TEST_POINT_BYTE6_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
);
Expand Down
Loading

0 comments on commit 6d81e0d

Please sign in to comment.