diff options
author | Jiewen Yao <jiewen.yao@intel.com> | 2017-11-03 16:22:45 +0800 |
---|---|---|
committer | Jiewen Yao <jiewen.yao@intel.com> | 2017-11-13 14:06:26 +0800 |
commit | 47685e9ba5821a90f95a781b8c69545d362916eb (patch) | |
tree | fb177df5ffd7fb167ea820a0f58465332a9db471 /Platform/Intel/MinPlatformPkg/Test | |
parent | 303915fc30865823ef102d7d507103c0c2a56137 (diff) | |
download | edk2-platforms-47685e9ba5821a90f95a781b8c69545d362916eb.tar.xz |
Add SMM test point according to the design.
Cc: Michael A Kubacki <michael.a.kubacki@intel.com>
Cc: Amy Chan <amy.chan@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Brett Wang <brett.wang@intel.com>
Cc: Daocheng Bu <daocheng.bu@intel.com>
Cc: Isaac W Oram <isaac.w.oram@intel.com>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Amy Chan <amy.chan@intel.com>
Diffstat (limited to 'Platform/Intel/MinPlatformPkg/Test')
9 files changed, 445 insertions, 16 deletions
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c index bf9bfa9615..427d502633 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckSmiHandlerInstrument.c @@ -43,16 +43,7 @@ VOID InternalDumpData (
IN UINT8 *Data,
IN UINTN Size
- )
-{
- UINTN Index;
- for (Index = 0; Index < Size; Index++) {
- DEBUG ((DEBUG_INFO, "%02x", (UINTN)Data[Index]));
- if ((Index + 1) != Size) {
- DEBUG ((DEBUG_INFO, " "));
- }
- }
-}
+ );
/**
Get SMI handler profile database.
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c index 0465ef9f68..d64e98d5bf 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.c @@ -18,9 +18,16 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/DebugLib.h>
#include <Library/UefiLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/DmaRemappingReportingTable.h>
#include <IndustryStandard/WindowsSmmSecurityMitigationTable.h>
+#include <Protocol/SmmCommunication.h>
+#include <Guid/PiSmmCommunicationRegionTable.h>
+
+#include "TestPointInternal.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID mTestPointSmmCommunciationGuid = TEST_POINT_SMM_COMMUNICATION_GUID;
VOID
TestPointDumpGcd (
@@ -355,6 +362,116 @@ TestPointDxeSmmReadyToLockWsmtTableFuntional ( EFI_STATUS
EFIAPI
+TestPointDxeSmmReadyToBootSmmPageProtection (
+ VOID
+ )
+{
+ EFI_MEMORY_DESCRIPTOR *UefiMemoryMap;
+ UINTN UefiMemoryMapSize;
+ UINTN UefiDescriptorSize;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *GcdMemoryMap;
+ EFI_GCD_IO_SPACE_DESCRIPTOR *GcdIoMap;
+ UINTN GcdMemoryMapNumberOfDescriptors;
+ UINTN GcdIoMapNumberOfDescriptors;
+ EFI_STATUS Status;
+ UINTN CommSize;
+ UINT8 *CommBuffer;
+ EFI_SMM_COMMUNICATE_HEADER *CommHeader;
+ EFI_SMM_COMMUNICATION_PROTOCOL *SmmCommunication;
+ UINTN MinimalSizeNeeded;
+ EDKII_PI_SMM_COMMUNICATION_REGION_TABLE *PiSmmCommunicationRegionTable;
+ UINT32 Index;
+ EFI_MEMORY_DESCRIPTOR *Entry;
+ UINTN Size;
+ TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO *CommData;
+
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToBootSmmPageProtection - Enter\n"));
+
+ TestPointDumpUefiMemoryMap (&UefiMemoryMap, &UefiMemoryMapSize, &UefiDescriptorSize);
+ TestPointDumpGcd (&GcdMemoryMap, &GcdMemoryMapNumberOfDescriptors, &GcdIoMap, &GcdIoMapNumberOfDescriptors);
+
+ Status = gBS->LocateProtocol(&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **)&SmmCommunication);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: Locate SmmCommunication protocol - %r\n", Status));
+ return EFI_SUCCESS;
+ }
+
+ MinimalSizeNeeded = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) +
+ sizeof(TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO) +
+ UefiMemoryMapSize +
+ GcdMemoryMapNumberOfDescriptors * sizeof(EFI_GCD_MEMORY_SPACE_DESCRIPTOR) +
+ GcdIoMapNumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR);
+
+ Status = EfiGetSystemConfigurationTable(
+ &gEdkiiPiSmmCommunicationRegionTableGuid,
+ (VOID **)&PiSmmCommunicationRegionTable
+ );
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: Get PiSmmCommunicationRegionTable - %r\n", Status));
+ return EFI_SUCCESS;
+ }
+ ASSERT(PiSmmCommunicationRegionTable != NULL);
+ Entry = (EFI_MEMORY_DESCRIPTOR *)(PiSmmCommunicationRegionTable + 1);
+ Size = 0;
+ for (Index = 0; Index < PiSmmCommunicationRegionTable->NumberOfEntries; Index++) {
+ if (Entry->Type == EfiConventionalMemory) {
+ Size = EFI_PAGES_TO_SIZE((UINTN)Entry->NumberOfPages);
+ if (Size >= MinimalSizeNeeded) {
+ break;
+ }
+ }
+ Entry = (EFI_MEMORY_DESCRIPTOR *)((UINT8 *)Entry + PiSmmCommunicationRegionTable->DescriptorSize);
+ }
+ ASSERT(Index < PiSmmCommunicationRegionTable->NumberOfEntries);
+ CommBuffer = (UINT8 *)(UINTN)Entry->PhysicalStart;
+
+ CommHeader = (EFI_SMM_COMMUNICATE_HEADER *)&CommBuffer[0];
+ CopyMem(&CommHeader->HeaderGuid, &mTestPointSmmCommunciationGuid, sizeof(mTestPointSmmCommunciationGuid));
+ CommHeader->MessageLength = MinimalSizeNeeded - OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data);
+
+ CommData = (TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO *)&CommBuffer[OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data)];
+ CommData->Header.Version = TEST_POINT_SMM_COMMUNICATION_VERSION;
+ CommData->Header.FuncId = TEST_POINT_SMM_COMMUNICATION_FUNC_ID_UEFI_GCD_MAP_INFO;
+ CommData->Header.Size = CommHeader->MessageLength;
+ CommData->UefiMemoryMapOffset = sizeof(TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO);
+ CommData->UefiMemoryMapSize = UefiMemoryMapSize;
+ CommData->GcdMemoryMapOffset = CommData->UefiMemoryMapOffset + CommData->UefiMemoryMapSize;
+ CommData->GcdMemoryMapSize = GcdMemoryMapNumberOfDescriptors * sizeof(EFI_GCD_MEMORY_SPACE_DESCRIPTOR);
+ CommData->GcdIoMapOffset = CommData->GcdMemoryMapOffset + CommData->GcdMemoryMapSize;
+ CommData->GcdIoMapSize = GcdIoMapNumberOfDescriptors * sizeof(EFI_GCD_IO_SPACE_DESCRIPTOR);
+ CopyMem (
+ (VOID *)((UINTN)CommData + CommData->UefiMemoryMapOffset),
+ UefiMemoryMap,
+ CommData->UefiMemoryMapSize
+ );
+ CopyMem (
+ (VOID *)((UINTN)CommData + CommData->GcdMemoryMapOffset),
+ GcdMemoryMap,
+ CommData->GcdMemoryMapSize
+ );
+ CopyMem (
+ (VOID *)((UINTN)CommData + CommData->GcdIoMapOffset),
+ GcdIoMap,
+ CommData->GcdIoMapSize
+ );
+
+ CommSize = OFFSET_OF(EFI_SMM_COMMUNICATE_HEADER, Data) + CommHeader->MessageLength;
+ Status = SmmCommunication->Communicate(SmmCommunication, CommBuffer, &CommSize);
+ if (EFI_ERROR(Status)) {
+ DEBUG ((DEBUG_INFO, "TestPointDxeSmmReadyToBootSmmPageProtection: SmmCommunication - %r\n", Status));
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointDxeSmmReadyToBootSmmPageProtection - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
TestPointReadyToBootSmiHandlerInstrument (
VOID
)
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf index 609f6c34af..7ca562a023 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeTestPointCheckLib.inf @@ -70,6 +70,7 @@ DxeCheckPiSignedFvBoot.c
DxeCheckTcgTrustedBoot.c
DxeCheckTcgMor.c
+ TestPointHelp.c
[Guids]
gEfiMemoryAttributesTableGuid
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c index 7625c60e61..bf0817ea40 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmCheckCommunicationBuffer.c @@ -58,7 +58,9 @@ IsUefiPageNotPresent ( EFI_STATUS
TestPointCheckSmmCommunicationBuffer (
- VOID
+ IN EFI_MEMORY_DESCRIPTOR *UefiMemoryMap,
+ IN UINTN UefiMemoryMapSize,
+ IN UINTN UefiDescriptorSize
)
{
EFI_STATUS ReturnStatus;
@@ -70,8 +72,8 @@ TestPointCheckSmmCommunicationBuffer ( DEBUG ((DEBUG_INFO, "==== TestPointCheckSmmCommunicationBuffer - Enter\n"));
ReturnStatus = EFI_SUCCESS;
- MemoryMapEntryCount = mUefiMemoryMapSize/mUefiDescriptorSize;
- MemoryMap = mUefiMemoryMap;
+ MemoryMapEntryCount = UefiMemoryMapSize/UefiDescriptorSize;
+ MemoryMap = UefiMemoryMap;
for (Index = 0; Index < MemoryMapEntryCount; Index++) {
if (IsUefiPageNotPresent(MemoryMap)) {
DEBUG ((DEBUG_INFO, "UEFI MemoryMap Checking 0x%lx - 0x%x\n", MemoryMap->PhysicalStart, EFI_PAGES_TO_SIZE(MemoryMap->NumberOfPages)));
@@ -85,7 +87,7 @@ TestPointCheckSmmCommunicationBuffer ( ReturnStatus = Status;
}
}
- MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, mUefiDescriptorSize);
+ MemoryMap = NEXT_MEMORY_DESCRIPTOR(MemoryMap, UefiDescriptorSize);
}
if (EFI_ERROR (ReturnStatus)) {
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c index cbc21307ce..3225f139e6 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.c @@ -16,6 +16,13 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/TestPointLib.h>
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/SmmMemLib.h>
+#include <Library/SmmServicesTableLib.h>
+
+#include "TestPointInternal.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID mTestPointSmmCommunciationGuid = TEST_POINT_SMM_COMMUNICATION_GUID;
EFI_STATUS
TestPointCheckSmrr (
@@ -39,7 +46,9 @@ TestPointCheckSmmPaging ( EFI_STATUS
TestPointCheckSmmCommunicationBuffer (
- VOID
+ IN EFI_MEMORY_DESCRIPTOR *UefiMemoryMap,
+ IN UINTN UefiMemoryMapSize,
+ IN UINTN UefiDescriptorSize
);
VOID
@@ -206,7 +215,7 @@ TestPointSmmReadyToBootSmmPageProtection ( if (mUefiMemoryMap != NULL) {
Result = TRUE;
- Status = TestPointCheckSmmCommunicationBuffer ();
+ Status = TestPointCheckSmmCommunicationBuffer (mUefiMemoryMap, mUefiMemoryMapSize, mUefiDescriptorSize);
if (EFI_ERROR(Status)) {
Result = FALSE;
}
@@ -223,6 +232,163 @@ TestPointSmmReadyToBootSmmPageProtection ( return EFI_SUCCESS;
}
+/**
+ Dispatch function for a Software SMI handler.
+
+ Caution: This function may receive untrusted input.
+ Communicate buffer and buffer size are external input, so this function will do basic validation.
+
+ @param CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS Command is handled successfully.
+**/
+EFI_STATUS
+TestPointSmmReadyToBootSmmPageProtectionHandler (
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ BOOLEAN Result;
+ TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO *CommData;
+ UINTN TempCommBufferSize;
+
+ if ((mFeatureImplemented[5] & TEST_POINT_BYTE5_SMM_READY_TO_BOOT_SMM_PAGE_LEVEL_PROTECTION) == 0) {
+ return EFI_SUCCESS;
+ }
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBootSmmPageProtectionHandler - Enter\n"));
+
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < sizeof(TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO)) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+
+ if (!SmmIsBufferOutsideSmmValid((UINTN)CommBuffer, TempCommBufferSize)) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: SMM communication buffer in SMRAM or overflow!\n"));
+ return EFI_SUCCESS;
+ }
+ DEBUG ((DEBUG_INFO, "TempCommBufferSize - 0x%x\n", TempCommBufferSize));
+ CommData = AllocateCopyPool (TempCommBufferSize, CommBuffer);
+ if (CommData == NULL) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: SMM communication buffer size too big!\n"));
+ return EFI_SUCCESS;
+ }
+ if (CommData->UefiMemoryMapOffset != sizeof(TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO)) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: UefiMemoryMapOffset invalid!\n"));
+ goto Done;
+ }
+ if (CommData->UefiMemoryMapSize > TempCommBufferSize - CommData->UefiMemoryMapOffset) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: UefiMemoryMapSize invalid!\n"));
+ goto Done;
+ }
+ if (CommData->GcdMemoryMapOffset != CommData->UefiMemoryMapOffset + CommData->UefiMemoryMapSize) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: GcdMemoryMapOffset invalid!\n"));
+ goto Done;
+ }
+ if (CommData->GcdMemoryMapSize > TempCommBufferSize - CommData->GcdMemoryMapOffset) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: GcdMemoryMapSize invalid!\n"));
+ goto Done;
+ }
+ if (CommData->GcdIoMapOffset != CommData->GcdMemoryMapOffset + CommData->GcdMemoryMapSize) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: GcdIoMapOffset invalid!\n"));
+ goto Done;
+ }
+ if (CommData->GcdIoMapSize != TempCommBufferSize - CommData->GcdIoMapOffset) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmReadyToBootSmmPageProtectionHandler: GcdIoMapSize invalid!\n"));
+ goto Done;
+ }
+
+ if (CommData->UefiMemoryMapSize != 0) {
+ Result = TRUE;
+
+ Status = TestPointCheckSmmCommunicationBuffer (
+ (EFI_MEMORY_DESCRIPTOR *)((UINTN)CommData + CommData->UefiMemoryMapOffset),
+ (UINTN)CommData->UefiMemoryMapSize,
+ mUefiDescriptorSize
+ );
+ if (EFI_ERROR(Status)) {
+ Result = FALSE;
+ }
+ if (Result) {
+ TestPointLibSetFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 5,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
+ );
+ } else {
+ TestPointLibClearFeaturesVerified (
+ PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV,
+ NULL,
+ 5,
+ TEST_POINT_BYTE5_SMM_READY_TO_LOCK_SECURE_SMM_COMMUNICATION_BUFFER
+ );
+ }
+ }
+Done:
+ FreePool (CommData);
+
+ DEBUG ((DEBUG_INFO, "======== TestPointSmmReadyToBootSmmPageProtectionHandler - Exit\n"));
+ return EFI_SUCCESS;
+}
+
+/**
+ Dispatch function for a Software SMI handler.
+
+ Caution: This function may receive untrusted input.
+ Communicate buffer and buffer size are external input, so this function will do basic validation.
+
+ @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
+ @param Context Points to an optional handler context which was specified when the
+ handler was registered.
+ @param CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS Command is handled successfully.
+**/
+EFI_STATUS
+EFIAPI
+TestPointSmmHandler (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context OPTIONAL,
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
+ )
+{
+ TEST_POINT_SMM_COMMUNICATION_HEADER CommData;
+ UINTN TempCommBufferSize;
+
+ //
+ // If input is invalid, stop processing this SMI
+ //
+ if (CommBuffer == NULL || CommBufferSize == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ TempCommBufferSize = *CommBufferSize;
+
+ if (TempCommBufferSize < sizeof(TEST_POINT_SMM_COMMUNICATION_HEADER)) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmHandler: SMM communication buffer size invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ CopyMem (&CommData, CommBuffer, sizeof(CommData));
+ if (CommData.Version != TEST_POINT_SMM_COMMUNICATION_VERSION) {
+ DEBUG((DEBUG_ERROR, "TestPointSmmHandler: SMM communication Version invalid!\n"));
+ return EFI_SUCCESS;
+ }
+ switch (CommData.FuncId) {
+ case TEST_POINT_SMM_COMMUNICATION_FUNC_ID_UEFI_GCD_MAP_INFO:
+ return TestPointSmmReadyToBootSmmPageProtectionHandler (CommBuffer, CommBufferSize);
+ }
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
EFIAPI
TestPointSmmExitBootServices (
@@ -236,6 +402,25 @@ TestPointSmmExitBootServices ( }
/**
+ Register SMM Test Point handler.
+**/
+VOID
+RegisterSmmTestPointHandler (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE DispatchHandle;
+
+ Status = gSmst->SmiHandlerRegister (
+ TestPointSmmHandler,
+ &mTestPointSmmCommunciationGuid,
+ &DispatchHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
Initialize feature data
**/
VOID
@@ -270,5 +455,7 @@ SmmTestPointCheckLibConstructor ( {
InitData (PLATFORM_TEST_POINT_ROLE_PLATFORM_IBV);
+ RegisterSmmTestPointHandler ();
+
return EFI_SUCCESS;
}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf index ca24387a34..cb1a21bff0 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/SmmTestPointCheckLib.inf @@ -29,6 +29,7 @@ MemoryAllocationLib
DevicePathLib
PeCoffGetEntryPointLib
+ SmmMemLib
TestPointLib
[Packages]
@@ -48,6 +49,7 @@ DxeCheckMemoryMap.c
DxeCheckLoadedImage.c
DxeCheckGcd.c
+ TestPointHelp.c
[Pcd]
gMinPlatformModuleTokenSpaceGuid.PcdTestPointIbvPlatformFeature
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointHelp.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointHelp.c new file mode 100644 index 0000000000..d631eaf193 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointHelp.c @@ -0,0 +1,73 @@ +/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <Uefi.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/TestPointLib.h>
+#include <Library/DebugLib.h>
+
+/**
+ This function dump raw data.
+
+ @param Data raw data
+ @param Size raw data size
+**/
+VOID
+InternalDumpData (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ for (Index = 0; Index < Size; Index++) {
+ DEBUG ((DEBUG_INFO, "%02x", (UINTN)Data[Index]));
+ if ((Index + 1) != Size) {
+ DEBUG ((DEBUG_INFO, " "));
+ }
+ }
+}
+
+/**
+
+ This function dump raw data with colume format.
+
+ @param Data raw data
+ @param Size raw data size
+
+**/
+VOID
+InternalDumpHex (
+ IN UINT8 *Data,
+ IN UINTN Size
+ )
+{
+ UINTN Index;
+ UINTN Count;
+ UINTN Left;
+
+#define COLUME_SIZE (16 * 2)
+
+ Count = Size / COLUME_SIZE;
+ Left = Size % COLUME_SIZE;
+ for (Index = 0; Index < Count; Index++) {
+ DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+ InternalDumpData (Data + Index * COLUME_SIZE, COLUME_SIZE);
+ DEBUG ((EFI_D_INFO, "\n"));
+ }
+
+ if (Left != 0) {
+ DEBUG ((EFI_D_INFO, "%04x: ", Index * COLUME_SIZE));
+ InternalDumpData (Data + Index * COLUME_SIZE, Left);
+ DEBUG ((EFI_D_INFO, "\n"));
+ }
+}
diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointInternal.h b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointInternal.h new file mode 100644 index 0000000000..2144e94239 --- /dev/null +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/TestPointInternal.h @@ -0,0 +1,47 @@ +/** @file
+
+Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that accompanies this distribution.
+The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php.
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef _TEST_POINT_PRIVATE_H_
+#define _TEST_POINT_PRIVATE_H_
+
+#include <Uefi.h>
+#include <PiSmm.h>
+#include <Library/TestPointCheckLib.h>
+#include <Library/DebugLib.h>
+
+#define TEST_POINT_SMM_COMMUNICATION_VERSION 0x1
+#define TEST_POINT_SMM_COMMUNICATION_FUNC_ID_UEFI_GCD_MAP_INFO 0x1
+
+typedef struct {
+ UINT32 Version;
+ UINT32 FuncId;
+ UINT64 Size;
+} TEST_POINT_SMM_COMMUNICATION_HEADER;
+
+typedef struct {
+ TEST_POINT_SMM_COMMUNICATION_HEADER Header;
+ UINT64 UefiMemoryMapOffset;
+ UINT64 UefiMemoryMapSize;
+ UINT64 GcdMemoryMapOffset;
+ UINT64 GcdMemoryMapSize;
+ UINT64 GcdIoMapOffset;
+ UINT64 GcdIoMapSize;
+} TEST_POINT_SMM_COMMUNICATION_UEFI_GCD_MAP_INFO;
+
+#define TEST_POINT_SMM_COMMUNICATION_GUID { \
+ 0x9cfa432a, 0x17cd, 0x4eb7, 0x96, 0x54, 0x2e, 0xb2, 0x5, 0x91, 0xef, 0x8f \
+ }
+
+extern EFI_GUID mTestPointSmmCommunciationGuid;
+
+#endif
\ No newline at end of file diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c index d3f170554b..2234272e16 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLibNull/TestPointCheckLibNull.c @@ -143,6 +143,15 @@ TestPointDxeSmmReadyToLockWsmtTableFuntional ( EFI_STATUS
EFIAPI
+TestPointDxeSmmReadyToBootSmmPageProtection (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
TestPointReadyToBootSmiHandlerInstrument (
VOID
)
|