mirror of
				https://gitlab.com/qemu-project/edk2.git
				synced 2025-10-30 07:56:39 +08:00 
			
		
		
		
	SecurityPkg: Optimization by moving PeiServicesLocatePpi outside loop
This update refactors the code by moving the LocatePpi function call outside of the for loop where it was previously called repeatedly. By relocating the LocatePpi invocation outside of the loop, we improve the efficiency of the code by avoiding redundant lookups. Signed-off-by: Ashraf Ali <ashraf.ali.s@intel.com>
This commit is contained in:
		| @ -150,6 +150,16 @@ VerifyHashedFv ( | ||||
|   HashValue = AllocateZeroPool (AlgInfo->HashSize * (FvNumber + 1)); | ||||
|   ASSERT (HashValue != NULL); | ||||
|  | ||||
|   Status = PeiServicesLocatePpi ( | ||||
|              &gEdkiiPeiFirmwareVolumeShadowPpiGuid, | ||||
|              0, | ||||
|              NULL, | ||||
|              (VOID **)&FvShadowPpi | ||||
|              ); | ||||
|   if (EFI_ERROR (Status)) { | ||||
|     FvShadowPpi = NULL; | ||||
|   } | ||||
|  | ||||
|   // | ||||
|   // Calculate hash value for each FV first. | ||||
|   // | ||||
| @ -194,14 +204,8 @@ VerifyHashedFv ( | ||||
|     FvBuffer = AllocatePages (EFI_SIZE_TO_PAGES ((UINTN)FvInfo[FvIndex].Length)); | ||||
|  | ||||
|     ASSERT (FvBuffer != NULL); | ||||
|     Status = PeiServicesLocatePpi ( | ||||
|                &gEdkiiPeiFirmwareVolumeShadowPpiGuid, | ||||
|                0, | ||||
|                NULL, | ||||
|                (VOID **)&FvShadowPpi | ||||
|                ); | ||||
|  | ||||
|     if (!EFI_ERROR (Status)) { | ||||
|     if (FvShadowPpi != NULL) { | ||||
|       Status = FvShadowPpi->FirmwareVolumeShadow ( | ||||
|                               (EFI_PHYSICAL_ADDRESS)FvInfo[FvIndex].Base, | ||||
|                               FvBuffer, | ||||
| @ -209,7 +213,7 @@ VerifyHashedFv ( | ||||
|                               ); | ||||
|     } | ||||
|  | ||||
|     if (EFI_ERROR (Status)) { | ||||
|     if ((FvShadowPpi == NULL) || (EFI_ERROR (Status))) { | ||||
|       CopyMem ( | ||||
|         FvBuffer, | ||||
|         (CONST VOID *)(UINTN)FvInfo[FvIndex].Base, | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Ashraf Ali
					Ashraf Ali