Hi Min M Xu, 

I have filed a EDK2 bug relates to this patch:

Bug 4379 - Got NvVarStore FV headers were invalid when using OVMF with AMD SEV
https://bugzilla.tianocore.org/show_bug.cgi?id=4379  

I got a "NvVarStore FV headers were invalid." assert when using OVMF with AMD
SEV. After reverted this patch, the assert is gone.

Thanks!
Joey Lee

On Tue, Sep 06, 2022 at 12:35:56PM +0800, Min Xu via groups.io wrote:
> From: Min M Xu <min.m...@intel.com>
> 
> ReserveEmuVariableNvStore is updated with below 2 functions defined in
> PlatformInitLib:
>  - PlatformReserveEmuVariableNvStore
>  - PlatformInitEmuVariableNvStore
> 
> PlatformInitEmuVariableNvStore works when secure boot feature is enabled.
> This is because secure boot needs the EFI variables (PK/KEK/DB/DBX, etc)
> and EmuVariableNvStore is cleared when OVMF is launched with -bios
> parameter.
> 
> Cc: Erdem Aktas <erdemak...@google.com>
> Cc: James Bottomley <j...@linux.ibm.com>
> Cc: Jiewen Yao <jiewen....@intel.com>
> Cc: Tom Lendacky <thomas.lenda...@amd.com>
> Cc: Gerd Hoffmann <kra...@redhat.com>
> Acked-by: Gerd Hoffmann <kra...@redhat.com>
> Signed-off-by: Min Xu <min.m...@intel.com>
> ---
>  OvmfPkg/PlatformPei/Platform.c | 25 +++++++------------------
>  1 file changed, 7 insertions(+), 18 deletions(-)
> 
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 009db67ee60a..b1f8140d6041 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -220,24 +220,13 @@ ReserveEmuVariableNvStore (
>    EFI_PHYSICAL_ADDRESS  VariableStore;
>    RETURN_STATUS         PcdStatus;
>  
> -  //
> -  // Allocate storage for NV variables early on so it will be
> -  // at a consistent address.  Since VM memory is preserved
> -  // across reboots, this allows the NV variable storage to survive
> -  // a VM reboot.
> -  //
> -  VariableStore =
> -    (EFI_PHYSICAL_ADDRESS)(UINTN)
> -    AllocateRuntimePages (
> -      EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize))
> -      );
> -  DEBUG ((
> -    DEBUG_INFO,
> -    "Reserved variable store memory: 0x%lX; size: %dkb\n",
> -    VariableStore,
> -    (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024
> -    ));
> -  PcdStatus = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
> +  VariableStore = 
> (EFI_PHYSICAL_ADDRESS)(UINTN)PlatformReserveEmuVariableNvStore ();
> +  PcdStatus     = PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore);
> +
> + #ifdef SECURE_BOOT_FEATURE_ENABLED
> +  PlatformInitEmuVariableNvStore ((VOID *)(UINTN)VariableStore);
> + #endif
> +
>    ASSERT_RETURN_ERROR (PcdStatus);
>  }
>  
> -- 
> 2.29.2.windows.2
> 
> 
> 
> 
> 


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#101482): https://edk2.groups.io/g/devel/message/101482
Mute This Topic: https://groups.io/mt/93494907/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to