From nobody Mon Feb 9 01:49:16 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+90589+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90589+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1655519548; cv=none; d=zohomail.com; s=zohoarc; b=G4VT9z9P4CZUBByWZOypERayz8B/OSqL6SzVeZNHvuuomy5zrloC6qDMqpfn6x0m5OWLtjDZi93yStos775xVegl0H+hNUYdt3VG5bcg/m+ChdoREWEClxYuT7FdMJUDis5NidRiHd1KdHOi/7edzsUhapSwrlux2NbVgB4KuX0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655519548; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=mbMdZFwJEGwQ1465GzjX2VQ7reqqgbLxLFJFBPVEsJY=; b=MCKqq6yOviGatW0aFlekOHHOZVg0C8GQNJnmZtHTibZg3TaP9Lf0iViobTHeA5YqqwskiWAMDrPUHVm+kx73OiC4MFPxV907u/6lE9x8HxMJn5bq/MRekO0+ceq8wKcM8+cy+Esxx6oItTQySR44VHdRGhsNcVKRtJEWR5xUOE8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+90589+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 1655519548334847.9592967583201; Fri, 17 Jun 2022 19:32:28 -0700 (PDT) Return-Path: X-Received: by 127.0.0.2 with SMTP id TI5aYY1788612xZg3NASHyq0; Fri, 17 Jun 2022 19:32:28 -0700 X-Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web08.5676.1655519541534598350 for ; Fri, 17 Jun 2022 19:32:27 -0700 X-IronPort-AV: E=McAfee;i="6400,9594,10380"; a="280355770" X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="280355770" X-Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 19:32:26 -0700 X-IronPort-AV: E=Sophos;i="5.92,306,1650956400"; d="scan'208";a="642270321" X-Received: from mxu9-mobl1.ccr.corp.intel.com ([10.249.173.231]) by fmsmga008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 17 Jun 2022 19:32:24 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min M Xu , Erdem Aktas , James Bottomley , Jiewen Yao , Gerd Hoffmann , Tom Lendacky Subject: [edk2-devel] [PATCH 3/3] OvmfPkg: Initialize NvVarStore with Configuration FV in Td guest Date: Sat, 18 Jun 2022 10:32:03 +0800 Message-Id: In-Reply-To: References: MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,min.m.xu@intel.com X-Gm-Message-State: 1sbIuEnH8xe7umACdRPJ8skpx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1655519548; bh=Mo3EqRU4PiptuRAry4nPgmGbhY2HiE1cIPsSwfuRUdc=; h=Cc:Date:From:Reply-To:Subject:To; b=YxDUGUhVoF+uEsnzySZBRUajAcjkD8tnVkQfjAQjX12jzwfZ64Fa+7+HwZG13LvfVdl RxEXn0Xfcsa7iggzsc7hWWSa9rw3h8EPzvVkPXcE51gLALvNbuzT6ohMBAk7EmKcAB4lL uIKfs4rw3/Cv36Xa3gGE8NVtJRzQoCmU0sc= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1655519548684100013 Content-Type: text/plain; charset="utf-8" From: Min M Xu 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 Cc: James Bottomley Cc: Jiewen Yao Cc: Gerd Hoffmann Cc: Tom Lendacky Signed-off-by: Min Xu --- OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c | 19 +++++++++++++++++++ OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf | 2 ++ 2 files changed, 21 insertions(+) diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.c b/OvmfPkg/EmuVariableFv= bRuntimeDxe/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; =20 DEBUG ((DEBUG_INFO, "EMU Variable FVB Started\n")); =20 @@ -774,6 +776,23 @@ FvbInitialize ( =20 mEmuVarsFvb.BufferPtr =3D Ptr; =20 + // + // In Tdx guest the VarNvStore content should be initialized by the Conf= iguration FV (CFV). + // Integrity of the CFV has been validated by TdxValidateCfv (@PlatformI= nitLib) + // + if (TdIsEnabled ()) { + CfvBase =3D (UINT8 *)(UINTN)PcdGet32 (PcdCfvBase); + CfvSize =3D (UINT32)PcdGet32 (PcdCfvRawDataSize); + + if (CfvSize > mEmuVarsFvb.Size) { + DEBUG ((DEBUG_ERROR, "Size of CFV is larger than the EMU Variable FV= B.\n")); + ASSERT (FALSE); + } else { + CopyMem (Ptr, CfvBase, CfvSize); + Initialize =3D FALSE; + } + } + // // Initialize the main FV header and variable store header // diff --git a/OvmfPkg/EmuVariableFvbRuntimeDxe/Fvb.inf b/OvmfPkg/EmuVariable= FvbRuntimeDxe/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 =20 [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 --=20 2.29.2.windows.2 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- 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/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-