@@ -89,23 +89,9 @@ typedef struct {
8989
9090#endif
9191
92- // MU_CHANGE - [END]
92+ EFI_TPM2_ACPI_TABLE_TEMPLATE mTpm2AcpiTemplate ;
9393
94- EFI_TPM2_ACPI_TABLE_V5 mTpm2AcpiTemplate = {
95- {
96- EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE ,
97- sizeof (mTpm2AcpiTemplate ),
98- EFI_TPM2_ACPI_TABLE_REVISION ,
99- //
100- // Compiler initializes the remaining bytes to 0
101- // These fields should be filled in in production
102- //
103- },
104- 0 , // BIT0~15: PlatformClass
105- // BIT16~31: Reserved
106- 0 , // Control Area
107- EFI_TPM2_ACPI_TABLE_START_METHOD_TIS , // StartMethod
108- };
94+ // MU_CHANGE - [END]
10995
11096/**
11197 Patch version string of Physical Presence interface supported by platform. The initial string tag in TPM
@@ -348,7 +334,7 @@ PublishTpm2 (
348334 UINT64 OemTableId ;
349335 EFI_TPM2_ACPI_CONTROL_AREA * ControlArea ;
350336 TPM2_PTP_INTERFACE_TYPE InterfaceType ;
351- UINT64 PartitionId ;
337+ EFI_TPM2_ACPI_TABLE_V5 * Tpm2AcpiTableV5 ; // MU_CHANGE
352338
353339 STATIC_ASSERT ((FixedPcdGet64 (PcdTpmMaxAddress ) - FixedPcdGet64 (PcdTpmBaseAddress )) == (FixedPcdGet32 (PcdTpmCrbRegionSize ) - 1 ), "TPM CRB region size mismatch" );
354340
@@ -358,60 +344,70 @@ PublishTpm2 (
358344 // Otherwise, the PCR record would be different after event log update
359345 // or the PCD configuration change.
360346 //
361- TpmMeasureAndLogData (
362- 0 ,
363- EV_POST_CODE ,
364- EV_POSTCODE_INFO_ACPI_DATA ,
365- ACPI_DATA_LEN ,
366- & mTpm2AcpiTemplate ,
367- mTpm2AcpiTemplate .Header .Length
368- );
347+ // MU_CHANGE [BEGIN]
348+ // Allow a platform to drop TCG ACPI measurements until we have a chance to make them more
349+ // consistent and functional.
350+ if (!FixedPcdGetBool (PcdSkipTcgSmmAcpiMeasurements )) {
351+ TpmMeasureAndLogData (
352+ 0 ,
353+ EV_POST_CODE ,
354+ EV_POSTCODE_INFO_ACPI_DATA ,
355+ ACPI_DATA_LEN ,
356+ & mTpm2AcpiTemplate ,
357+ sizeof (EFI_TPM2_ACPI_TABLE_TEMPLATE )
358+ );
359+ }
369360
370- mTpm2AcpiTemplate .Header .Revision = PcdGet8 (PcdTpm2AcpiTableRev );
361+ mTpm2AcpiTemplate .Header .Signature = EFI_ACPI_5_0_TRUSTED_COMPUTING_PLATFORM_2_TABLE_SIGNATURE ;
362+ mTpm2AcpiTemplate .Header .Length = sizeof (EFI_TPM2_ACPI_TABLE_V5 );
363+ mTpm2AcpiTemplate .Header .Revision = PcdGet8 (PcdTpm2AcpiTableRev );
371364 DEBUG ((DEBUG_INFO , "Tpm2 ACPI table revision is %d\n" , mTpm2AcpiTemplate .Header .Revision ));
372365
366+ // FF-A is only supported in revisions 5 and up.
373367 if (mTpm2AcpiTemplate .Header .Revision < EFI_TPM2_ACPI_TABLE_REVISION_5 ) {
374- DEBUG ((DEBUG_ERROR , "%a The minimum revision supported for TPM over FFA table is 5, not %d. \n" , __func__ , mTpm2AcpiTemplate . Header . Revision ));
368+ DEBUG ((DEBUG_ERROR , "The minimum revision supported for TPM over FF-A table is 5\n" ));
375369 ASSERT (FALSE);
376370 return EFI_UNSUPPORTED ;
377371 }
378372
379- mTpm2AcpiTemplate .Flags = (mTpm2AcpiTemplate .Flags & 0xFFFF0000 ) | PcdGet8 (PcdTpmPlatformClass );
380- DEBUG ((DEBUG_INFO , "Tpm2 ACPI table PlatformClass is %d\n" , (mTpm2AcpiTemplate .Flags & 0x0000FFFF )));
381-
382- mTpm2AcpiTemplate .Laml = PcdGet32 (PcdTpm2AcpiTableLaml );
383- mTpm2AcpiTemplate .Lasa = PcdGet64 (PcdTpm2AcpiTableLasa );
384- if ((mTpm2AcpiTemplate .Laml == 0 ) || (mTpm2AcpiTemplate .Lasa == 0 )) {
385- //
386- // If version is smaller than 4 or Laml/Lasa is not valid, rollback to original Length.
387- //
388- mTpm2AcpiTemplate .Header .Length = sizeof (EFI_TPM2_ACPI_TABLE );
389- }
390-
373+ // CRB over FF-A only supports the CRB interface type.
391374 InterfaceType = PcdGet8 (PcdActiveTpmInterfaceType );
392375 DEBUG ((DEBUG_INFO , "Tpm Active Interface Type %d\n" , InterfaceType ));
393-
394- PartitionId = PcdGet16 (PcdTpmServiceFfaPartitionId );
395- ASSERT (PartitionId != 0 );
396- if (InterfaceType == Tpm2PtpInterfaceCrb ) {
397- mTpm2AcpiTemplate .StartMethod = EFI_TPM2_ACPI_TABLE_START_METHOD_COMMAND_RESPONSE_BUFFER_INTERFACE_WITH_FFA ;
398- mTpm2AcpiTemplate .AddressOfControlArea = PcdGet64 (PcdTpmBaseAddress ) + 0x40 ;
399- mTpm2AcpiTemplate .FfaParameters .Flags = 0x00 ; // Notifications Not Supported
400- mTpm2AcpiTemplate .FfaParameters .Attributes = (EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_CRB_REGION_SIZE_4KB << EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_CRB_REGION_SIZE_SHIFT ) |
401- (EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_MEM_TYPE_NOT_CACHABLE << EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_MEM_TYPE_SHIFT );
402- mTpm2AcpiTemplate .FfaParameters .PartitionId = PartitionId ; // Partition ID
403- ControlArea = (EFI_TPM2_ACPI_CONTROL_AREA * )(UINTN )mTpm2AcpiTemplate .AddressOfControlArea ;
404- ControlArea -> CommandSize = 0xF80 ;
405- ControlArea -> ResponseSize = 0xF80 ;
406- ControlArea -> Command = PcdGet64 (PcdTpmBaseAddress ) + 0x80 ;
407- ControlArea -> Response = PcdGet64 (PcdTpmBaseAddress ) + 0x80 ;
408- } else {
409- DEBUG ((DEBUG_ERROR , "TPM2 InterfaceType get error! %d\n" , InterfaceType ));
376+ if (InterfaceType != Tpm2PtpInterfaceCrb ) {
377+ DEBUG ((DEBUG_ERROR , "TPM over FF-A only supports CRB interface\n" ));
410378 return EFI_UNSUPPORTED ;
411379 }
412380
381+ mTpm2AcpiTemplate .Flags = (mTpm2AcpiTemplate .Flags & 0xFFFF0000 ) | PcdGet8 (PcdTpmPlatformClass );
382+ DEBUG ((DEBUG_INFO , "Tpm2 ACPI table PlatformClass is %d\n" , (mTpm2AcpiTemplate .Flags & 0x0000FFFF )));
383+
384+ Tpm2AcpiTableV5 = (EFI_TPM2_ACPI_TABLE_V5 * )& mTpm2AcpiTemplate ;
385+ Tpm2AcpiTableV5 -> Laml = PcdGet32 (PcdTpm2AcpiTableLaml );
386+ Tpm2AcpiTableV5 -> Lasa = PcdGet64 (PcdTpm2AcpiTableLasa );
387+ if ((Tpm2AcpiTableV5 -> Laml == 0 ) || (Tpm2AcpiTableV5 -> Lasa == 0 )) {
388+ // Remove LAML/LASA from the length if either is 0.
389+ mTpm2AcpiTemplate .Header .Length -= (sizeof (UINT32 ) + sizeof (UINT64 ));
390+ }
391+
413392 DEBUG ((DEBUG_INFO , "Tpm2 ACPI table size %d\n" , mTpm2AcpiTemplate .Header .Length ));
414393
394+ mTpm2AcpiTemplate .StartMethod = EFI_TPM2_ACPI_TABLE_START_METHOD_COMMAND_RESPONSE_BUFFER_INTERFACE_WITH_FFA ;
395+ mTpm2AcpiTemplate .AddressOfControlArea = PcdGet64 (PcdTpmBaseAddress ) + 0x40 ;
396+ ControlArea = (EFI_TPM2_ACPI_CONTROL_AREA * )(UINTN )mTpm2AcpiTemplate .AddressOfControlArea ;
397+ ControlArea -> CommandSize = 0xF80 ;
398+ ControlArea -> ResponseSize = 0xF80 ;
399+ ControlArea -> Command = PcdGet64 (PcdTpmBaseAddress ) + 0x80 ;
400+ ControlArea -> Response = PcdGet64 (PcdTpmBaseAddress ) + 0x80 ;
401+
402+ // Set the FF-A specific parameters.
403+ Tpm2AcpiTableV5 -> FfaParameters .Flags = 0x00 ; // Notifications Not Supported
404+ Tpm2AcpiTableV5 -> FfaParameters .Attributes = (EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_CRB_REGION_SIZE_4KB << EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_CRB_REGION_SIZE_SHIFT ) |
405+ (EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_MEM_TYPE_NOT_CACHABLE << EFI_TPM2_ACPI_TABLE_ARM_FFA_PARAMETER_ATTR_MEM_TYPE_SHIFT );
406+ Tpm2AcpiTableV5 -> FfaParameters .PartitionId = PcdGet16 (PcdTpmServiceFfaPartitionId );
407+ ASSERT (Tpm2AcpiTableV5 -> FfaParameters .PartitionId != 0 );
408+
409+ // MU_CHANGE [END]
410+
415411 CopyMem (mTpm2AcpiTemplate .Header .OemId , PcdGetPtr (PcdAcpiDefaultOemId ), sizeof (mTpm2AcpiTemplate .Header .OemId ));
416412 OemTableId = PcdGet64 (PcdAcpiDefaultOemTableId );
417413 CopyMem (& mTpm2AcpiTemplate .Header .OemTableId , & OemTableId , sizeof (UINT64 ));
0 commit comments