Skip to content

Commit

Permalink
Integrate PEI RNG Shared Crypto
Browse files Browse the repository at this point in the history
Produces a RNG PPI that is used by shared crypto to abstract platform
RNG support.

- Updates Mu Basecore to v2023110010.0.1
- Updates Mu Tiano Plus to v2023110001.1.0
- Updates Mu MM Supervisor to v12.0.1 (for overrides)
- Updates pytools for compat with Mu Basecore Rust plugin

Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
  • Loading branch information
makubacki committed Aug 2, 2024
1 parent b09793d commit 0e9a994
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 14 deletions.
2 changes: 1 addition & 1 deletion MU_BASECORE
Submodule MU_BASECORE updated 82 files
+13 −3 .github/workflows/codeql.yml
+3 −3 BaseTools/Plugin/CodeQL/codeqlcli_ext_dep.yaml
+3 −3 BaseTools/Plugin/CodeQL/codeqlcli_linux_ext_dep.yaml
+3 −3 BaseTools/Plugin/CodeQL/codeqlcli_windows_ext_dep.yaml
+27 −3 BaseTools/Plugin/HostBasedUnitTestRunner/HostBasedUnitTestRunner.py
+169 −44 BaseTools/Plugin/OverrideValidation/OverrideValidation.py
+1 −1 BaseTools/Plugin/OverrideValidation/OverrideValidation_plug_in.json
+41 −3 BaseTools/Plugin/OverrideValidation/ReadMe.md
+4 −320 BaseTools/Plugin/RustEnvironmentCheck/RustEnvironmentCheck.py
+2 −1 BaseTools/Plugin/RustEnvironmentCheck/RustEnvironmentCheck_plug_in.yaml
+7 −0 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/AeadAesGcmTests.c
+133 −41 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/BaseCryptLibUnitTestApp.inf
+7 −0 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/BlockCipherTests.c
+22 −4 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/BnTests.c
+7 −0 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/DhTests.c
+28 −0 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/EcTests.c
+14 −0 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HkdfTests.c
+16 −4 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/HmacTests.c
+133 −41 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/TestBaseCryptLibHost.inf
+8 −1 CryptoPkg/Test/UnitTest/Library/BaseCryptLib/X509Tests.c
+6 −0 Makefile.toml
+1 −0 MdeModulePkg/Core/Dxe/DxeMain.inf
+124 −9 MdeModulePkg/Core/Dxe/Misc/MemoryProtectionSupport.c
+3 −0 MdePkg/Test/MdePkgHostTest.dsc
+45 −0 MdePkg/Test/Mock/Include/GoogleTest/Library/MockPciExpressLib.h
+88 −1 MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiBootServicesTableLib.h
+31 −0 MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiDevicePathLib.h
+10 −0 MdePkg/Test/Mock/Include/GoogleTest/Library/MockUefiLib.h
+3 −3 MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockHash2.h
+3 −3 MdePkg/Test/Mock/Include/GoogleTest/Protocol/MockRng.h
+13 −0 MdePkg/Test/Mock/Library/GoogleTest/MockPciExpressLib/MockPciExpressLib.cpp
+33 −0 MdePkg/Test/Mock/Library/GoogleTest/MockPciExpressLib/MockPciExpressLib.inf
+90 −45 MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/MockUefiBootServicesTableLib.cpp
+9 −10 MdePkg/Test/Mock/Library/GoogleTest/MockUefiBootServicesTableLib/MockUefiBootServicesTableLib.inf
+11 −0 MdePkg/Test/Mock/Library/GoogleTest/MockUefiDevicePathLib/MockUefiDevicePathLib.cpp
+34 −0 MdePkg/Test/Mock/Library/GoogleTest/MockUefiDevicePathLib/MockUefiDevicePathLib.inf
+1 −0 MdePkg/Test/Mock/Library/GoogleTest/MockUefiLib/MockUefiLib.cpp
+1 −0 NetworkPkg/Dhcp4Dxe/Dhcp4Driver.c
+1 −1 NetworkPkg/Dhcp6Dxe/Dhcp6Driver.c
+1 −0 NetworkPkg/DnsDxe/DnsDhcp.c
+1 −0 NetworkPkg/DnsDxe/DnsImpl.c
+1 −0 NetworkPkg/HttpBootDxe/HttpBootDhcp6.c
+1 −0 NetworkPkg/IScsiDxe/IScsiCHAP.c
+1 −0 NetworkPkg/IScsiDxe/IScsiMisc.c
+1 −0 NetworkPkg/IScsiDxe/IScsiMisc.h
+21 −14 NetworkPkg/Include/Library/NetLib.h
+1 −0 NetworkPkg/Ip4Dxe/Ip4Driver.c
+1 −1 NetworkPkg/Ip6Dxe/Ip6Driver.c
+1 −1 NetworkPkg/Ip6Dxe/Ip6If.c
+1 −1 NetworkPkg/Ip6Dxe/Ip6Nd.c
+1 −1 NetworkPkg/Ip6Dxe/Ip6Nd.h
+35 −29 NetworkPkg/Library/DxeNetLib/DxeNetLib.c
+8 −2 NetworkPkg/Library/DxeNetLib/DxeNetLib.inf
+1 −0 NetworkPkg/NetworkPkg.dec
+2 −3 NetworkPkg/SecurityFixes.yaml
+1 −1 NetworkPkg/TcpDxe/TcpDriver.c
+4 −0 NetworkPkg/TcpDxe/TcpDxe.inf
+1 −1 NetworkPkg/TcpDxe/TcpFunc.h
+1 −1 NetworkPkg/TcpDxe/TcpMain.h
+15 −9 NetworkPkg/TcpDxe/TcpMisc.c
+1 −1 NetworkPkg/TcpDxe/TcpTimer.c
+1 −0 NetworkPkg/Test/NetworkPkgHostTest.dsc
+1 −0 NetworkPkg/Udp4Dxe/Udp4Driver.c
+1 −1 NetworkPkg/Udp6Dxe/Udp6Driver.c
+97 −5 NetworkPkg/UefiPxeBcDxe/GoogleTest/PxeBcDhcp6GoogleTest.cpp
+1 −0 NetworkPkg/UefiPxeBcDxe/GoogleTest/UefiPxeBcDxeGoogleTest.inf
+1 −1 NetworkPkg/UefiPxeBcDxe/PxeBcDhcp4.c
+1 −0 NetworkPkg/UefiPxeBcDxe/PxeBcDriver.c
+0 −2 UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
+7 −2 UefiCpuPkg/Library/CpuPageTableLib/CpuPageTableMap.c
+5 −5 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.c
+1 −0 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.h
+1 −0 UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
+29 −0 UefiCpuPkg/Test/Mock/Include/GoogleTest/Library/MockTimerLib.h
+11 −0 UefiCpuPkg/Test/Mock/Library/GoogleTest/MockTimerLib/MockTimerLib.cpp
+34 −0 UefiCpuPkg/Test/Mock/Library/GoogleTest/MockTimerLib/MockTimerLib.inf
+1 −0 UefiCpuPkg/Test/UefiCpuPkgHostTest.dsc
+22 −3 UnitTestFrameworkPkg/ReadMe.md
+2 −1 UnitTestFrameworkPkg/UnitTestFrameworkPkg.ci.yaml
+10 −3 UnitTestFrameworkPkg/UnitTestFrameworkPkgHost.dsc.inc
+2 −2 pip-requirements.txt
+1 −1 rustfmt.toml
10 changes: 10 additions & 0 deletions Platforms/QemuQ35Pkg/PlatformPei/Platform.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include <Library/QemuFwCfgS3Lib.h>
#include <Library/QemuFwCfgSimpleParserLib.h>
#include <Library/ResourcePublicationLib.h>
#include <Library/RngLib.h>
#include <Ppi/MasterBootMode.h>
#include <IndustryStandard/I440FxPiix4.h>
#include <IndustryStandard/Microvm.h>
Expand Down Expand Up @@ -820,6 +821,7 @@ InitializePlatform (
{
EFI_STATUS Status;
// MU_CHANGE START
UINT16 RandomNumber;
DXE_MEMORY_PROTECTION_SETTINGS DxeSettings;
MM_MEMORY_PROTECTION_SETTINGS MmSettings;

Expand All @@ -835,6 +837,14 @@ InitializePlatform (
DxeSettings.ImageProtectionPolicy.Fields.BlockImagesWithoutNxFlag = 0;
#endif

if (GetRandomNumber16 (&RandomNumber)) {
DEBUG ((DEBUG_INFO, "[%a] - The random number is %d.\n", __func__, RandomNumber));
}

if (GetRandomNumber16 (&RandomNumber)) {
DEBUG ((DEBUG_INFO, "[%a] - The random number is %d.\n", __func__, RandomNumber));
}

BuildGuidDataHob (
&gDxeMemoryProtectionSettingsGuid,
&DxeSettings,
Expand Down
1 change: 1 addition & 0 deletions Platforms/QemuQ35Pkg/PlatformPei/PlatformPei.inf
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
MtrrLib
MemEncryptSevLib
PcdLib
RngLib

[Pcd]
gUefiQemuQ35PkgTokenSpaceGuid.PcdOvmfPeiMemFvBase
Expand Down
24 changes: 16 additions & 8 deletions Platforms/QemuQ35Pkg/QemuQ35Pkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -362,13 +362,13 @@
PeiServicesLib |MdePkg/Library/PeiServicesLib/PeiServicesLib.inf
MemoryAllocationLib |MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
ReportStatusCodeLib |MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
RngLib |MdePkg/Library/BaseRngLib/BaseRngLib.inf
MemEncryptSevLib |QemuQ35Pkg/Library/BaseMemEncryptSevLib/PeiMemEncryptSevLib.inf
FrameBufferMemDrawLib |MsGraphicsPkg/Library/FrameBufferMemDrawLib/FrameBufferMemDrawLibPei.inf
MmUnblockMemoryLib |MmSupervisorPkg/Library/MmSupervisorUnblockMemoryLib/MmSupervisorUnblockMemoryLibPei.inf

[LibraryClasses.common.PEI_CORE]
PeiCoreEntryPoint |MdePkg/Library/PeiCoreEntryPoint/PeiCoreEntryPoint.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf

[LibraryClasses.common.PEIM]
ResetSystemLib |MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
Expand All @@ -394,6 +394,7 @@
SourceDebugEnabledLib |SourceLevelDebugPkg/Library/SourceDebugEnabled/SourceDebugEnabledLib.inf
Tcg2PreUefiEventLogLib |QemuPkg/Library/QemuPreUefiEventLogLibNull/QemuPreUefiEventLogLibNull.inf
!endif
RngLib |MdePkg/Library/PeiRngLib/PeiRngLib.inf

[LibraryClasses.X64.PEIM]
CpuExceptionHandlerLib |UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuExceptionHandlerLib.inf
Expand All @@ -419,7 +420,7 @@
# Non DXE Core but everything else
[LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_DRIVER, LibraryClasses.common.UEFI_APPLICATION]
TimerLib |QemuQ35Pkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
RngLib |MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
RngLib |MdePkg/Library/DxeRngLib/DxeRngLib.inf
PciLib |QemuQ35Pkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf

OemMfciLib |OemPkg/Library/OemMfciLib/OemMfciLibDxe.inf
Expand All @@ -430,6 +431,7 @@
ExtractGuidedSectionLib |MdePkg/Library/DxeExtractGuidedSectionLib/DxeExtractGuidedSectionLib.inf
DebugAgentLib |DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.inf
MemoryBinOverrideLib |MdeModulePkg/Library/MemoryBinOverrideLibNull/MemoryBinOverrideLibNull.inf
RngLib |MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf


[LibraryClasses.common.DXE_RUNTIME_DRIVER]
Expand All @@ -443,9 +445,6 @@
[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.DXE_DRIVER]
UefiScsiLib|MdePkg/Library/UefiScsiLib/UefiScsiLib.inf

[LibraryClasses.common.UEFI_DRIVER]
RngLib|MdePkg/Library/DxeRngLib/DxeRngLib.inf

[LibraryClasses.common.UEFI_APPLICATION]
CheckHwErrRecHeaderLib|MsWheaPkg/Library/CheckHwErrRecHeaderLib/CheckHwErrRecHeaderLib.inf
FlatPageTableLib|UefiTestingPkg/Library/FlatPageTableLib/FlatPageTableLib.inf
Expand Down Expand Up @@ -483,7 +482,7 @@
MmServicesTableLib|MdePkg/Library/MmServicesTableLib/MmServicesTableLib.inf
SmmServicesTableLib|MdePkg/Library/SmmServicesTableLib/SmmServicesTableLib.inf
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmCpuExceptionHandlerLib.inf
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
LockBoxLib|MdeModulePkg/Library/SmmLockBoxLib/SmmLockBoxSmmLib.inf
AdvLoggerAccessLib|AdvLoggerPkg/Library/AdvLoggerSmmAccessLib/AdvLoggerSmmAccessLib.inf

Expand Down Expand Up @@ -513,6 +512,7 @@
MmServicesTableLib|StandaloneMmPkg/Library/StandaloneMmServicesTableLib/StandaloneMmServicesTableLibCore.inf
MmSaveStateLib|UefiCpuPkg/Library/MmSaveStateLib/AmdMmSaveStateLib.inf
SmmCpuSyncLib|MmSupervisorPkg/Library/StandaloneMmCpuSyncLib/StandaloneMmCpuSyncLib.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf

[LibraryClasses.common.MM_STANDALONE]
TimerLib|QemuQ35Pkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
Expand All @@ -527,7 +527,7 @@
StandaloneMmDriverEntryPoint|MmSupervisorPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.inf
AdvLoggerAccessLib|AdvLoggerPkg/Library/AdvLoggerMmAccessLib/AdvLoggerMmAccessLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLibStandaloneMm.inf
RngLib|MdePkg/Library/BaseRngLib/BaseRngLib.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
PciLib|QemuQ35Pkg/Library/DxePciLibI440FxQ35/DxePciLibI440FxQ35.inf

BaseLib|MmSupervisorPkg/Library/BaseLibSysCall/BaseLib.inf
Expand Down Expand Up @@ -914,6 +914,11 @@ QemuQ35Pkg/Library/ResetSystemLib/StandaloneMmResetSystemLib.inf
}
!endif

SecurityPkg/RandomNumberGenerator/RngPei/RngPei.inf {
<LibraryClasses>
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
}

QemuQ35Pkg/PlatformPei/PlatformPei.inf {
<LibraryClasses>
NULL|StandaloneMmPkg/Library/PeiStandaloneMmHobProductionLib/PeiStandaloneMmHobProductionLib.inf
Expand Down Expand Up @@ -1104,7 +1109,10 @@ QemuQ35Pkg/Library/ResetSystemLib/StandaloneMmResetSystemLib.inf
QemuPkg/VirtioRngDxe/VirtioRng.inf

# Rng Protocol producer
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf {
<LibraryClasses>
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
}

MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf
Expand Down
1 change: 1 addition & 0 deletions Platforms/QemuQ35Pkg/QemuQ35Pkg.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ INF MdeModulePkg/Core/Pei/PeiMain.inf
INF MdeModulePkg/Universal/PCD/Pei/Pcd.inf
INF MdeModulePkg/Universal/ReportStatusCodeRouter/Pei/ReportStatusCodeRouterPei.inf
INF MdeModulePkg/Universal/StatusCodeHandler/Pei/StatusCodeHandlerPei.inf
INF SecurityPkg/RandomNumberGenerator/RngPei/RngPei.inf
INF QemuQ35Pkg/PlatformPei/PlatformPei.inf
INF MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
INF UefiCpuPkg/Universal/Acpi/S3Resume2Pei/S3Resume2Pei.inf
Expand Down
14 changes: 12 additions & 2 deletions Platforms/QemuSbsaPkg/QemuSbsaPkg.dsc
Original file line number Diff line number Diff line change
Expand Up @@ -406,8 +406,8 @@
PeCoffGetEntryPointLib|MdePkg/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
ExtractGuidedSectionLib|MdePkg/Library/PeiExtractGuidedSectionLib/PeiExtractGuidedSectionLib.inf
FrameBufferMemDrawLib|MsGraphicsPkg/Library/FrameBufferMemDrawLib/FrameBufferMemDrawLibPei.inf

PeiServicesTablePointerLib|ArmPkg/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf

[LibraryClasses.common.PEIM]
PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf
Expand All @@ -433,6 +433,7 @@
OemMfciLib |OemPkg/Library/OemMfciLib/OemMfciLibPei.inf
ConfigKnobShimLib |SetupDataPkg/Library/ConfigKnobShimLib/ConfigKnobShimPeiLib/ConfigKnobShimPeiLib.inf
PolicyLib |PolicyServicePkg/Library/PeiPolicyLib/PeiPolicyLib.inf
RngLib |MdePkg/Library/PeiRngLib/PeiRngLib.inf

!if $(TPM2_ENABLE) == TRUE
Tpm2DeviceLib|SecurityPkg/Library/Tpm2DeviceLibDTpm/Tpm2DeviceLibDTpm.inf
Expand All @@ -446,6 +447,7 @@
PerformanceLib|MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
MemoryBinOverrideLib|MdeModulePkg/Library/MemoryBinOverrideLibNull/MemoryBinOverrideLibNull.inf
DebugAgentLib|DebuggerFeaturePkg/Library/DebugAgent/DebugAgentDxe.inf
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf

[LibraryClasses.common.DXE_DRIVER]
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
Expand Down Expand Up @@ -947,6 +949,11 @@
}
!endif

SecurityPkg/RandomNumberGenerator/RngPei/RngPei.inf {
<LibraryClasses>
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
}

MdeModulePkg/Core/DxeIplPeim/DxeIpl.inf
MsCorePkg/Core/GuidedSectionExtractPeim/GuidedSectionExtract.inf {
<LibraryClasses>
Expand Down Expand Up @@ -1033,7 +1040,10 @@
QemuPkg/VirtioRngDxe/VirtioRng.inf

# Rng Protocol producer
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf
SecurityPkg/RandomNumberGenerator/RngDxe/RngDxe.inf {
<LibraryClasses>
RngLib|MdeModulePkg/Library/BaseRngLibTimerLib/BaseRngLibTimerLib.inf
}

#
# FAT filesystem + GPT/MBR partitioning + UDF filesystem + virtio-fs
Expand Down
1 change: 1 addition & 0 deletions Platforms/QemuSbsaPkg/QemuSbsaPkg.fdf
Original file line number Diff line number Diff line change
Expand Up @@ -475,6 +475,7 @@ READ_LOCK_STATUS = TRUE

INF ArmPlatformPkg/PrePeiCore/PrePeiCoreUniCore.inf
INF MdeModulePkg/Core/Pei/PeiMain.inf
INF SecurityPkg/RandomNumberGenerator/RngPei/RngPei.inf
INF ArmPlatformPkg/PlatformPei/PlatformPeim.inf
INF ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.inf
INF ArmPkg/Drivers/CpuPei/CpuPei.inf
Expand Down
4 changes: 2 additions & 2 deletions pip-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
# https://www.python.org/dev/peps/pep-0440/#version-specifiers
##

edk2-pytool-library==0.21.5
edk2-pytool-extensions==0.27.4
edk2-pytool-library==0.21.9
edk2-pytool-extensions==0.27.10
xmlschema==3.3.2
regex==2024.7.24
pygount==1.8.0
Expand Down

0 comments on commit 0e9a994

Please sign in to comment.