From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.43, mailfrom: eric.jin@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Sun, 11 Aug 2019 19:01:42 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Aug 2019 19:01:42 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,375,1559545200"; d="scan'208";a="375083051" Received: from unknown (HELO jjin9-MOBL.ccr.corp.intel.com) ([10.239.192.132]) by fmsmga005.fm.intel.com with ESMTP; 11 Aug 2019 19:01:40 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Michael Turner , Bret Barkelew , Liming Gao , Michael D Kinney Subject: [PATCH V2 07/10] FmpDevicePkg/FmpDxe: Improve all DEBUG() messages Date: Mon, 12 Aug 2019 10:01:38 +0800 Message-Id: <20190812020138.43880-1-eric.jin@intel.com> X-Mailer: git-send-email 2.20.1.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1525 Update all DEBUG() messages to include the name of the FMP device from PcdFmpDeviceImageIdName. Based on content from the following commit, but expanded to cover all DEBUG() messages. https://github.com/microsoft/mu_tiano_plus/commit/a2c7da88d3a73dbe9b6b75952d6866179c905f28#diff-025d4889f6d3a482b49638a25e432d6d Cc: Sean Brogan Cc: Michael Turner Cc: Bret Barkelew Cc: Liming Gao Signed-off-by: Michael D Kinney Reviewed-by: Eric Jin --- FmpDevicePkg/FmpDxe/DetectTestKey.c | 16 +-- FmpDevicePkg/FmpDxe/FmpDxe.c | 134 ++++++++++++-------------- FmpDevicePkg/FmpDxe/FmpDxe.h | 7 ++ FmpDevicePkg/FmpDxe/VariableSupport.c | 71 ++++++++------ 4 files changed, 115 insertions(+), 113 deletions(-) diff --git a/FmpDevicePkg/FmpDxe/DetectTestKey.c b/FmpDevicePkg/FmpDxe/DetectTestKey.c index e697a08489..0e10d5ee17 100644 --- a/FmpDevicePkg/FmpDxe/DetectTestKey.c +++ b/FmpDevicePkg/FmpDxe/DetectTestKey.c @@ -1,19 +1,13 @@ /** @file Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key. - Copyright (c) 2018, Intel Corporation. All rights reserved.
+ Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent **/ -#include -#include -#include -#include -#include -#include -#include +#include "FmpDxe.h" /** Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches @@ -39,7 +33,7 @@ DetectTestKey ( UINTN TestKeyDigestSize; // - // If PcdFmpDeviceTestKeySha256Digest is not exacty SHA256_DIGEST_SIZE bytes, + // If PcdFmpDeviceTestKeySha256Digest is not exactly SHA256_DIGEST_SIZE bytes, // then skip the test key detection. // TestKeyDigestSize = PcdGetSize (PcdFmpDeviceTestKeySha256Digest); @@ -143,9 +137,9 @@ DetectTestKey ( // set PcdTestKeyUsed to TRUE. // if (TestKeyUsed) { - DEBUG ((DEBUG_INFO, "FmpDxe: Test key detected in PcdFmpDevicePkcs7CertBufferXdr.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Test key detected in PcdFmpDevicePkcs7CertBufferXdr.\n", mImageIdName)); PcdSetBoolS (PcdTestKeyUsed, TRUE); } else { - DEBUG ((DEBUG_INFO, "FmpDxe: No test key detected in PcdFmpDevicePkcs7CertBufferXdr.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): No test key detected in PcdFmpDevicePkcs7CertBufferXdr.\n", mImageIdName)); } } diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.c b/FmpDevicePkg/FmpDxe/FmpDxe.c index 1574425fd6..b160e0f542 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.c +++ b/FmpDevicePkg/FmpDxe/FmpDxe.c @@ -164,12 +164,12 @@ GetImageTypeIdGuid ( Status = FmpDeviceGetImageTypeIdGuidPtr (&FmpDeviceLibGuid); if (EFI_ERROR (Status)) { if (Status != EFI_UNSUPPORTED) { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid error %r\n", mImageIdName, Status)); } return &gEfiCallerIdGuid; } if (FmpDeviceLibGuid == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib GetImageTypeIdGuidPtr() returned invalid GUID\n", mImageIdName)); return &gEfiCallerIdGuid; } return FmpDeviceLibGuid; @@ -299,7 +299,7 @@ PopulateDescriptor ( // // Unexpected error. Use default version. // - DEBUG ((DEBUG_ERROR, "FmpDxe: GetVersion() from FmpDeviceLib (%s) returned %r\n", GetImageTypeNameString(), Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetVersion() from FmpDeviceLib (%s) returned %r\n", mImageIdName, GetImageTypeNameString(), Status)); Private->Descriptor.Version = DEFAULT_VERSION; } @@ -317,13 +317,13 @@ PopulateDescriptor ( // Status = FmpDeviceGetVersionString (&Private->Descriptor.VersionName); if (Status == EFI_UNSUPPORTED) { - DEBUG ((DEBUG_INFO, "FmpDxe: GetVersionString() unsupported in FmpDeviceLib.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): GetVersionString() unsupported in FmpDeviceLib.\n", mImageIdName)); Private->Descriptor.VersionName = AllocateCopyPool ( sizeof (VERSION_STRING_NOT_SUPPORTED), VERSION_STRING_NOT_SUPPORTED ); } else if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_INFO, "FmpDxe: GetVersionString() not available in FmpDeviceLib.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): GetVersionString() not available in FmpDeviceLib.\n", mImageIdName)); Private->Descriptor.VersionName = AllocateCopyPool ( sizeof (VERSION_STRING_NOT_AVAILABLE), VERSION_STRING_NOT_AVAILABLE @@ -434,7 +434,7 @@ GetTheImageInfo ( // Check for valid pointer // if (ImageInfoSize == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImageInfo() - ImageInfoSize is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - ImageInfoSize is NULL.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -445,7 +445,7 @@ GetTheImageInfo ( // if (*ImageInfoSize < (sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR))) { *ImageInfoSize = sizeof (EFI_FIRMWARE_IMAGE_DESCRIPTOR); - DEBUG ((DEBUG_VERBOSE, "FmpDxe: GetImageInfo() - ImageInfoSize is to small.\n")); + DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): GetImageInfo() - ImageInfoSize is to small.\n", mImageIdName)); Status = EFI_BUFFER_TOO_SMALL; goto cleanup; } @@ -455,7 +455,7 @@ GetTheImageInfo ( // if ( (ImageInfo == NULL) || (DescriptorVersion == NULL) || (DescriptorCount == NULL) || (DescriptorSize == NULL) || (PackageVersion == NULL)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImageInfo() - Pointer Parameter is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImageInfo() - Pointer Parameter is NULL.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -540,13 +540,13 @@ GetTheImage ( // Check to make sure index is 1 (only 1 image for this device) // if (ImageIndex != 1) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Index Invalid.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - Image Index Invalid.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } if (ImageSize == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - ImageSize Pointer Parameter is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - ImageSize Pointer Parameter is NULL.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -560,13 +560,13 @@ GetTheImage ( } if (*ImageSize < Size) { *ImageSize = Size; - DEBUG ((DEBUG_VERBOSE, "FmpDxe: GetImage() - ImageSize is to small.\n")); + DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): GetImage() - ImageSize is to small.\n", mImageIdName)); Status = EFI_BUFFER_TOO_SMALL; goto cleanup; } if (Image == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: GetImage() - Image Pointer Parameter is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): GetImage() - Image Pointer Parameter is NULL.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -714,7 +714,7 @@ CheckTheImage ( PopulateDescriptor (Private); if (ImageUpdatable == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - ImageUpdatable Pointer Parameter is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - ImageUpdatable Pointer Parameter is NULL.\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -725,7 +725,7 @@ CheckTheImage ( *ImageUpdatable = IMAGE_UPDATABLE_VALID; if (Image == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - Image Pointer Parameter is NULL.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - Image Pointer Parameter is NULL.\n", mImageIdName)); // // not sure if this is needed // @@ -737,7 +737,7 @@ CheckTheImage ( PublicKeyDataXdrEnd = PublicKeyDataXdr + PcdGetSize (PcdFmpDevicePkcs7CertBufferXdr); if (PublicKeyDataXdr == NULL || (PublicKeyDataXdr == PublicKeyDataXdrEnd)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Invalid certificate, skipping it.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Invalid certificate, skipping it.\n", mImageIdName)); Status = EFI_ABORTED; } else { // @@ -747,7 +747,8 @@ CheckTheImage ( Index++; DEBUG ( (DEBUG_INFO, - "FmpDxe: Certificate #%d [%p..%p].\n", + "FmpDxe(%s): Certificate #%d [%p..%p].\n", + mImageIdName, Index, PublicKeyDataXdr, PublicKeyDataXdrEnd @@ -758,7 +759,7 @@ CheckTheImage ( // // Key data extends beyond end of PCD // - DEBUG ((DEBUG_ERROR, "FmpDxe: Certificate size extends beyond end of PCD, skipping it.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate size extends beyond end of PCD, skipping it.\n", mImageIdName)); Status = EFI_ABORTED; break; } @@ -774,7 +775,7 @@ CheckTheImage ( // // Key data extends beyond end of PCD // - DEBUG ((DEBUG_ERROR, "FmpDxe: Certificate extends beyond end of PCD, skipping it.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Certificate extends beyond end of PCD, skipping it.\n", mImageIdName)); Status = EFI_ABORTED; break; } @@ -794,7 +795,7 @@ CheckTheImage ( } if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - Authentication Failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - Authentication Failed %r.\n", mImageIdName, Status)); goto cleanup; } @@ -802,7 +803,7 @@ CheckTheImage ( // Check to make sure index is 1 // if (ImageIndex != 1) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckImage() - Image Index Invalid.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckImage() - Image Index Invalid.\n", mImageIdName)); *ImageUpdatable = IMAGE_UPDATABLE_INVALID_TYPE; Status = EFI_SUCCESS; goto cleanup; @@ -814,13 +815,13 @@ CheckTheImage ( // FmpPayloadHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, &FmpPayloadSize ); if (FmpPayloadHeader == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpHeader failed.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpHeader failed.\n", mImageIdName)); Status = EFI_ABORTED; goto cleanup; } Status = GetFmpPayloadHeaderVersion (FmpPayloadHeader, FmpPayloadSize, &Version); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetFmpPayloadHeaderVersion failed %r.\n", mImageIdName, Status)); *ImageUpdatable = IMAGE_UPDATABLE_INVALID; Status = EFI_SUCCESS; goto cleanup; @@ -832,8 +833,8 @@ CheckTheImage ( if (Version < Private->Descriptor.LowestSupportedImageVersion) { DEBUG ( (DEBUG_ERROR, - "FmpDxe: CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n", - Version, Private->Descriptor.LowestSupportedImageVersion) + "FmpDxe(%s): CheckTheImage() - Version Lower than lowest supported version. 0x%08X < 0x%08X\n", + mImageIdName, Version, Private->Descriptor.LowestSupportedImageVersion) ); *ImageUpdatable = IMAGE_UPDATABLE_INVALID_OLD; Status = EFI_SUCCESS; @@ -857,7 +858,7 @@ CheckTheImage ( // AllHeaderSize = GetAllHeaderSize ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize ); if (AllHeaderSize == 0) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - GetAllHeaderSize failed.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - GetAllHeaderSize failed.\n", mImageIdName)); Status = EFI_ABORTED; goto cleanup; } @@ -868,7 +869,7 @@ CheckTheImage ( // Status = FmpDeviceCheckImage ((((UINT8 *)Image) + AllHeaderSize), RawSize, ImageUpdatable); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): CheckTheImage() - FmpDeviceLib CheckImage failed. Status = %r\n", mImageIdName, Status)); } cleanup: @@ -977,7 +978,7 @@ SetTheImage ( // it should be blocked by hardware too but we can catch here even faster // if (Private->FmpDeviceLocked) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Device is already locked. Can't update.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Device is already locked. Can't update.\n", mImageIdName)); Status = EFI_UNSUPPORTED; goto cleanup; } @@ -987,7 +988,7 @@ SetTheImage ( // Status = CheckTheImage (This, ImageIndex, Image, ImageSize, &Updateable); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Check The Image failed with %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Check The Image failed with %r.\n", mImageIdName, Status)); if (Status == EFI_SECURITY_VIOLATION) { LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_AUTH_ERROR; } @@ -1000,7 +1001,7 @@ SetTheImage ( // FmpHeader = GetFmpHeader ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, ImageSize, &FmpPayloadSize ); if (FmpHeader == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetFmpHeader failed.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpHeader failed.\n", mImageIdName)); Status = EFI_ABORTED; goto cleanup; } @@ -1016,15 +1017,15 @@ SetTheImage ( if (Updateable != IMAGE_UPDATABLE_VALID) { DEBUG ( (DEBUG_ERROR, - "FmpDxed: SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n", - Updateable) + "FmpDxe(%s): SetTheImage() - Check The Image returned that the Image was not valid for update. Updatable value = 0x%X.\n", + mImageIdName, Updateable) ); Status = EFI_ABORTED; goto cleanup; } if (Progress == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Invalid progress callback\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Invalid progress callback\n", mImageIdName)); Status = EFI_INVALID_PARAMETER; goto cleanup; } @@ -1036,7 +1037,7 @@ SetTheImage ( // Status = Progress (1); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - Progress Callback failed with Status %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - Progress Callback failed with Status %r.\n", mImageIdName, Status)); } // @@ -1044,14 +1045,14 @@ SetTheImage ( // Status = CheckSystemPower (&BooleanValue); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemPower - API call failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemPower - API call failed %r.\n", mImageIdName, Status)); goto cleanup; } if (!BooleanValue) { Status = EFI_ABORTED; DEBUG ( (DEBUG_ERROR, - "FmpDxe: SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n") + "FmpDxe(%s): SetTheImage() - CheckSystemPower - returned False. Update not allowed due to System Power.\n", mImageIdName) ); LastAttemptStatus = LAST_ATTEMPT_STATUS_ERROR_PWR_EVT_BATT; goto cleanup; @@ -1064,14 +1065,14 @@ SetTheImage ( // Status = CheckSystemThermal (&BooleanValue); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemThermal - API call failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemThermal - API call failed %r.\n", mImageIdName, Status)); goto cleanup; } if (!BooleanValue) { Status = EFI_ABORTED; DEBUG ( (DEBUG_ERROR, - "FmpDxe: SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n") + "FmpDxe(%s): SetTheImage() - CheckSystemThermal - returned False. Update not allowed due to System Thermal.\n", mImageIdName) ); goto cleanup; } @@ -1083,14 +1084,14 @@ SetTheImage ( // Status = CheckSystemEnvironment (&BooleanValue); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - API call failed %r.\n", mImageIdName, Status)); goto cleanup; } if (!BooleanValue) { Status = EFI_ABORTED; DEBUG ( (DEBUG_ERROR, - "FmpDxe: SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n") + "FmpDxe(%s): SetTheImage() - CheckSystemEnvironment - returned False. Update not allowed due to System Environment.\n", mImageIdName) ); goto cleanup; } @@ -1108,13 +1109,13 @@ SetTheImage ( // Status = GetFmpPayloadHeaderSize (FmpHeader, FmpPayloadSize, &FmpHeaderSize); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetFmpPayloadHeaderSize failed %r.\n", mImageIdName, Status)); goto cleanup; } AllHeaderSize = GetAllHeaderSize ( (EFI_FIRMWARE_IMAGE_AUTHENTICATION *)Image, FmpHeaderSize ); if (AllHeaderSize == 0) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() - GetAllHeaderSize failed.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() - GetAllHeaderSize failed.\n", mImageIdName)); Status = EFI_ABORTED; goto cleanup; } @@ -1136,7 +1137,7 @@ SetTheImage ( AbortReason ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: SetTheImage() SetImage from FmpDeviceLib failed. Status = %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): SetTheImage() SetImage from FmpDeviceLib failed. Status = %r.\n", mImageIdName, Status)); goto cleanup; } @@ -1304,9 +1305,9 @@ FmpDxeLockEventNotify ( Status = FmpDeviceLock(); if (EFI_ERROR (Status)) { if (Status != EFI_UNSUPPORTED) { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLock() returned error. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_WARN, "FmpDxe: FmpDeviceLock() returned error. Status = %r\n", Status)); + DEBUG ((DEBUG_WARN, "FmpDxe(%s): FmpDeviceLock() returned error. Status = %r\n", mImageIdName, Status)); } } Private->FmpDeviceLocked = TRUE; @@ -1333,8 +1334,6 @@ InstallFmpInstance ( EFI_FIRMWARE_MANAGEMENT_PROTOCOL *Fmp; FIRMWARE_MANAGEMENT_PRIVATE_DATA *Private; - DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Entry\n")); - // // Only allow a single FMP Protocol instance to be installed // @@ -1358,7 +1357,7 @@ InstallFmpInstance ( &mFirmwareManagementPrivateDataTemplate ); if (Private == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to allocate memory for private structure.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to allocate memory for private structure.\n", mImageIdName)); Status = EFI_OUT_OF_RESOURCES; goto cleanup; } @@ -1366,10 +1365,7 @@ InstallFmpInstance ( // // Initialize private context data structure // - DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Initialize private context data structure\n")); - Private->Handle = Handle; - Private->FmpDeviceContext = NULL; Status = FmpDeviceSetContext (Private->Handle, &Private->FmpDeviceContext); if (Status == EFI_UNSUPPORTED) { @@ -1383,17 +1379,15 @@ InstallFmpInstance ( // PopulateDescriptor (Private); - DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Lock events\n")); - if (IsLockFmpDeviceAtLockEventGuidRequired ()) { // - // Lock all UEFI Variables used by this module. + // Register all UEFI Variables used by this module to be locked. // Status = LockAllFmpVariables (Private); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variables. Status = %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to register variables to lock. Status = %r.\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_INFO, "FmpDxe: All variables locked\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): All variables registered to lock\n", mImageIdName)); } // @@ -1408,32 +1402,27 @@ InstallFmpInstance ( &Private->FmpDeviceLockEvent ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to register notification. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to register notification. Status = %r\n", mImageIdName, Status)); } ASSERT_EFI_ERROR (Status); } else { - DEBUG ((DEBUG_VERBOSE, "FmpDxe: Not registering notification to call FmpDeviceLock() because mfg mode\n")); + DEBUG ((DEBUG_VERBOSE, "FmpDxe(%s): Not registering notification to call FmpDeviceLock() because mfg mode\n", mImageIdName)); } // // Install FMP Protocol and FMP Progress Protocol // - DEBUG ((DEBUG_ERROR, "InstallFmpInstance: Install FMP Protocol and FMP Progress Protocol\n")); - Status = gBS->InstallMultipleProtocolInterfaces ( &Private->Handle, &gEfiFirmwareManagementProtocolGuid, &Private->Fmp, &gEdkiiFirmwareManagementProgressProtocolGuid, &mFmpProgress, NULL ); - if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Protocol install error. Status = %r.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol install error. Status = %r.\n", mImageIdName, Status)); goto cleanup; } - DEBUG ((DEBUG_INFO, "FmpDxe: Protocols Installed!\n")); - cleanup: if (EFI_ERROR (Status)) { @@ -1498,6 +1487,7 @@ UninstallFmpInstance ( EFI_OPEN_PROTOCOL_GET_PROTOCOL ); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol open error. Status = %r.\n", mImageIdName, Status)); return Status; } @@ -1515,6 +1505,7 @@ UninstallFmpInstance ( NULL ); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol uninstall error. Status = %r.\n", mImageIdName, Status)); return Status; } @@ -1601,11 +1592,11 @@ FmpDxeEntryPoint ( // // PcdFmpDeviceImageIdName must be set to a non-empty Unicode string // - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib PcdFmpDeviceImageIdName is an empty string.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe: PcdFmpDeviceImageIdName is an empty string.\n")); ASSERT (FALSE); + return EFI_UNSUPPORTED; } - // // Detects if PcdFmpDevicePkcs7CertBufferXdr contains a test key. // @@ -1626,7 +1617,7 @@ FmpDxeEntryPoint ( if (PcdGetSize (PcdFmpDeviceLockEventGuid) == sizeof (EFI_GUID)) { mLockGuid = (EFI_GUID *)PcdGetPtr (PcdFmpDeviceLockEventGuid); } - DEBUG ((DEBUG_INFO, "FmpDxe: Lock GUID: %g\n", mLockGuid)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Lock GUID: %g\n", mImageIdName, mLockGuid)); // // Register with library the install function so if the library uses @@ -1637,24 +1628,25 @@ FmpDxeEntryPoint ( Status = RegisterFmpInstaller (InstallFmpInstance); if (Status == EFI_UNSUPPORTED) { mFmpSingleInstance = TRUE; - DEBUG ((DEBUG_INFO, "FmpDxe: FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): FmpDeviceLib registration returned EFI_UNSUPPORTED. Installing single FMP instance.\n", mImageIdName)); Status = RegisterFmpUninstaller (UninstallFmpInstance); if (Status == EFI_UNSUPPORTED) { Status = InstallFmpInstance (ImageHandle); } else { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n", mImageIdName)); Status = EFI_UNSUPPORTED; } } else if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib registration returned %r. No FMP installed.\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib registration returned %r. No FMP installed.\n", mImageIdName, Status)); } else { DEBUG (( DEBUG_INFO, - "FmpDxe: FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n" + "FmpDxe(%s): FmpDeviceLib registration returned EFI_SUCCESS. Expect FMP to be installed during the BDS/Device connection phase.\n", + mImageIdName )); Status = RegisterFmpUninstaller (UninstallFmpInstance); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "FmpDxe: FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n")); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): FmpDeviceLib RegisterFmpInstaller and RegisterFmpUninstaller do not match.\n", mImageIdName)); } } diff --git a/FmpDevicePkg/FmpDxe/FmpDxe.h b/FmpDevicePkg/FmpDxe/FmpDxe.h index 06514c67c8..28bfa41580 100644 --- a/FmpDevicePkg/FmpDxe/FmpDxe.h +++ b/FmpDevicePkg/FmpDxe/FmpDxe.h @@ -17,6 +17,8 @@ #include #include #include +#include +#include #include #include #include @@ -71,6 +73,11 @@ typedef struct { #define FIRMWARE_MANAGEMENT_PRIVATE_DATA_FROM_THIS(a) \ CR (a, FIRMWARE_MANAGEMENT_PRIVATE_DATA, Fmp, FIRMWARE_MANAGEMENT_PRIVATE_DATA_SIGNATURE) +/// +/// Null-terminated Unicode string retrieved from PcdFmpDeviceImageIdName. +/// +extern CHAR16 *mImageIdName; + /** Check to see if any of the keys in PcdFmpDevicePkcs7CertBufferXdr matches the test key. PcdFmpDeviceTestKeySha256Digest contains the SHA256 hash of diff --git a/FmpDevicePkg/FmpDxe/VariableSupport.c b/FmpDevicePkg/FmpDxe/VariableSupport.c index d06d6b36c7..6c1ecf7df9 100644 --- a/FmpDevicePkg/FmpDxe/VariableSupport.c +++ b/FmpDevicePkg/FmpDxe/VariableSupport.c @@ -75,9 +75,9 @@ DeleteFmpVariable ( if (Valid) { Status = gRT->SetVariable (VariableName, &gEfiCallerIdGuid, 0, 0, NULL); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed to delete FMP Variable %s. Status = %r\n", VariableName, Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to delete variable %s. Status = %r\n", mImageIdName, VariableName, Status)); } else { - DEBUG ((DEBUG_INFO, "Deleted FMP Variable %s\n", VariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Deleted variable %s\n", mImageIdName, VariableName)); } } } @@ -112,12 +112,12 @@ GetFmpControllerState ( &Size ); if (EFI_ERROR (Status) || FmpControllerState == NULL) { - DEBUG ((DEBUG_ERROR, "Failed to get the FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to get the controller state. Status = %r\n", mImageIdName, Status)); } else { if (Size == sizeof (*FmpControllerState)) { return FmpControllerState; } - DEBUG ((DEBUG_ERROR, "Getting FMP Controller State returned a size different than expected. Size = 0x%x\n", Size)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Getting controller state returned a size different than expected. Size = 0x%x\n", mImageIdName, Size)); } if (FmpControllerState != NULL) { FreePool (FmpControllerState); @@ -151,7 +151,7 @@ GenerateFmpVariableName ( VariableName = CatSPrint (NULL, BaseVariableName); if (VariableName == NULL) { - DEBUG ((DEBUG_ERROR, "Failed to generate FMP variable name %s.\n", BaseVariableName)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName)); return VariableName; } if (HardwareInstance == 0) { @@ -159,7 +159,7 @@ GenerateFmpVariableName ( } VariableName = CatSPrint (VariableName, L"%016lx", HardwareInstance); if (VariableName == NULL) { - DEBUG ((DEBUG_ERROR, "Failed to generate FMP variable name %s.\n", BaseVariableName)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to generate variable name %s.\n", mImageIdName, BaseVariableName)); } return VariableName; } @@ -234,11 +234,11 @@ GenerateFmpVariableNames ( VARNAME_FMPSTATE ); - DEBUG ((DEBUG_INFO, "FmpDxe Variable %g %s\n", &gEfiCallerIdGuid, Private->VersionVariableName)); - DEBUG ((DEBUG_INFO, "FmpDxe Variable %g %s\n", &gEfiCallerIdGuid, Private->LsvVariableName)); - DEBUG ((DEBUG_INFO, "FmpDxe Variable %g %s\n", &gEfiCallerIdGuid, Private->LastAttemptStatusVariableName)); - DEBUG ((DEBUG_INFO, "FmpDxe Variable %g %s\n", &gEfiCallerIdGuid, Private->LastAttemptVersionVariableName)); - DEBUG ((DEBUG_INFO, "FmpDxe Variable %g %s\n", &gEfiCallerIdGuid, Private->FmpStateVariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->VersionVariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LsvVariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LastAttemptStatusVariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->LastAttemptVersionVariableName)); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Variable %g %s\n", mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName)); Buffer = GetFmpControllerState (Private); if (Buffer != NULL) { @@ -258,7 +258,7 @@ GenerateFmpVariableNames ( // FMP Controller State was either not found or is wrong size. // Create a new FMP Controller State variable with the correct size. // - DEBUG ((DEBUG_INFO, "Create FMP Controller State\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Create controller state\n", mImageIdName)); GetFmpVariable ( Private->VersionVariableName, &FmpControllerState.VersionValid, @@ -292,7 +292,7 @@ GenerateFmpVariableNames ( // delete the individual variables. They can be used again on next boot // to create the FMP Controller State. // - DEBUG ((DEBUG_ERROR, "Failed to create FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to create controller state. Status = %r\n", mImageIdName, Status)); } else { DeleteFmpVariable (Private->VersionVariableName); DeleteFmpVariable (Private->LsvVariableName); @@ -327,7 +327,8 @@ GetVersionFromVariable ( if (FmpControllerState != NULL) { if (FmpControllerState->VersionValid) { Value = FmpControllerState->Version; - DEBUG ((DEBUG_INFO, "Get FMP Variable %g %s Version %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s Version %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, Value @@ -365,7 +366,8 @@ GetLowestSupportedVersionFromVariable ( if (FmpControllerState != NULL) { if (FmpControllerState->LsvValid) { Value = FmpControllerState->Lsv; - DEBUG ((DEBUG_INFO, "Get FMP Variable %g %s LowestSupportedVersion %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LowestSupportedVersion %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, Value @@ -402,7 +404,8 @@ GetLastAttemptStatusFromVariable ( if (FmpControllerState != NULL) { if (FmpControllerState->LastAttemptStatusValid) { Value = FmpControllerState->LastAttemptStatus; - DEBUG ((DEBUG_INFO, "Get FMP Variable %g %s LastAttemptStatus %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LastAttemptStatus %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, Value @@ -439,7 +442,8 @@ GetLastAttemptVersionFromVariable ( if (FmpControllerState != NULL) { if (FmpControllerState->LastAttemptVersionValid) { Value = FmpControllerState->LastAttemptVersion; - DEBUG ((DEBUG_INFO, "Get FMP Variable %g %s LastAttemptVersion %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Get variable %g %s LastAttemptVersion %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, Value @@ -486,7 +490,7 @@ SetVersionInVariable ( Update = TRUE; } if (!Update) { - DEBUG ((DEBUG_INFO, "No need to update FMP Controller State. Same value as before.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { FmpControllerState->VersionValid = TRUE; FmpControllerState->Version = Version; @@ -498,9 +502,10 @@ SetVersionInVariable ( FmpControllerState ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed to update FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_INFO, "Set FMP Variable %g %s Version %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s Version %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, Version @@ -548,7 +553,7 @@ SetLowestSupportedVersionInVariable ( Update = TRUE; } if (!Update) { - DEBUG ((DEBUG_INFO, "No need to update FMP Controller State. Same value as before.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { FmpControllerState->LsvValid = TRUE; FmpControllerState->Lsv = LowestSupportedVersion; @@ -560,9 +565,10 @@ SetLowestSupportedVersionInVariable ( FmpControllerState ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed to update FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_INFO, "Set FMP Variable %g %s LowestSupportedVersion %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LowestSupportedVersion %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, LowestSupportedVersion @@ -610,7 +616,7 @@ SetLastAttemptStatusInVariable ( Update = TRUE; } if (!Update) { - DEBUG ((DEBUG_INFO, "No need to update FMP Controller State. Same value as before.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { FmpControllerState->LastAttemptStatusValid = TRUE; FmpControllerState->LastAttemptStatus = LastAttemptStatus; @@ -622,9 +628,10 @@ SetLastAttemptStatusInVariable ( FmpControllerState ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed to update FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_INFO, "Set FMP Variable %g %s LastAttemptStatus %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LastAttemptStatus %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, LastAttemptStatus @@ -672,7 +679,7 @@ SetLastAttemptVersionInVariable ( Update = TRUE; } if (!Update) { - DEBUG ((DEBUG_INFO, "No need to update FMP Controller State. Same value as before.\n")); + DEBUG ((DEBUG_INFO, "FmpDxe(%s): No need to update controller state. Same value as before.\n", mImageIdName)); } else { FmpControllerState->LastAttemptVersionValid = TRUE; FmpControllerState->LastAttemptVersion = LastAttemptVersion; @@ -684,9 +691,10 @@ SetLastAttemptVersionInVariable ( FmpControllerState ); if (EFI_ERROR (Status)) { - DEBUG ((DEBUG_ERROR, "Failed to update FMP Controller State. Status = %r\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to update controller state. Status = %r\n", mImageIdName, Status)); } else { - DEBUG ((DEBUG_INFO, "Set FMP Variable %g %s LastAttemptVersion %08x\n", + DEBUG ((DEBUG_INFO, "FmpDxe(%s): Set variable %g %s LastAttemptVersion %08x\n", + mImageIdName, &gEfiCallerIdGuid, Private->FmpStateVariableName, LastAttemptVersion @@ -728,7 +736,8 @@ LockFmpVariable ( return PreviousStatus; } - DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to lock variable %g %s. Status = %r\n", + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to lock variable %g %s. Status = %r\n", + mImageIdName, &gEfiCallerIdGuid, VariableName, Status @@ -765,7 +774,7 @@ LockAllFmpVariables ( (VOID **)&VariableLock ); if (EFI_ERROR (Status) || VariableLock == NULL) { - DEBUG ((DEBUG_ERROR, "FmpDxe: Failed to locate Variable Lock Protocol (%r).\n", Status)); + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Failed to locate Variable Lock Protocol (%r).\n", mImageIdName, Status)); return EFI_UNSUPPORTED; } -- 2.20.1.windows.1