public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [Patch] SecurityPkg:Tcg2Smm: Update TcgNvs info after memory is allocated
@ 2018-05-20 14:42 Zhang, Chao B
  2018-05-21  8:21 ` Long, Qin
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang, Chao B @ 2018-05-20 14:42 UTC (permalink / raw)
  To: edk2-devel; +Cc: Yao Jiewen, Long Qin

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>
---
 SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
index c3cee834ae..3e0a68999a 100644
--- a/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
+++ b/SecurityPkg/Tcg/Tcg2Smm/Tcg2Smm.c
@@ -308,19 +308,21 @@ UpdatePPVersion (
   interrupt buffer size. BufferSize, PkgLength and interrupt descirptor in ByteList need to be patched
 
   @param[in, out] Table            The TPM item in ACPI table.
   @param[in]      IrqBuffer        Input new IRQ buffer.
   @param[in]      IrqBuffserSize   Input new IRQ buffer size.
+  @param[out]     IsShortFormPkgLength   If _PRS returns Short length Package(ACPI spec 20.2.4).
 
   @return                          patch status.
 
 **/
 EFI_STATUS
 UpdatePossibleResource (
-  EFI_ACPI_DESCRIPTION_HEADER    *Table,
-  UINT32                         *IrqBuffer,
-  UINT32                         IrqBuffserSize
+  IN  EFI_ACPI_DESCRIPTION_HEADER    *Table,
+  IN  UINT32                         *IrqBuffer,
+  IN  UINT32                         IrqBuffserSize,
+  OUT BOOLEAN                        *IsShortFormPkgLength
   )
 {
   UINT8       *DataPtr;
   UINT8       *DataEndPtr;
   UINT32      NewPkgLength;
@@ -429,11 +431,11 @@ UpdatePossibleResource (
       *(DataPtr + 2) = (UINT8)(IrqBuffserSize + 19);
 
       //
       // Notify _PRS to report short formed ResourceTemplate
       //
-      mTcgNvs->IsShortFormPkgLength = TRUE;
+      *IsShortFormPkgLength = TRUE;
 
       break;
     }
   }
 
@@ -501,11 +503,11 @@ UpdatePossibleResource (
         *(DataPtr + 2 + ((*DataPtr & (BIT7|BIT6)) >> 6)) = (UINT8)(IrqBuffserSize + 19);
 
         //
         // Notify _PRS to report long formed ResourceTemplate
         //
-        mTcgNvs->IsShortFormPkgLength = FALSE;
+        *IsShortFormPkgLength = FALSE;
         break;
       }
     }
   }
 
@@ -670,10 +672,13 @@ PublishAcpiTable (
   UINTN                          TableKey;
   EFI_ACPI_DESCRIPTION_HEADER    *Table;
   UINTN                          TableSize;
   UINT32                         *PossibleIrqNumBuf;
   UINT32                         PossibleIrqNumBufSize;
+  BOOLEAN                        IsShortFormPkgLength;
+
+  IsShortFormPkgLength = FALSE;
 
   Status = GetSectionFromFv (
              &gEfiCallerIdGuid,
              EFI_SECTION_RAW,
              0,
@@ -708,11 +713,11 @@ PublishAcpiTable (
     //
     PossibleIrqNumBuf     = (UINT32 *)PcdGetPtr(PcdTpm2PossibleIrqNumBuf);
     PossibleIrqNumBufSize = (UINT32)PcdGetSize(PcdTpm2PossibleIrqNumBuf);
 
     if (PossibleIrqNumBufSize <= MAX_PRS_INT_BUF_SIZE && (PossibleIrqNumBufSize % sizeof(UINT32)) == 0) {
-      Status = UpdatePossibleResource(Table, PossibleIrqNumBuf, PossibleIrqNumBufSize);
+      Status = UpdatePossibleResource(Table, PossibleIrqNumBuf, PossibleIrqNumBufSize, &IsShortFormPkgLength);
       DEBUG ((
         DEBUG_INFO,
         "UpdatePossibleResource status - %x. TPM2 service may not ready in OS.\n",
         Status
         ));
@@ -741,11 +746,11 @@ PublishAcpiTable (
   ASSERT (Table->OemTableId == SIGNATURE_64 ('T', 'p', 'm', '2', 'T', 'a', 'b', 'l'));
   CopyMem (Table->OemId, PcdGetPtr (PcdAcpiDefaultOemId), sizeof (Table->OemId) );
   mTcgNvs = AssignOpRegion (Table, SIGNATURE_32 ('T', 'N', 'V', 'S'), (UINT16) sizeof (TCG_NVS));
   ASSERT (mTcgNvs != NULL);
   mTcgNvs->TpmIrqNum            = PcdGet32(PcdTpm2CurrentIrqNum);
-  mTcgNvs->IsShortFormPkgLength = FALSE;
+  mTcgNvs->IsShortFormPkgLength = IsShortFormPkgLength;
 
   //
   // Publish the TPM ACPI table. Table is re-checksumed.
   //
   Status = gBS->LocateProtocol (&gEfiAcpiTableProtocolGuid, NULL, (VOID **) &AcpiTable);
-- 
2.16.2.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-05-21  8:21 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-20 14:42 [Patch] SecurityPkg:Tcg2Smm: Update TcgNvs info after memory is allocated Zhang, Chao B
2018-05-21  8:21 ` Long, Qin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox