From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by mx.groups.io with SMTP id smtpd.web08.4238.1626933188101722294 for ; Wed, 21 Jul 2021 22:53:09 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.100, mailfrom: min.m.xu@intel.com) X-IronPort-AV: E=McAfee;i="6200,9189,10052"; a="275391620" X-IronPort-AV: E=Sophos;i="5.84,260,1620716400"; d="scan'208";a="275391620" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 22:53:05 -0700 X-IronPort-AV: E=Sophos;i="5.84,260,1620716400"; d="scan'208";a="512374753" Received: from mxu9-mobl1.ccr.corp.intel.com ([10.238.4.4]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 21 Jul 2021 22:53:02 -0700 From: "Min Xu" To: devel@edk2.groups.io Cc: Min Xu , Ard Biesheuvel , Jordan Justen , Brijesh Singh , Erdem Aktas , James Bottomley , Jiewen Yao , Tom Lendacky , Eric Dong , Ray Ni , Debkumar De Subject: [PATCH V2 0/4] Add Intel TDX support in OvmfPkg/ResetVector Date: Thu, 22 Jul 2021 13:52:12 +0800 Message-Id: X-Mailer: git-send-email 2.29.2.windows.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Intel's Trust Domain Extensions (Intel TDX) refers to an Intel technology that extends Virtual Machines Extensions (VMX) and Multi-Key Total Memory Encryption (MKTME) with a new kind of virutal machines guest called a Trust Domain (TD). A TD is desinged to run in a CPU mode that protects the confidentiality of TD memory contents and the TD's CPU state from other software, including the hosting Virtual-Machine Monitor (VMM), unless explicitly shared by the TD itself. The patch-sets to support Intel TDX in OvmfPkg is split into several waves. This is wave1 which adds Intel TDX support in OvmfPkg/ResetVector. Note: TDX only works in X64. Patch 1 add the PCDs of BFV/CFV. BFV is the code part of the image. CFV is the configuration part. BFV is measured by VMM and CFV is measured by TDVF itself. Patch 2 add TdxMetadata in OvmfPkg/ResetVector. It describes the information about the image so that VMM can do the initialization and measurement based on these information. Patch 3 updates the UefiCpuPkg/Vtf0/Main.asm to add Main32 entrypoint. It is because on reset all the CPUs are in 32-bit protected mode. In the Main32 entry point, Init32 is called to do the 32-bit initializaiton. In UefiCpuPkg/ResetVector/Vtf0/Ia32, Init32.asm is added. It is a null stub of the 32-bit initialization. The actual work is implemented in OvmfPkg. In Patch 4, InitTdx.asm does the tdx initialization, ReloadFlat32 loads the GDT and sets the CR0, then jump to 32-bit protected mode. Init32.asm put above 2 together to complete the 32-bit initializaiton. After that page tables are built and set, then jump to SecEntry. [TDX]: https://software.intel.com/content/dam/develop/external/us/en/ documents/tdx-whitepaper-final9-17.pdf [TDVF]: https://software.intel.com/content/dam/develop/external/us/en/ documents/tdx-virtual-firmware-design-guide-rev-1.pdf Code is at https://github.com/mxu9/edk2/tree/tdvf_wave1.v2 v2 changes: - Move InitTdx.asm and ReloadFlat32.asm from UefiCpuPkg/ResetVector/Vtf0 to OvmfPkg/ResetVector. Init32.asm is created which is a null stub of 32-bit initialization. In Main32 just simply call Init32. It makes the Main.asm in UefiCpuPkg/ResetVector clean and clear. - Init32.asm/InitTdx.asm/ReloadFlat32.asm are created under OvmfPkg/ResetVector/Ia32. - Update some descriptions of the patch-sets. - Update the REF link in cover letter. - Add Ard Biesheuvel in Cc list. v1: https://edk2.groups.io/g/devel/message/77675 Cc: Ard Biesheuvel Cc: Jordan Justen Cc: Brijesh Singh Cc: Erdem Aktas Cc: James Bottomley Cc: Jiewen Yao Cc: Tom Lendacky Cc: Eric Dong Cc: Ray Ni CC: Debkumar De Signed-off-by: Min Xu Min Xu (4): OvmfPkg: Add Tdx BFV/CFV PCDs and PcdOvmfImageSizeInKb OvmfPkg: Add Tdx metadata UefiCpuPkg/ResetVector: Add Main32 entry point in Main.asm OvmfPkg/ResetVector: Update ResetVector to support Tdx OvmfPkg/OvmfPkg.dec | 13 +++ OvmfPkg/OvmfPkgDefines.fdf.inc | 12 ++- OvmfPkg/ResetVector/Ia16/ResetVectorVtf0.asm | 38 ++++++++ OvmfPkg/ResetVector/Ia32/Flat32ToFlat64.asm | 47 ++++++++++ OvmfPkg/ResetVector/Ia32/Init32.asm | 34 +++++++ OvmfPkg/ResetVector/Ia32/InitTdx.asm | 57 ++++++++++++ OvmfPkg/ResetVector/Ia32/PageTables64.asm | 41 +++++++++ OvmfPkg/ResetVector/Ia32/ReloadFlat32.asm | 44 +++++++++ OvmfPkg/ResetVector/ResetVector.inf | 11 ++- OvmfPkg/ResetVector/ResetVector.nasmb | 65 ++++++++++++- OvmfPkg/ResetVector/X64/TdxMetadata.asm | 97 ++++++++++++++++++++ UefiCpuPkg/ResetVector/Vtf0/Ia32/Init32.asm | 13 +++ UefiCpuPkg/ResetVector/Vtf0/Main.asm | 14 +++ UefiCpuPkg/ResetVector/Vtf0/Vtf0.nasmb | 2 +- 14 files changed, 483 insertions(+), 5 deletions(-) create mode 100644 OvmfPkg/ResetVector/Ia32/Init32.asm create mode 100644 OvmfPkg/ResetVector/Ia32/InitTdx.asm create mode 100644 OvmfPkg/ResetVector/Ia32/ReloadFlat32.asm create mode 100644 OvmfPkg/ResetVector/X64/TdxMetadata.asm create mode 100644 UefiCpuPkg/ResetVector/Vtf0/Ia32/Init32.asm -- 2.29.2.windows.2