]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Measure Processor location as system identity to PCR[1] according to Tcg server spec
authorczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Nov 2012 01:32:51 +0000 (01:32 +0000)
committerczhang46 <czhang46@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Nov 2012 01:32:51 +0000 (01:32 +0000)
Signed-off-by : Chao Zhang<chao.b.zhang@intel.com>
Reviewed-by   : Dong Guo<guo.dong@intel.com>
Reviewed-by   : Yao Jiewen<jiewen.yao@intel.com>

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13971 6f19259b-4bc3-4df7-8a09-765794883524

SecurityPkg/Tcg/TcgDxe/TcgDxe.c
SecurityPkg/Tcg/TcgDxe/TcgDxe.inf

index aa16641fdef94d6a40040dd108c604f4cf87994c..b8221b19a6932a6d0755dd1f80484354abba143f 100644 (file)
@@ -34,6 +34,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/DevicePath.h>\r
 #include <Protocol/TcgService.h>\r
 #include <Protocol/AcpiTable.h>\r
+#include <Protocol/MpService.h>\r
 \r
 #include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
@@ -158,6 +159,87 @@ EFI_TCG_SERVER_ACPI_TABLE           mTcgServerAcpiTemplate = {
 UINTN  mBootAttempts  = 0;\r
 CHAR16 mBootVarName[] = L"BootOrder";\r
 \r
+/**\r
+  Get All processors EFI_CPU_LOCATION in system. LocationBuf is allocated inside the function\r
+  Caller is responsible to free LocationBuf.\r
+\r
+  @param[out] LocationBuf          Returns Processor Location Buffer.\r
+  @param[out] Num                  Returns processor number.\r
+\r
+  @retval EFI_SUCCESS              Operation completed successfully.\r
+  @retval EFI_UNSUPPORTED       MpService protocol not found.\r
+\r
+**/\r
+EFI_STATUS\r
+GetProcessorsCpuLocation (\r
+    OUT  EFI_CPU_PHYSICAL_LOCATION   **LocationBuf,\r
+    OUT  UINTN                       *Num\r
+  )\r
+{\r
+  EFI_STATUS                        Status;\r
+  EFI_MP_SERVICES_PROTOCOL          *MpProtocol;\r
+  UINTN                             ProcessorNum;\r
+  UINTN                             EnabledProcessorNum;\r
+  EFI_PROCESSOR_INFORMATION         ProcessorInfo;\r
+  EFI_CPU_PHYSICAL_LOCATION         *ProcessorLocBuf;\r
+  UINTN                             Index;\r
+\r
+  Status = gBS->LocateProtocol (&gEfiMpServiceProtocolGuid, NULL, (VOID **) &MpProtocol);\r
+  if (EFI_ERROR (Status)) {\r
+    //\r
+    // MP protocol is not installed\r
+    //\r
+    return EFI_UNSUPPORTED;\r
+  }\r
+\r
+  Status = MpProtocol->GetNumberOfProcessors(\r
+                         MpProtocol,\r
+                         &ProcessorNum,\r
+                         &EnabledProcessorNum\r
+                         );\r
+  if (EFI_ERROR(Status)){\r
+    return Status;\r
+  }\r
+\r
+  Status = gBS->AllocatePool(\r
+                  EfiBootServicesData,\r
+                  sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,\r
+                  &ProcessorLocBuf\r
+                  );\r
+  if (EFI_ERROR(Status)){\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get each processor Location info\r
+  //\r
+  for (Index = 0; Index < ProcessorNum; Index++) {\r
+    Status = MpProtocol->GetProcessorInfo(\r
+                           MpProtocol,\r
+                           Index,\r
+                           &ProcessorInfo\r
+                           );\r
+    if (EFI_ERROR(Status)){\r
+      FreePool(ProcessorLocBuf);\r
+      return Status;\r
+    }\r
+\r
+    //\r
+    // Get all Processor Location info & measure\r
+    //\r
+    CopyMem(\r
+      &ProcessorLocBuf[Index],\r
+      &ProcessorInfo.Location,\r
+      sizeof(EFI_CPU_PHYSICAL_LOCATION)\r
+      );\r
+  }\r
+\r
+  *LocationBuf = ProcessorLocBuf;\r
+  *Num = ProcessorNum;\r
+\r
+  return Status;\r
+}\r
+\r
 /**\r
   This service provides EFI protocol capability information, state information \r
   about the TPM, and Event Log state information.\r
@@ -679,7 +761,12 @@ MeasureHandoffTables (
   SMBIOS_TABLE_ENTRY_POINT          *SmbiosTable;\r
   TCG_PCR_EVENT_HDR                 TcgEvent;\r
   EFI_HANDOFF_TABLE_POINTERS        HandoffTables;\r
+  UINTN                             ProcessorNum;\r
+  EFI_CPU_PHYSICAL_LOCATION         *ProcessorLocBuf;\r
 \r
+  //\r
+  // Measure SMBIOS with EV_EFI_HANDOFF_TABLES to PCR[1]\r
+  //\r
   Status = EfiGetSystemConfigurationTable (\r
              &gEfiSmbiosTableGuid,\r
              (VOID **) &SmbiosTable\r
@@ -708,6 +795,34 @@ MeasureHandoffTables (
                );\r
   }\r
 \r
+  if (PcdGet8 (PcdTpmPlatformClass) == TCG_PLATFORM_TYPE_SERVER) {\r
+    //\r
+    // Tcg Server spec. \r
+    // Measure each processor EFI_CPU_PHYSICAL_LOCATION with EV_TABLE_OF_DEVICES to PCR[1]\r
+    //\r
+    Status = GetProcessorsCpuLocation(&ProcessorLocBuf, &ProcessorNum);\r
+\r
+    if (!EFI_ERROR(Status)){\r
+      TcgEvent.PCRIndex  = 1;\r
+      TcgEvent.EventType = EV_TABLE_OF_DEVICES;\r
+      TcgEvent.EventSize = sizeof (HandoffTables);\r
+\r
+      HandoffTables.NumberOfTables = 1;\r
+      HandoffTables.TableEntry[0].VendorGuid  = gEfiMpServiceProtocolGuid;\r
+      HandoffTables.TableEntry[0].VendorTable = ProcessorLocBuf;\r
+\r
+      Status = TcgDxeHashLogExtendEventI (\r
+                 &mTcgDxeData,\r
+                 (UINT8*)(UINTN)ProcessorLocBuf,\r
+                 sizeof(EFI_CPU_PHYSICAL_LOCATION) * ProcessorNum,\r
+                 &TcgEvent,\r
+                 (UINT8*)&HandoffTables\r
+                 );\r
+\r
+      FreePool(ProcessorLocBuf);\r
+    }\r
+  }\r
+\r
   return Status;\r
 }\r
 \r
index 239997db7dd4f7e8f0058868b7df635d0735042c..ba53d328d67dffd0c4a3398b1462bd6a0afb2b21 100644 (file)
@@ -62,6 +62,7 @@
   gEfiTcgProtocolGuid                           ## PRODUCES\r
   gEfiAcpiTableProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
   gEfiDevicePathProtocolGuid                    # PROTOCOL ALWAYS_CONSUMED\r
+  gEfiMpServiceProtocolGuid                     # PROTOCOL ALWAYS_CONSUMED\r
 \r
 [Pcd]\r
   gEfiSecurityPkgTokenSpaceGuid.PcdTpmPlatformClass\r