]> git.proxmox.com Git - mirror_edk2.git/blobdiff - SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigImpl.c
SecurityPkg: Tcg2ConfigDxe/Tcg2Smm: Fix TPM2 HID issue
[mirror_edk2.git] / SecurityPkg / Tcg / Tcg2Config / Tcg2ConfigImpl.c
index 1317dca3d9d33fd89863d20e1083a3b1567df19a..b3a849e91812e566b9be0d9a4cfb44921ae836b6 100644 (file)
@@ -441,9 +441,9 @@ GetTpm2HID(
     //   #### is Firmware Version 1\r
     //\r
     if (PnpHID) {\r
-      AsciiSPrint(Hid + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));\r
+      AsciiSPrint(Hid + 3, TPM_HID_PNP_SIZE - 3, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 & 0x0000FFFF));\r
     } else {\r
-      AsciiSPrint(Hid + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 && 0x0000FFFF));\r
+      AsciiSPrint(Hid + 4, TPM_HID_ACPI_SIZE - 4, "%02d%02d", ((FirmwareVersion1 & 0xFFFF0000) >> 16), (FirmwareVersion1 & 0x0000FFFF));\r
     }\r
 \r
   } else {\r
@@ -455,6 +455,81 @@ GetTpm2HID(
   return EFI_SUCCESS;\r
 }\r
 \r
+/**\r
+  This function processes the results of changes in configuration\r
+  for TCG2 version information.\r
+\r
+  @param[in] Action             Specifies the type of action taken by the browser.\r
+                                ASSERT if the Action is not EFI_BROWSER_ACTION_SUBMITTED.\r
+  @param[in] QuestionId         A unique value which is sent to the original\r
+                                exporting driver so that it can identify the type\r
+                                of data to expect.\r
+  @param[in] Type               The type of value for the question.\r
+  @param[in] Value              A pointer to the data being sent to the original\r
+                                exporting driver.\r
+\r
+  @retval EFI_SUCCESS           The callback successfully handled the action.\r
+\r
+**/\r
+EFI_STATUS\r
+Tcg2VersionInfoCallback (\r
+  IN EFI_BROWSER_ACTION         Action,\r
+  IN EFI_QUESTION_ID            QuestionId,\r
+  IN UINT8                      Type,\r
+  IN EFI_IFR_TYPE_VALUE         *Value\r
+  )\r
+{\r
+  EFI_INPUT_KEY                 Key;\r
+  UINT64                        PcdTcg2PpiVersion;\r
+  UINT8                         PcdTpm2AcpiTableRev;\r
+\r
+  ASSERT (Action == EFI_BROWSER_ACTION_SUBMITTED);\r
+\r
+  if (QuestionId == KEY_TCG2_PPI_VERSION) {\r
+    //\r
+    // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r
+    // the SetVariable to TCG2_VERSION_NAME should have been done.\r
+    // If the PCD value is not equal to the value set to variable,\r
+    // the PCD is not DynamicHii type and does not map to the setup option.\r
+    //\r
+    PcdTcg2PpiVersion = 0;\r
+    CopyMem (\r
+      &PcdTcg2PpiVersion,\r
+      PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer),\r
+      AsciiStrSize ((CHAR8 *) PcdGetPtr (PcdTcgPhysicalPresenceInterfaceVer))\r
+      );\r
+    if (PcdTcg2PpiVersion != Value->u64) {\r
+      CreatePopUp (\r
+        EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+        &Key,\r
+        L"WARNING: PcdTcgPhysicalPresenceInterfaceVer is not DynamicHii type and does not map to this option!",\r
+        L"The version configuring by this setup option will not work!",\r
+        NULL\r
+        );\r
+    }\r
+  } else if (QuestionId == KEY_TPM2_ACPI_REVISION){\r
+    //\r
+    // Get the PCD value after EFI_BROWSER_ACTION_SUBMITTED,\r
+    // the SetVariable to TCG2_VERSION_NAME should have been done.\r
+    // If the PCD value is not equal to the value set to variable,\r
+    // the PCD is not DynamicHii type and does not map to the setup option.\r
+    //\r
+    PcdTpm2AcpiTableRev = PcdGet8 (PcdTpm2AcpiTableRev);\r
+\r
+    if (PcdTpm2AcpiTableRev != Value->u8) {\r
+      CreatePopUp (\r
+        EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE,\r
+        &Key,\r
+        L"WARNING: PcdTpm2AcpiTableRev is not DynamicHii type and does not map to this option!",\r
+        L"The Revision configuring by this setup option will not work!",\r
+        NULL\r
+        );\r
+    }\r
+  }\r
+\r
+  return EFI_SUCCESS;\r
+}\r
+\r
 /**\r
   This function processes the results of changes in configuration.\r
 \r
@@ -522,7 +597,6 @@ Tcg2Callback (
 \r
   if (Action == EFI_BROWSER_ACTION_CHANGING) {\r
     if (QuestionId == KEY_TPM_DEVICE_INTERFACE) {\r
-      EFI_STATUS  Status;\r
       Status = SetPtpInterface ((VOID *) (UINTN) PcdGet64 (PcdTpmBaseAddress), Value->u8);\r
       if (EFI_ERROR (Status)) {\r
         CreatePopUp (\r
@@ -547,7 +621,13 @@ Tcg2Callback (
       return SaveTcg2PpRequestParameter (Value->u32);\r
     }\r
     if ((QuestionId >= KEY_TPM2_PCR_BANKS_REQUEST_0) && (QuestionId <= KEY_TPM2_PCR_BANKS_REQUEST_4)) {\r
-      SaveTcg2PCRBanksRequest (QuestionId - KEY_TPM2_PCR_BANKS_REQUEST_0, Value->b);\r
+      return SaveTcg2PCRBanksRequest (QuestionId - KEY_TPM2_PCR_BANKS_REQUEST_0, Value->b);\r
+    }\r
+  }\r
+\r
+  if (Action == EFI_BROWSER_ACTION_SUBMITTED) {\r
+    if (QuestionId == KEY_TCG2_PPI_VERSION || QuestionId == KEY_TPM2_ACPI_REVISION) {\r
+      return Tcg2VersionInfoCallback (Action, QuestionId, Type, Value);\r
     }\r
   }\r
 \r
@@ -910,6 +990,7 @@ InstallTcg2ConfigForm (
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "Tcg2ConfigDriver: Fail to set TCG2_STORAGE_INFO_NAME\n"));\r
   }\r
+\r
   return EFI_SUCCESS;  \r
 }\r
 \r