X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FUniversal%2FVariable%2FRuntimeDxe%2FVariableNonVolatile.c;fp=MdeModulePkg%2FUniversal%2FVariable%2FRuntimeDxe%2FVariableNonVolatile.c;h=9e2d8fe0fe0cc1ccd2608775c6bbadaf1abf484d;hp=5e9d40b67ac29f364c9927bda2efbecf38c4a728;hb=4dbebc2d102e83dbafab568a2f7471791001b42c;hpb=60b519456cf01beb269bf864a37fa2acdc53f003 diff --git a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c index 5e9d40b67a..9e2d8fe0fe 100644 --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableNonVolatile.c @@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore ( EFI_PHYSICAL_ADDRESS NvStorageBase; UINT8 *NvStorageData; UINT32 NvStorageSize; + UINT64 NvStorageSize64; FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData; UINT32 BackUpOffset; UINT32 BackUpSize; @@ -153,19 +154,24 @@ InitRealNonVolatileVariableStore ( mVariableModuleGlobal->FvbInstance = NULL; + Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64); + ASSERT_EFI_ERROR (Status); + + Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize); + // This driver currently assumes the size will be UINT32 so assert the value is safe for now. + ASSERT_EFI_ERROR (Status); + + ASSERT (NvStorageBase != 0); + // // Allocate runtime memory used for a memory copy of the FLASH region. // Keep the memory and the FLASH in sync as updates occur. // - NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize); NvStorageData = AllocateRuntimeZeroPool (NvStorageSize); if (NvStorageData == NULL) { return EFI_OUT_OF_RESOURCES; } - NvStorageBase = NV_STORAGE_VARIABLE_BASE; - ASSERT (NvStorageBase != 0); - // // Copy NV storage data to the memory buffer. //