Reviewed-by: Rebecca Cran <rebecca@os.amperecomputing.com>
On 8/8/2024 9:12 PM, Nhi Pham wrote:
> From: Tam Chi Nguyen <tamnguyenchi@os.amperecomputing.com>
>
> Currently, the NVRAM FV region is only updated once at FlashPei that makes
> the data in NVRAM FV outdated with data in NVRAM region in SPI-NOR.
> It causes the duplication of the valid NV variables when the Variable
> Reclaim process performs. Consequently, after rebooting, system goes to
> an infinite loop at GetNextVariableName.
>
> It requires the data in NVRAM FV to be synced up with NVRAM cache in memory
> that is managed by VariableDxe.
>
> Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
> ---
> Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf | 1 +
> Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.c | 3 +++
> 2 files changed, 4 insertions(+)
>
> diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf b/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf
> index 008fd2315ffe..5f537cf7df27 100644
> --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf
> +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.inf
> @@ -25,6 +25,7 @@ [Packages]
> Silicon/Ampere/AmpereSiliconPkg/AmpereSiliconPkg.dec
>
> [LibraryClasses]
> + BaseMemoryLib
> DebugLib
> FlashLib
> PcdLib
> diff --git a/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.c b/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.c
> index 009694703ddd..853c458e375f 100644
> --- a/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.c
> +++ b/Silicon/Ampere/AmpereAltraPkg/Drivers/FlashFvbDxe/FlashFvbDxe.c
> @@ -6,6 +6,7 @@
>
> **/
>
> +#include <Library/BaseMemoryLib.h>
> #include <Library/DebugLib.h>
> #include <Library/FlashLib.h>
> #include <Library/PcdLib.h>
> @@ -361,6 +362,8 @@ FlashFvbDxeWrite (
> return EFI_DEVICE_ERROR;
> }
>
> + CopyMem ((UINT8 *)(UINTN)mNvStorageBase + Lba * mFlashBlockSize + Offset, Buffer, *NumBytes);
> +
> return Status;
> }
>