SecurityPkg:Tcg2Smm: Update TcgNvs info after memory is allocated
authorZhang, Chao B <chao.b.zhang@intel.com>
Fri, 18 May 2018 08:38:18 +0000 (16:38 +0800)
committerZhang, Chao B <chao.b.zhang@intel.com>
Tue, 22 May 2018 00:48:56 +0000 (08:48 +0800)
Update package format info in _PRS to TcgNvs after memory is allocated.

Change-Id: Icfadb350e60d3ed2df332e92c257ce13309c0018
Contributed-under: TianoCore Contribution Agreement 1.1
Cc: Yao Jiewen <jiewen.yao@intel.com>
Cc: Long Qin <qin.long@intel.com>
Signed-off-by: Zhang, Chao B <chao.b.zhang@intel.com>
Reviewed-by: Long Qin <qin.long@intel.com>
SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c

index c3cee83..3e0a689 100644 (file)
@@ -310,15 +310,17 @@ UpdatePPVersion (
   @param[in, out] Table            The TPM item in ACPI table.\r
   @param[in]      IrqBuffer        Input new IRQ buffer.\r
   @param[in]      IrqBuffserSize   Input new IRQ buffer size.\r
+  @param[out]     IsShortFormPkgLength   If _PRS returns Short length Package(ACPI spec 20.2.4).\r
 \r
   @return                          patch status.\r
 \r
 **/\r
 EFI_STATUS\r
 UpdatePossibleResource (\r
-  EFI_ACPI_DESCRIPTION_HEADER    *Table,\r
-  UINT32                         *IrqBuffer,\r
-  UINT32                         IrqBuffserSize\r
+  IN  EFI_ACPI_DESCRIPTION_HEADER    *Table,\r
+  IN  UINT32                         *IrqBuffer,\r
+  IN  UINT32                         IrqBuffserSize,\r
+  OUT BOOLEAN                        *IsShortFormPkgLength\r
   )\r
 {\r
   UINT8       *DataPtr;\r
@@ -431,7 +433,7 @@ UpdatePossibleResource (
       //\r
       // Notify _PRS to report short formed ResourceTemplate\r
       //\r
-      mTcgNvs->IsShortFormPkgLength = TRUE;\r
+      *IsShortFormPkgLength = TRUE;\r
 \r
       break;\r
     }\r
@@ -503,7 +505,7 @@ UpdatePossibleResource (
         //\r
         // Notify _PRS to report long formed ResourceTemplate\r
         //\r
-        mTcgNvs->IsShortFormPkgLength = FALSE;\r
+        *IsShortFormPkgLength = FALSE;\r
         break;\r
       }\r
     }\r
@@ -672,6 +674,9 @@ PublishAcpiTable (
   UINTN                          TableSize;\r
   UINT32                         *PossibleIrqNumBuf;\r
   UINT32                         PossibleIrqNumBufSize;\r
+  BOOLEAN                        IsShortFormPkgLength;\r
+\r
+  IsShortFormPkgLength = FALSE;\r
 \r
   Status = GetSectionFromFv (\r
              &gEfiCallerIdGuid,\r
@@ -710,7 +715,7 @@ PublishAcpiTable (
     PossibleIrqNumBufSize = (UINT32)PcdGetSize(PcdTpm2PossibleIrqNumBuf);\r
 \r
     if (PossibleIrqNumBufSize <= MAX_PRS_INT_BUF_SIZE && (PossibleIrqNumBufSize % sizeof(UINT32)) == 0) {\r
-      Status = UpdatePossibleResource(Table, PossibleIrqNumBuf, PossibleIrqNumBufSize);\r
+      Status = UpdatePossibleResource(Table, PossibleIrqNumBuf, PossibleIrqNumBufSize, &IsShortFormPkgLength);\r
       DEBUG ((\r
         DEBUG_INFO,\r
         "UpdatePossibleResource status - %x. TPM2 service may not ready in OS.\n",\r
@@ -743,7 +748,7 @@ PublishAcpiTable (
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));\r
   ASSERT (mTcgNvs != NULL);\r
   mTcgNvs->TpmIrqNum            = PcdGet32(PcdTpm2CurrentIrqNum);\r
-  mTcgNvs->IsShortFormPkgLength = FALSE;\r
+  mTcgNvs->IsShortFormPkgLength = IsShortFormPkgLength;\r
 \r
   //\r
   // Publish the TPM ACPI table. Table is re-checksumed.\r