From: Min M Xu <[email protected]> QEMU command option -pflash is not supported in Tdx guest. When Tdx guest is booted, EmuVariableFvbRuntimeDxe driver is loaded and the NvVarStore is initialized with empty content. This patch is to initialize the NvVarStore with the content of Configuration FV (CFV).
Cc: Erdem Aktas <[email protected]> Cc: James Bottomley <[email protected]> Cc: Jiewen Yao <[email protected]> Cc: Gerd Hoffmann <[email protected]> Cc: Tom Lendacky <[email protected]> Signed-off-by: Min Xu <[email protected]> --- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 19 +++++++++++++++++++ OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 2 ++ 2 files changed, 21 insertions(+) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c index 4fc715dc3681..96895272d806 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c @@ -717,6 +717,8 @@ FvbInitialize ( EFI_HANDLE Handle; EFI_PHYSICAL_ADDRESS Address; RETURN_STATUS PcdStatus; + UINT8 *CfvBase; + UINT32 CfvSize; DEBUG ((DEBUG_INFO, "EMU Variable FVB Started\n")); @@ -774,6 +776,23 @@ FvbInitialize ( mEmuVarsFvb.BufferPtr = Ptr; + // + // In Tdx guest the VarNvStore content should be initialized by the Configuration FV (CFV). + // Integrity of the CFV has been validated by TdxValidateCfv (@PlatformInitLib) + // + if (TdIsEnabled ()) { + CfvBase = (UINT8 *)(UINTN)PcdGet32 (PcdCfvBase); + CfvSize = (UINT32)PcdGet32 (PcdCfvRawDataSize); + + if (CfvSize > mEmuVarsFvb.Size) { + DEBUG ((DEBUG_ERROR, "Size of CFV is larger than the EMU Variable FVB.\n")); + ASSERT (FALSE); + } else { + CopyMem (Ptr, CfvBase, CfvSize); + Initialize = FALSE; + } + } + // // Initialize the main FV header and variable store header // diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf index 0811545cf7b3..15e8e673e8a0 100644 --- a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf +++ b/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf @@ -56,6 +56,8 @@ gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gUefiOvmfPkgTokenSpaceGuid.PcdCfvBase + gUefiOvmfPkgTokenSpaceGuid.PcdCfvRawDataSize [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 -- 2.29.2.windows.2 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#90589): https://edk2.groups.io/g/devel/message/90589 Mute This Topic: https://groups.io/mt/91835110/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
