X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=SecurityPkg%2FTcg%2FTrEEConfig%2FTrEEConfigPeim.c;h=efe40bc3ce256d7b872325ec22fabc4b1328a73b;hp=77d640dd443a3bcf58187c67b711181cd354f3fb;hb=83a276f61342d0b0d94e96f7d0636bf9474b5ed1;hpb=c1d932429ef9700a2da64452546be14e92468b07 diff --git a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c index 77d640dd44..efe40bc3ce 100644 --- a/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c +++ b/SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c @@ -1,7 +1,7 @@ /** @file The module entry point for TrEE configuration module. -Copyright (c) 2013, Intel Corporation. All rights reserved.
+Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -25,6 +25,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include +#include #include #include "TrEEConfigNvData.h" @@ -37,6 +38,12 @@ CONST EFI_PEI_PPI_DESCRIPTOR gTpmSelectedPpi = { NULL }; +EFI_PEI_PPI_DESCRIPTOR mTpmInitializationDonePpiList = { + EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST, + &gPeiTpmInitializationDonePpiGuid, + NULL +}; + /** This routine check both SetupVariable and real TPM device, and return final TpmDevice configuration. @@ -67,6 +74,7 @@ TrEEConfigPeimEntryPoint ( { UINTN Size; EFI_STATUS Status; + EFI_STATUS Status2; EFI_PEI_READ_ONLY_VARIABLE2_PPI *VariablePpi; TREE_CONFIGURATION TrEEConfiguration; UINTN Index; @@ -94,19 +102,23 @@ TrEEConfigPeimEntryPoint ( // // Validation // - if (TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) { - TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT; + if ((TrEEConfiguration.TpmDevice > TPM_DEVICE_MAX) || (TrEEConfiguration.TpmDevice < TPM_DEVICE_MIN)) { + TrEEConfiguration.TpmDevice = TPM_DEVICE_DEFAULT; } // // Although we have SetupVariable info, we still need detect TPM device manually. // - DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice)); + DEBUG ((EFI_D_INFO, "TrEEConfiguration.TpmDevice from Setup: %x\n", TrEEConfiguration.TpmDevice)); if (PcdGetBool (PcdTpmAutoDetection)) { TpmDevice = DetectTpmDevice (TrEEConfiguration.TpmDevice); - DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice final: %x\n", TpmDevice)); - TrEEConfiguration.TpmDevice = TpmDevice; + DEBUG ((EFI_D_INFO, "TpmDevice final: %x\n", TpmDevice)); + if (TpmDevice != TPM_DEVICE_NULL) { + TrEEConfiguration.TpmDevice = TpmDevice; + } + } else { + TpmDevice = TrEEConfiguration.TpmDevice; } // @@ -114,11 +126,14 @@ TrEEConfigPeimEntryPoint ( // This is work-around because there is no gurantee DynamicHiiPcd can return correct value in DXE phase. // Using DynamicPcd instead. // + // NOTE: TrEEConfiguration variable contains the desired TpmDevice type, + // while PcdTpmInstanceGuid PCD contains the real detected TpmDevice type + // for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) { - if (TrEEConfiguration.TpmDevice == mTpmInstanceId[Index].TpmDevice) { + if (TpmDevice == mTpmInstanceId[Index].TpmDevice) { Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid); PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid); - DEBUG ((EFI_D_ERROR, "TrEEConfiguration.TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid)); + DEBUG ((EFI_D_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid)); break; } } @@ -129,5 +144,15 @@ TrEEConfigPeimEntryPoint ( Status = PeiServicesInstallPpi (&gTpmSelectedPpi); ASSERT_EFI_ERROR (Status); + // + // Even if no TPM is selected or detected, we still need intall TpmInitializationDonePpi. + // Because TcgPei or TrEEPei will not run, but we still need a way to notify other driver. + // Other driver can know TPM initialization state by TpmInitializedPpi. + // + if (CompareGuid (PcdGetPtr(PcdTpmInstanceGuid), &gEfiTpmDeviceInstanceNoneGuid)) { + Status2 = PeiServicesInstallPpi (&mTpmInitializationDonePpiList); + ASSERT_EFI_ERROR (Status2); + } + return Status; }