Skip to content

Commit

Permalink
SecurityPkg: Use PcdSet##S to instead of PcdSet##
Browse files Browse the repository at this point in the history
PcdSet## has no error status returned, then the caller has no idea about whether the set operation is successful or not.
PcdSet##S were added to return error status and PcdSet## APIs were put in ifndef DISABLE_NEW_DEPRECATED_INTERFACES condition.
To adopt PcdSet##S and further code development with DISABLE_NEW_DEPRECATED_INTERFACES defined, we need to Replace PcdSet## usage with PcdSet##S.

Normally, DynamicDefault PCD set is expected to be success, but DynamicHii PCD set failure is a legal case.
PcdTpmInitializationPolicy/PcdTcg2HashAlgorithmBitmap/PcdTpm2HashMask/PcdTpmInstanceGuid all have set operation in PEI phase,
PEI phase does not allow DynamicHii PCD set, so DynamicDefault is expected for them and use PcdSet##S to instead of PcdSet## and assert when set failure.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18614 6f19259b-4bc3-4df7-8a09-765794883524
  • Loading branch information
lzeng14 authored and lzeng14 committed Oct 16, 2015
1 parent e90c57a commit fe3ca12
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,7 @@ RegisterHashInterfaceLib (
UINTN Index;
UINT32 HashMask;
UINT32 BiosSupportedHashMask;
EFI_STATUS Status;

//
// Check allow
Expand All @@ -218,7 +219,8 @@ RegisterHashInterfaceLib (
return EFI_OUT_OF_RESOURCES;
}
BiosSupportedHashMask = PcdGet32 (PcdTcg2HashAlgorithmBitmap);
PcdSet32 (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | HashMask);
Status = PcdSet32S (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | HashMask);
ASSERT_EFI_ERROR (Status);

//
// Check duplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ RegisterHashInterfaceLib (
HASH_INTERFACE_HOB LocalHashInterfaceHob;
UINT32 HashMask;
UINT32 BiosSupportedHashMask;
EFI_STATUS Status;

//
// Check allow
Expand All @@ -280,7 +281,8 @@ RegisterHashInterfaceLib (
return EFI_OUT_OF_RESOURCES;
}
BiosSupportedHashMask = PcdGet32 (PcdTcg2HashAlgorithmBitmap);
PcdSet32 (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | HashMask);
Status = PcdSet32S (PcdTcg2HashAlgorithmBitmap, BiosSupportedHashMask | HashMask);
ASSERT_EFI_ERROR (Status);

//
// Check duplication
Expand Down
3 changes: 2 additions & 1 deletion SecurityPkg/Tcg/Tcg2Config/Tcg2ConfigPeim.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ Tcg2ConfigPeimEntryPoint (
for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
if (TpmDevice == mTpmInstanceId[Index].TpmDevice) {
Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid);
PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
Status = PcdSetPtrS (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
ASSERT_EFI_ERROR (Status);
DEBUG ((EFI_D_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));
break;
}
Expand Down
3 changes: 2 additions & 1 deletion SecurityPkg/Tcg/Tcg2Config/TpmDetection.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ DetectTpmDevice (
}

// NO initialization needed again.
PcdSet8 (PcdTpmInitializationPolicy, 0);
Status = PcdSet8S (PcdTpmInitializationPolicy, 0);
ASSERT_EFI_ERROR (Status);
return TPM_DEVICE_1_2;
}
3 changes: 2 additions & 1 deletion SecurityPkg/Tcg/Tcg2Pei/Tcg2Pei.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ SetTpm2HashMask (
}
}
}
PcdSet32 (PcdTpm2HashMask, ActivePcrBanks);
Status = PcdSet32S (PcdTpm2HashMask, ActivePcrBanks);
ASSERT_EFI_ERROR (Status);
}

/**
Expand Down
5 changes: 3 additions & 2 deletions SecurityPkg/Tcg/TrEEConfig/TpmDetection.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
TPM1.2/dTPM2.0 auto detection.
Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2013 - 2015, Intel Corporation. All rights reserved.<BR>
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
Expand Down Expand Up @@ -124,6 +124,7 @@ DetectTpmDevice (
}

// NO initialization needed again.
PcdSet8 (PcdTpmInitializationPolicy, 0);
Status = PcdSet8S (PcdTpmInitializationPolicy, 0);
ASSERT_EFI_ERROR (Status);
return TPM_DEVICE_1_2;
}
3 changes: 2 additions & 1 deletion SecurityPkg/Tcg/TrEEConfig/TrEEConfigPeim.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ TrEEConfigPeimEntryPoint (
for (Index = 0; Index < sizeof(mTpmInstanceId)/sizeof(mTpmInstanceId[0]); Index++) {
if (TpmDevice == mTpmInstanceId[Index].TpmDevice) {
Size = sizeof(mTpmInstanceId[Index].TpmInstanceGuid);
PcdSetPtr (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
Status = PcdSetPtrS (PcdTpmInstanceGuid, &Size, &mTpmInstanceId[Index].TpmInstanceGuid);
ASSERT_EFI_ERROR (Status);
DEBUG ((EFI_D_INFO, "TpmDevice PCD: %g\n", &mTpmInstanceId[Index].TpmInstanceGuid));
break;
}
Expand Down

0 comments on commit fe3ca12

Please sign in to comment.