Skip to content

Commit

Permalink
CryptoPkg: Add CryptoStandaloneMm and StandaloneMmCryptLib
Browse files Browse the repository at this point in the history
Adds a Standalone MM instance of BaseCryptLib intended to only be
used with the CryptoStandaloneMm driver added. The library instance
can be linked against Standalone MM drivers to the use the
gEdkiiSmmCryptoProtocolGuid protocol instance produced by
CryptoStandaloneMm.

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
  • Loading branch information
makubacki authored and kenlautner committed Jan 19, 2024
1 parent eab839f commit 5bbf055
Show file tree
Hide file tree
Showing 5 changed files with 661 additions and 7 deletions.
33 changes: 26 additions & 7 deletions CryptoPkg/CryptoPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,15 @@
ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseReportStatusCodeLibNull.inf
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf

[LibraryClasses.common.MM_STANDALONE]
BaseCryptLib|CryptoPkg/Library/BaseCryptLib/SmmCryptLib.inf
DebugLib|MdePkg/Library/BaseDebugLibNull/BaseDebugLibNull.inf
MemoryAllocationLib|StandaloneMmPkg/Library/StandaloneMmMemoryAllocationLib/StandaloneMmMemoryAllocationLib.inf
MmServicesTableLib|MdePkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLib.inf
ReportStatusCodeLib|MdeModulePkg/Library/SmmReportStatusCodeLib/StandaloneMmReportStatusCodeLib.inf
StandaloneMmDriverEntryPoint|MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
TlsLib|CryptoPkg/Library/TlsLibNull/TlsLibNull.inf

################################################################################
#
# Pcd Section - list of all EDK II PCD Entries defined by this Platform
Expand Down Expand Up @@ -218,6 +227,7 @@

CryptoPkg/Library/BaseCryptLibOnProtocolPpi/PeiCryptLib.inf
CryptoPkg/Library/BaseCryptLibOnProtocolPpi/DxeCryptLib.inf
CryptoPkg/Library/BaseCryptLibOnProtocolPpi/StandaloneMmCryptLib.inf # MU_CHANGE: Add StandaloneMmCryptLib
# MU_CHANGE [BEGIN] The prebuilt versions of CryptoDriver
!if $(CRYPTO_BINARY_EXTDEP_PATH) != FALSE
!include CryptoPkg/Driver/Bin/CryptoPkg.ci.inc.dsc
Expand Down Expand Up @@ -248,7 +258,22 @@
FILE_GUID = $(DXE_CRYPTO_DRIVER_FILE_GUID) # MU_CHANGE updated File GUID
}

## MU_CHANGE TCBZ_3799 - can't compile for ARM as it depends on ArmSoftFloatLib
[Components.IA32, Components.X64]
CryptoPkg/Driver/CryptoSmm.inf {
<Defines>
FILE_GUID = $(SMM_CRYPTO_DRIVER_FILE_GUID)# MU_CHANGE updated File GUID
}

# MU_CHANGE [BEGIN]: Add CryptoStandaloneMm
[Components.IA32, Components.X64, Components.AARCH64]
CryptoPkg/Driver/CryptoStandaloneMm.inf {
<Defines>
FILE_GUID = $(STANDALONEMM_CRYPTO_DRIVER_FILE_GUID) # MU_CHANGE updated File GUID
}
# MU_CHANGE [END]: Add CryptoStandaloneMm

## MU_CHANGE TCBZ_3799 - can't compile for ARM as it depends on ArmSoftFloatLib
[Components.IA32, Components.X64, Components.AARCH64]
CryptoPkg/Test/UnitTest/Library/BaseCryptLib/BaseCryptLibUnitTestApp.inf { ## Add unit-test application for the crypto tests.
## MU_CHANGE [START] add library classes to allow crypto tests to run in uefi shell correctly
<LibraryClasses>
Expand All @@ -268,12 +293,6 @@
## MU_CHANGE [END]
## MU_CHANGE [END]

[Components.IA32, Components.X64]
CryptoPkg/Driver/CryptoSmm.inf {
<Defines>
FILE_GUID = $(SMM_CRYPTO_DRIVER_FILE_GUID)# MU_CHANGE updated File GUID
}

[BuildOptions]
RELEASE_*_*_CC_FLAGS = -DMDEPKG_NDEBUG
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
Expand Down
41 changes: 41 additions & 0 deletions CryptoPkg/Driver/CryptoStandaloneMm.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/** @file
Installs the EDK II Crypto SMM Protocol in Standalone MM.
Copyright (C) Microsoft Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <PiMm.h>
#include <Library/MmServicesTableLib.h>
#include <Protocol/SmmCrypto.h>

extern CONST EDKII_CRYPTO_PROTOCOL mEdkiiCrypto;

/**
The module Entry Point of the Crypto Standalone MM Driver.
@param[in] ImageHandle The firmware allocated handle for the EFI image.
@param[in] SystemTable A pointer to the EFI System Table.
@retval EFI_SUCCESS The entry point is executed successfully.
@retval Other Some error occurs when executing this entry point.
**/
EFI_STATUS
EFIAPI
CryptoStandaloneMmEntry (
IN EFI_HANDLE ImageHandle,
IN EFI_MM_SYSTEM_TABLE *MmSystemTable
)
{
EFI_HANDLE Handle;

Handle = NULL;
return gMmst->MmInstallProtocolInterface (
&Handle,
&gEdkiiSmmCryptoProtocolGuid,
EFI_NATIVE_INTERFACE,
(EDKII_CRYPTO_PROTOCOL *)&mEdkiiCrypto
);
}
Loading

0 comments on commit 5bbf055

Please sign in to comment.