From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: eric.jin@intel.com) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by groups.io with SMTP; Thu, 01 Aug 2019 01:45:31 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Aug 2019 01:45:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,333,1559545200"; d="scan'208";a="372534769" Received: from jjin9-mobl.ccr.corp.intel.com ([10.239.192.65]) by fmsmga006.fm.intel.com with ESMTP; 01 Aug 2019 01:45:27 -0700 From: "Eric Jin" To: devel@edk2.groups.io Cc: Sean Brogan , Michael Turner , Bret Barkelew , Liming Gao , Michael D Kinney Subject: [PATCH 07/14] FmpDevicePkg/FmpDxe: Improve all DEBUG() messages Date: Thu, 1 Aug 2019 16:45:21 +0800 Message-Id: <20190801084521.18564-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 b3564e1be9..4f41543194 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; @@ -296,7 +296,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; } @@ -314,13 +314,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 @@ -431,7 +431,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; } @@ -442,7 +442,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; } @@ -452,7 +452,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; } @@ -537,13 +537,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; } @@ -557,13 +557,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; } @@ -711,7 +711,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; } @@ -722,7 +722,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 // @@ -734,7 +734,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 { // @@ -744,7 +744,8 @@ CheckTheImage ( Index++; DEBUG ( (DEBUG_INFO, - "FmpDxe: Certificate #%d [%p..%p].\n", + "FmpDxe(%s): Certificate #%d [%p..%p].\n", + mImageIdName, Index, PublicKeyDataXdr, PublicKeyDataXdrEnd @@ -755,7 +756,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; } @@ -771,7 +772,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; } @@ -791,7 +792,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; } @@ -799,7 +800,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; @@ -811,13 +812,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; @@ -829,8 +830,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; @@ -854,7 +855,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; } @@ -865,7 +866,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: @@ -974,7 +975,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; } @@ -984,7 +985,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; } @@ -997,7 +998,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; } @@ -1013,15 +1014,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; } @@ -1033,7 +1034,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)); } // @@ -1041,14 +1042,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; @@ -1061,14 +1062,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; } @@ -1080,14 +1081,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; } @@ -1105,13 +1106,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; } @@ -1133,7 +1134,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; } @@ -1301,9 +1302,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; @@ -1330,8 +1331,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 // @@ -1355,7 +1354,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; } @@ -1363,10 +1362,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) { @@ -1380,17 +1376,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)); } // @@ -1405,32 +1399,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)) { @@ -1495,6 +1484,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; } @@ -1512,6 +1502,7 @@ UninstallFmpInstance ( NULL ); if (EFI_ERROR (Status)) { + DEBUG ((DEBUG_ERROR, "FmpDxe(%s): Protocol uninstall error. Status = %r.\n", mImageIdName, Status)); return Status; } @@ -1598,11 +1589,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. // @@ -1623,7 +1614,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 @@ -1634,24 +1625,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 5aeabf88b2..5b4242d932 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 @@ -487,7 +491,7 @@ SetVersionInVariable ( FmpControllerState->VersionValid = TRUE; FmpControllerState->Version = Version; 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 { Status = gRT->SetVariable ( Private->FmpStateVariableName, @@ -497,9 +501,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 ( FmpControllerState->LsvValid = TRUE; FmpControllerState->Lsv = LowestSupportedVersion; 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 { Status = gRT->SetVariable ( Private->FmpStateVariableName, @@ -558,9 +563,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 @@ -609,7 +615,7 @@ SetLastAttemptStatusInVariable ( FmpControllerState->LastAttemptStatusValid = TRUE; FmpControllerState->LastAttemptStatus = LastAttemptStatus; 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 { Status = gRT->SetVariable ( Private->FmpStateVariableName, @@ -619,9 +625,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 @@ -670,7 +677,7 @@ SetLastAttemptVersionInVariable ( FmpControllerState->LastAttemptVersionValid = TRUE; FmpControllerState->LastAttemptVersion = LastAttemptVersion; 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 { Status = gRT->SetVariable ( Private->FmpStateVariableName, @@ -680,9 +687,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 @@ -724,7 +732,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 @@ -761,7 +770,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