summaryrefslogtreecommitdiffstats
path: root/StandaloneMmPkg/Core/FwVol.c
diff options
context:
space:
mode:
authorLevi Yun <yeoreum.yun@arm.com>2025-01-09 10:17:27 +0000
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2025-01-20 09:13:26 +0000
commit2091e449f17936175a043a067b99595fb1c9789d (patch)
tree11bfc27344164b69ccfd97cd43eae18c7ce95587 /StandaloneMmPkg/Core/FwVol.c
parent2d2642f4832ebc45cb7d5ba9430b933d953b94f2 (diff)
downloadedk2-2091e449f17936175a043a067b99595fb1c9789d.tar.gz
StandaloneMmPkg: Introduce a PCD to disable shadow boot FV
On some Arm platforms the boot firmware volume passed in the HOB by the secure world firmware (TF-A) is never freed and is always mapped as read-only. On such platforms the heap memory can be saved by disabling the shadow copy of the boot firmware volume. This is useful as on some platforms the amount of memory available is limited. Therefore, introduce a PCD PcdShadowBfv that platforms can configure to disable the shadow boot FV. This PCD is set to TRUE by default. Signed-off-by: Levi Yun <yeoreum.yun@arm.com>
Diffstat (limited to 'StandaloneMmPkg/Core/FwVol.c')
-rw-r--r--StandaloneMmPkg/Core/FwVol.c42
1 files changed, 32 insertions, 10 deletions
diff --git a/StandaloneMmPkg/Core/FwVol.c b/StandaloneMmPkg/Core/FwVol.c
index 9559581e74..d5dfdacbf0 100644
--- a/StandaloneMmPkg/Core/FwVol.c
+++ b/StandaloneMmPkg/Core/FwVol.c
@@ -270,18 +270,36 @@ MmDispatchFvs (
DEBUG ((DEBUG_INFO, "%a: FV[%d] address - 0x%x\n", __func__, Index, FvHob.FirmwareVolume->BaseAddress));
DEBUG ((DEBUG_INFO, "%a: FV[%d] size - 0x%x\n", __func__, Index, FvHob.FirmwareVolume->Length));
- Fv = AllocatePool (FvHob.FirmwareVolume->Length);
- if (Fv == NULL) {
- DEBUG ((DEBUG_ERROR, "Fail to allocate memory for Fv\n"));
- CpuDeadLoop ();
- return;
+
+ if (FvHob.FirmwareVolume->Length == 0x00) {
+ DEBUG ((
+ DEBUG_INFO,
+ "%a: Skip invalid FV[%d]- 0x%x/0x%x\n",
+ __func__,
+ Index,
+ FvHob.FirmwareVolume->BaseAddress,
+ FvHob.FirmwareVolume->Length
+ ));
+ continue;
+ }
+
+ if (!FixedPcdGetBool (PcdShadowBfv)) {
+ Fv = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvHob.FirmwareVolume->BaseAddress);
+ } else {
+ Fv = AllocatePool (FvHob.FirmwareVolume->Length);
+ if (Fv == NULL) {
+ DEBUG ((DEBUG_ERROR, "Fail to allocate memory for Fv\n"));
+ CpuDeadLoop ();
+ return;
+ }
+
+ CopyMem (
+ (VOID *)Fv,
+ (VOID *)(UINTN)FvHob.FirmwareVolume->BaseAddress,
+ FvHob.FirmwareVolume->Length
+ );
}
- CopyMem (
- (VOID *)Fv,
- (VOID *)(UINTN)FvHob.FirmwareVolume->BaseAddress,
- FvHob.FirmwareVolume->Length
- );
MmCoreFfsFindMmDriver (Fv, 0);
mMmFv[Index++] = Fv;
@@ -307,6 +325,10 @@ MmFreeShadowedFvs (
{
UINTN Index;
+ if (!FixedPcdGetBool (PcdShadowBfv)) {
+ return;
+ }
+
for (Index = 0; Index < ARRAY_SIZE (mMmFv); Index++) {
if (mMmFv[Index] != NULL) {
FreePool (mMmFv[Index]);