diff options
Diffstat (limited to 'MdeModulePkg')
5 files changed, 111 insertions, 3 deletions
diff --git a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c index 3343e60..22ab4d7 100644 --- a/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c +++ b/MdeModulePkg/Library/UefiBootManagerLib/BmBoot.c @@ -1404,7 +1404,7 @@ BmDestroyRamDisk ( Status = mRamDisk->Unregister (RamDiskDevicePath);
ASSERT_EFI_ERROR (Status);
- FreePages (RamDiskBuffer, RamDiskSizeInPages);
+ FreeAlignedPages (RamDiskBuffer, RamDiskSizeInPages);
}
/**
@@ -1454,8 +1454,12 @@ BmExpandLoadFile ( //
// The load option resides in a RAM disk.
+ // Use a reasonable default of 2MB for alignment as the ramdisk device is
+ // implemented as an NVDIMM persistent memory and operating systems may
+ // wish to map this with huge page support.
//
- FileBuffer = AllocateReservedPages (EFI_SIZE_TO_PAGES (BufferSize));
+
+ FileBuffer = AllocateAlignedReservedPages (EFI_SIZE_TO_PAGES (BufferSize), SIZE_2MB);
if (FileBuffer == NULL) {
DEBUG_CODE_BEGIN ();
EFI_DEVICE_PATH *LoadFilePath;
@@ -1496,7 +1500,7 @@ BmExpandLoadFile ( Status = LoadFile->LoadFile (LoadFile, FilePath, TRUE, &BufferSize, FileBuffer);
if (EFI_ERROR (Status)) {
- FreePages (FileBuffer, EFI_SIZE_TO_PAGES (BufferSize));
+ FreeAlignedPages (FileBuffer, EFI_SIZE_TO_PAGES (BufferSize));
return NULL;
}
diff --git a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc index 0643e38..2361374 100644 --- a/MdeModulePkg/Test/MdeModulePkgHostTest.dsc +++ b/MdeModulePkg/Test/MdeModulePkgHostTest.dsc @@ -71,3 +71,4 @@ MdeModulePkg/Test/Mock/Library/GoogleTest/MockHiiLib/MockHiiLib.inf
MdeModulePkg/Test/Mock/Library/GoogleTest/MockPciHostBridgeLib/MockPciHostBridgeLib.inf
MdeModulePkg/Test/Mock/Library/GoogleTest/MockVariablePolicyHelperLib/MockVariablePolicyHelperLib.inf
+ MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf
diff --git a/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h new file mode 100644 index 0000000..59ec205 --- /dev/null +++ b/MdeModulePkg/Test/Mock/Include/GoogleTest/Library/MockSecurityManagementLib.h @@ -0,0 +1,54 @@ +/** @file
+ Google Test mocks for DevicePathLib
+
+ Copyright (c) 2025, Yandex. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef MOCK_SECURITY_MANAGEMENT_LIB_H_
+#define MOCK_SECURITY_MANAGEMENT_LIB_LIB_H_
+
+#include <Library/GoogleTestLib.h>
+#include <Library/FunctionMockLib.h>
+extern "C" {
+ #include <Uefi.h>
+ #include <Library/SecurityManagementLib.h>
+}
+
+struct MockSecurityManagementLib {
+ MOCK_INTERFACE_DECLARATION (MockSecurityManagementLib);
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ RegisterSecurityHandler,
+ (IN SECURITY_FILE_AUTHENTICATION_STATE_HANDLER SecurityHandler,
+ IN UINT32 AuthenticationOperation)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ ExecuteSecurityHandlers,
+ (IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FilePath)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ RegisterSecurity2Handler,
+ (IN SECURITY2_FILE_AUTHENTICATION_HANDLER Security2Handler,
+ IN UINT32 AuthenticationOperation)
+ );
+
+ MOCK_FUNCTION_DECLARATION (
+ EFI_STATUS,
+ ExecuteSecurity2Handlers,
+ (IN UINT32 AuthenticationOperation,
+ IN UINT32 AuthenticationStatus,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *File OPTIONAL,
+ IN VOID *FileBuffer,
+ IN UINTN FileSize,
+ IN BOOLEAN BootPolicy)
+ );
+};
+
+#endif // MOCK_SECURITY_MANAGEMENT_LIB_H_
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp new file mode 100644 index 0000000..fa3b24b --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.cpp @@ -0,0 +1,15 @@ +/** @file
+ Google Test mocks for SecurityManagementLib
+
+ Copyright (c) 2025, Yandex. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <GoogleTest/Library/MockSecurityManagementLib.h>
+
+MOCK_INTERFACE_DEFINITION (MockSecurityManagementLib);
+
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, RegisterSecurityHandler, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, ExecuteSecurityHandlers, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, RegisterSecurity2Handler, 2, EFIAPI);
+MOCK_FUNCTION_DEFINITION (MockSecurityManagementLib, ExecuteSecurity2Handlers, 6, EFIAPI);
diff --git a/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf new file mode 100644 index 0000000..d64e28c --- /dev/null +++ b/MdeModulePkg/Test/Mock/Library/GoogleTest/MockSecurityManagementLib/MockSecurityManagementLib.inf @@ -0,0 +1,34 @@ +## @file
+# Google Test mocks for SecurityManagementLib
+#
+# Copyright (c) 2025, Yandex. All rights reserved.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = MockSecurityManagementLib
+ FILE_GUID = 22FF8498-3FE9-495B-81B7-6595145F5832
+ MODULE_TYPE = HOST_APPLICATION
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = SecurityManagementLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[Sources]
+ MockSecurityManagementLib.cpp
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
+
+[LibraryClasses]
+ GoogleTestLib
+
+[BuildOptions]
+ MSFT:*_*_*_CC_FLAGS = /EHsc
|