summaryrefslogtreecommitdiffstats
path: root/SecurityPkg/FvReportPei
diff options
context:
space:
mode:
authorAshraf Ali <ashraf.ali.s@intel.com>2024-08-14 23:16:29 +0530
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2024-09-03 05:02:41 +0000
commitcb9bdf37532e8b75c38bd4874f9c797d7f66ed30 (patch)
treef6f35f8b912f2e47921ba277087045d602854ab8 /SecurityPkg/FvReportPei
parenta859f4fc0397ec4a9d1af016b7e1f03ccf14b605 (diff)
downloadedk2-cb9bdf37532e8b75c38bd4874f9c797d7f66ed30.tar.gz
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>
Diffstat (limited to 'SecurityPkg/FvReportPei')
-rw-r--r--SecurityPkg/FvReportPei/FvReportPei.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/SecurityPkg/FvReportPei/FvReportPei.c b/SecurityPkg/FvReportPei/FvReportPei.c
index 6288dde16b..50773db056 100644
--- a/SecurityPkg/FvReportPei/FvReportPei.c
+++ b/SecurityPkg/FvReportPei/FvReportPei.c
@@ -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,