Branch: refs/heads/master Home: https://github.com/tianocore/edk2 Commit: 3f0c788a5f65ebee41e95feb52b6e77052119aaa https://github.com/tianocore/edk2/commit/3f0c788a5f65ebee41e95feb52b6e77052119aaa Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022)
Changed paths: A MdePkg/Include/IndustryStandard/Tdx.h Log Message: ----------- MdePkg: Add Tdx.h RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Tdx.h includes the Intel Trust Domain Extension definitions. Detailed information can be found in below document: https://software.intel.com/content/dam/develop/external/us/en/ documents/tdx-module-1eas-v0.85.039.pdf Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Jiewen Yao <jiewen....@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 77228269e7c3fac8c949ffed5e59182c4c521e58 https://github.com/tianocore/edk2/commit/77228269e7c3fac8c949ffed5e59182c4c521e58 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Include/Register/Intel/Cpuid.h Log Message: ----------- MdePkg: Update Cpuid.h for Tdx RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Guest software can be designed to run either as a TD, as a legacy virtual machine, or directly on the CPU, based on enumeration of its run-time environment. [TDX-Module] Chap 10.2 defines the flow and the new CPUID leaf 0x21. [TDX-Module] Architecture Specification: Intel(R) Trust Domain Extensions Module, Chap 10.2, 344425-003US, August 2021 https://www.intel.com/content/dam/develop/external/us/en/documents/ tdx-module-1.0-public-spec-v0.931.pdf Cc: Ray Ni <ray...@intel.com> Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 818bc9596d720b43c369e57be4ad1fd8f7e1917b https://github.com/tianocore/edk2/commit/818bc9596d720b43c369e57be4ad1fd8f7e1917b Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Include/Library/BaseLib.h M MdePkg/Library/BaseLib/BaseLib.inf A MdePkg/Library/BaseLib/IntelTdxNull.c A MdePkg/Library/BaseLib/X64/TdCall.nasm A MdePkg/Library/BaseLib/X64/TdProbe.c A MdePkg/Library/BaseLib/X64/TdVmcall.nasm Log Message: ----------- MdePkg: Introduce basic Tdx functions in BaseLib RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Introduce basic Tdx functions in BaseLib: - TdCall () - TdVmCall () - TdIsEnabled () Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: c3001cb744f7b2e5d91a5803814f50e0607d592d https://github.com/tianocore/edk2/commit/c3001cb744f7b2e5d91a5803814f50e0607d592d Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: A MdePkg/Include/Library/TdxLib.h A MdePkg/Library/TdxLib/AcceptPages.c A MdePkg/Library/TdxLib/Rtmr.c A MdePkg/Library/TdxLib/TdInfo.c A MdePkg/Library/TdxLib/TdxLib.inf A MdePkg/Library/TdxLib/TdxLibNull.c M MdePkg/MdePkg.dec M MdePkg/MdePkg.dsc Log Message: ----------- MdePkg: Add TdxLib to wrap Tdx operations RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 TdxLib is created with functions to perform the related Tdx operation. This includes functions for: - TdAcceptPages : Accept pending private pages and initialize the pages to all-0 using the TD ephemeral private key. - TdExtendRtmr : Extend measurement to one of the RTMR registers. - TdSharedPageMask: Get the Td guest shared page mask which indicates it is a Shared or Private page. - TdMaxVCpuNum : Get the maximum number of virtual CPUs. - TdVCpuNum : Get the number of virtual CPUs. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: eddcba40b5ca79bed58b4d686f4cb7ad5e8fa0e0 https://github.com/tianocore/edk2/commit/eddcba40b5ca79bed58b4d686f4cb7ad5e8fa0e0 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/Include/Library/VmgExitLib.h A UefiCpuPkg/Library/VmgExitLibNull/VmTdExitNull.c M UefiCpuPkg/Library/VmgExitLibNull/VmgExitLibNull.inf Log Message: ----------- UefiCpuPkg: Extend VmgExitLibNull to handle #VE exception RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 VmgExitLib performs the necessary processing to handle a #VC exception. VmgExitLibNull is a NULL instance of VmgExitLib which provides a default limited interface. In this commit VmgExitLibNull is extended to handle a #VE exception with a default limited interface. A full feature version of #VE handler will be created later. Cc: Brijesh Singh <brijesh.si...@amd.com> 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: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: daf8f642f38b3701ada62a2bff87680b134d63c3 https://github.com/tianocore/edk2/commit/daf8f642f38b3701ada62a2bff87680b134d63c3 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Library/VmgExitLib/SecVmgExitLib.inf A OvmfPkg/Library/VmgExitLib/VmTdExitHandler.h A OvmfPkg/Library/VmgExitLib/VmTdExitVeHandler.c M OvmfPkg/Library/VmgExitLib/VmgExitLib.inf A OvmfPkg/Library/VmgExitLib/X64/TdVmcallCpuid.nasm Log Message: ----------- OvmfPkg: Extend VmgExitLib to handle #VE exception RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 The base VmgExitLib library provides a default limited interface to handle #VE exception. To provide full support, the OVMF version of VmgExitLib is extended to provide full support of #VE handler. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: de327f7d8a6e2090e1a32cb4907e3264e40f5792 https://github.com/tianocore/edk2/commit/de327f7d8a6e2090e1a32cb4907e3264e40f5792 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/Library/CpuExceptionHandlerLib/PeiDxeSmmCpuException.c M UefiCpuPkg/Library/CpuExceptionHandlerLib/SecPeiCpuException.c Log Message: ----------- UefiCpuPkg/CpuExceptionHandler: Add base support for the #VE exception RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Add base support to handle #VE exceptions. Update the common exception handlers to invoke the VmTdExitHandleVe () function of the VmgExitLib library when a #VE is encountered. A non-zero return code will propagate to the targeted exception handler. Cc: Brijesh Singh <brijesh.si...@amd.com> 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: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: ab9d790901c13b458fab3637efdf53a425bc7502 https://github.com/tianocore/edk2/commit/ab9d790901c13b458fab3637efdf53a425bc7502 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf A MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdx.c A MdePkg/Library/BaseIoLibIntrinsic/IoLibInternalTdxNull.c A MdePkg/Library/BaseIoLibIntrinsic/IoLibTdx.h Log Message: ----------- MdePkg: Add helper functions for Tdx guest in BaseIoLibIntrinsic RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Intel TDX architecture does not prescribe a specific software convention to perform I/O from the guest TD. Guest TD providers have many choices to provide I/O to the guest. The common I/O models are emulated devices, para-virtualized devices, SRIOV devices and Direct Device assignments. TDVF chooses para-virtualized I/O (Choice-A) which use the TDG.VP.VMCALL function to invoke the funtions provided by the host VMM to perform I/O. Another choice (Choice-B) is the emulation performed by the #VE handler. There are 2 benefits of para-virtualized I/O: 1. Performance. VMEXIT/VMENTRY is skipped so that the performance is better than #VE handler. 2. De-couple with #VE handler. Choice-B depends on the #VE handler which means I/O is not available until #VE handler is installed. For example, in PEI phase #VE handler is installed in CpuMpPei, while communication with Qemu (via I/O port) happen earlier than it. IoLibInternalTdx.c provides the helper functions for Tdx guest. IoLibInternalTdxNull.c provides the null version of the helper functions. It is included in the Non-X64 IoLib so that the build will not be broken. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: b6b2de8848648bbba1ab74b0752d6650bc03018a https://github.com/tianocore/edk2/commit/b6b2de8848648bbba1ab74b0752d6650bc03018a Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf M MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf M MdePkg/Library/BaseIoLibIntrinsic/IoLib.c Log Message: ----------- MdePkg: Support mmio for Tdx guest in BaseIoLibIntrinsic RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 TDVF access MMIO with TDG.VP.VMCALL to invoke VMM provided emulation functions. If the access to MMIO fails, it fall backs to the direct access. BaseIoLibIntrinsic.inf is the IoLib used by other packages. It will not support I/O in Td guest. But some files are shared between BaseIoLibIntrinsic and BaseIoLibIntrinsicSev (IoLib.c is the example). So IoLibInternalTdxNull.c (which holds the null stub of the Td I/O routines) is included in BaseIoLibIntrinsic.inf. BaseIoLibIntrinsic.inf doesn't import TdxLib so that the Pkgs which include BaseIoLibIntrinsic.inf need not include TdxLib. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: d74e93268185273b2a91ff8577659bafeac4341c https://github.com/tianocore/edk2/commit/d74e93268185273b2a91ff8577659bafeac4341c Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf A MdePkg/Library/BaseIoLibIntrinsic/IoLibFifo.c A MdePkg/Library/BaseIoLibIntrinsic/IoLibSev.h M MdePkg/Library/BaseIoLibIntrinsic/X64/IoFifoSev.nasm Log Message: ----------- MdePkg: Support IoFifo for Tdx guest in BaseIoLibIntrinsic RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Previously IoFifo functions are in X64/IoFifoSev.nasm which supports both SEV guest and Legacy guest. IoLibFifo.c is introduced to support SEV/TDX/Legacy guest in one binary. It checks the guest type in runtime and call corresponding functions then. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 3571fc906f7462556881f6ee153565b3595cee10 https://github.com/tianocore/edk2/commit/3571fc906f7462556881f6ee153565b3595cee10 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Library/BaseIoLibIntrinsic/IoLibGcc.c M MdePkg/Library/BaseIoLibIntrinsic/IoLibMsc.c Log Message: ----------- MdePkg: Support IoRead/IoWrite for Tdx guest in BaseIoLibIntrinsic RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 This commit supports IoRead/IoWrite for SEV/TDX/Legacy guest in one binary. It checks the guest type in runtime and then call corresponding functions. Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 7bed7ae6c596e304ee85f2351fb89d9ad0621671 https://github.com/tianocore/edk2/commit/7bed7ae6c596e304ee85f2351fb89d9ad0621671 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c Log Message: ----------- UefiCpuPkg: Support TDX in BaseXApicX2ApicLib RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 MSR is accessed in BaseXApicX2ApicLib. In TDX some MSRs are accessed directly from/to CPU. Some should be accessed via explicit requests from the host VMM using TDCALL(TDG.VP.VMCALL). This is done by the help of TdxLib. Please refer to [TDX] Section 18.1 TDX: https://software.intel.com/content/dam/develop/external/us/en/ documents/tdx-module-1.0-public-spec-v0.931.pdf Cc: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: d983b102b35899d8ff37477657c67af819aa6303 https://github.com/tianocore/edk2/commit/d983b102b35899d8ff37477657c67af819aa6303 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdePkg/Include/ConfidentialComputingGuestAttr.h Log Message: ----------- MdePkg: Add macro to check SEV / TDX guest RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Add macros CC_GUEST_IS_SEV / CC_GUEST_IS_TDX to check SEV / TDX guest. Cc: Michael Roth <michael.r...@amd.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Eric Dong <eric.d...@intel.com> Cc: James Bottomley <j...@linux.ibm.com> Cc: Min Xu <min.m...@intel.com> Cc: Jiewen Yao <jiewen....@intel.com> Cc: Tom Lendacky <thomas.lenda...@amd.com> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Erdem Aktas <erdemak...@google.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Michael D Kinney <michael.d.kin...@intel.com> Cc: Liming Gao <gaolim...@byosoft.com.cn> Cc: Zhiguang Liu <zhiguang....@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Liming Gao <gaolim...@byosoft.com.cn> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 88da06ca763eb6514565c1867a801a427c1f3447 https://github.com/tianocore/edk2/commit/88da06ca763eb6514565c1867a801a427c1f3447 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/Library/MpInitLib/DxeMpInitLib.inf A UefiCpuPkg/Library/MpInitLib/MpIntelTdx.h M UefiCpuPkg/Library/MpInitLib/MpLib.c A UefiCpuPkg/Library/MpInitLib/MpLibTdx.c A UefiCpuPkg/Library/MpInitLib/MpLibTdxNull.c M UefiCpuPkg/Library/MpInitLib/PeiMpInitLib.inf Log Message: ----------- UefiCpuPkg: Enable Tdx support in MpInitLib RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 In TDVF BSP and APs are simplified. BSP is the vCPU-0, while the others are treated as APs. So MP intialization is rather simple. ApWorker is not supported, BSP is always the working processor, while the APs are just in a wait-for-precedure state. Cc: Brijesh Singh <brijesh.si...@amd.com> 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: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 352eabdcd52959b0dc24631699783e09321d7d31 https://github.com/tianocore/edk2/commit/352eabdcd52959b0dc24631699783e09321d7d31 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: A OvmfPkg/Include/IndustryStandard/IntelTdx.h Log Message: ----------- OvmfPkg: Add IntelTdx.h in OvmfPkg/Include/IndustryStandard RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 IntelTdx.h defines the defition used by TDX in OvmfPkg: - Mailbox related defitions,such as the data structure, command code, AP relocation defitions. See Table 5.44 Multiprocessor Wakeup Mailbox Structure in below link. https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model/ ACPI_Software_Programming_Model.html#multiprocessor-wakeup-structure Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 6a608255bb431a1b71e49899763ca72108f8ed3f https://github.com/tianocore/edk2/commit/6a608255bb431a1b71e49899763ca72108f8ed3f Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: A OvmfPkg/Include/Library/TdxMailboxLib.h A OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c A OvmfPkg/Library/TdxMailboxLib/TdxMailboxLib.inf A OvmfPkg/Library/TdxMailboxLib/TdxMailboxNull.c M OvmfPkg/OvmfPkg.dec Log Message: ----------- OvmfPkg: Add TdxMailboxLib RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 In Tdx BSP may issues commands to APs for some task, for example, to accept pages paralelly. BSP also need to wait until all the APs have done the task. TdxMailboxLib wraps these common funtions for BSP. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 57bcfc3b06ad6edd7999313280f8d99b47f13ad5 https://github.com/tianocore/edk2/commit/57bcfc3b06ad6edd7999313280f8d99b47f13ad5 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/AmdSev/AmdSevX64.dsc M OvmfPkg/CloudHv/CloudHvX64.dsc A OvmfPkg/Include/Library/PlatformInitLib.h A OvmfPkg/Library/PlatformInitLib/Cmos.c A OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf M OvmfPkg/Microvm/MicrovmX64.dsc M OvmfPkg/OvmfPkg.dec M OvmfPkg/OvmfPkgIa32.dsc M OvmfPkg/OvmfPkgIa32X64.dsc M OvmfPkg/OvmfPkgX64.dsc R OvmfPkg/PlatformPei/Cmos.c R OvmfPkg/PlatformPei/Cmos.h M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/PlatformPei.inf Log Message: ----------- OvmfPkg: Create initial version of PlatformInitLib BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 There are 3 variants of PlatformPei in OvmfPkg: - OvmfPkg/PlatformPei - OvmfPkg/XenPlatformPei - OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf These PlatformPeis can share many common codes, such as Cmos / Hob / Memory / Platform related functions. This commit (and its following several patches) are to create a PlatformInitLib which wraps the common code called in above PlatformPeis. In this initial version of PlatformInitLib, below Cmos related functions are introduced: - PlatformCmosRead8 - PlatformCmosWrite8 - PlatformDebugDumpCmos They correspond to the functions in OvmfPkg/PlatformPei: - CmosRead8 - CmosWrite8 - DebugDumpCmos Considering this PlatformInitLib will be used in SEC phase, global variables and dynamic PCDs are avoided. We use PlatformInfoHob to exchange information between functions. EFI_HOB_PLATFORM_INFO is the data struct which contains the platform information, such as HostBridgeDevId, BootMode, S3Supported, SmmSmramRequire, etc. After PlatformInitLib is created, OvmfPkg/PlatformPei is refactored with this library. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 102cafedade13a718088e370ca42e0b87d10db71 https://github.com/tianocore/edk2/commit/102cafedade13a718088e370ca42e0b87d10db71 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Include/Library/PlatformInitLib.h A OvmfPkg/Library/PlatformInitLib/Platform.c M OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/Platform.h Log Message: ----------- OvmfPkg/PlatformInitLib: Add hob functions BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 In this patch of PlatformInitLib, below hob functions are introduced: - PlatformAddIoMemoryBaseSizeHob - PlatformAddIoMemoryRangeHob - PlatformAddMemoryBaseSizeHob - PlatformAddMemoryRangeHob - PlatformAddReservedMemoryBaseSizeHob They correspond the below functions in OvmfPkg/PlatformPei: - AddIoMemoryBaseSizeHob - AddIoMemoryRangeHob - AddMemoryBaseSizeHob - AddMemoryRangeHob - AddReservedMemoryBaseSizeHob After above hob functions are introduced in PlatformInitLib, OvmfPkg/PlatformPei is refactored with this library. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 9a9b33b3d6f58c306e8352dd8b685b5b147727a3 https://github.com/tianocore/edk2/commit/9a9b33b3d6f58c306e8352dd8b685b5b147727a3 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/AmdSev.c M OvmfPkg/PlatformPei/Fv.c M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/MemTypeInfo.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/Platform.h Log Message: ----------- OvmfPkg/PlatformPei: Move global variables to PlatformInfoHob BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 The intention of PlatformInitLib is to extract the common function used in OvmfPkg/PlatformPei. This lib will be used not only in PEI phase but also in SEC phase. SEC phase cannot use global variables between different functions. So PlatformInfoHob is created to hold the informations shared between functions. For example, HostBridgeDevId corespond to mHostBridgeDevId in PlatformPei. In this patch we will first move below global variables to PlatformInfoHob. - mBootMode - mS3Supported - mPhysMemAddressWidth - mMaxCpuCount - mHostBridgeDevId - mQ35SmramAtDefaultSmbase - mQemuUc32Base - mS3AcpiReservedMemorySize - mS3AcpiReservedMemoryBase PlatformInfoHob also holds other information, for example, PciIoBase / PciIoSize. This is because in SEC phase, PcdSetxxx doesn't work. So we will restruct the functions which set PCDs into two, one for PlatformInfoLib, one for PlatformPei. So in this patch we first move global variables and PCDs to PlatformInfoHob. All the changes are in OvmfPkg/PlatformPei. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 5a2574a82e983dc6b4da39b61fcfbc699b4d8ee5 https://github.com/tianocore/edk2/commit/5a2574a82e983dc6b4da39b61fcfbc699b4d8ee5 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor MiscInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 In MiscInitialization Microvm looks a little weird. Other platforms call PcdSet16S to set the PcdOvmfHostBridgePciDevId with the value same as PlatformInfoHob->HostBridgeDevId. But Microvm doesn't follow this way. In switch-case 0xffff is Microvm, but set with MICROVM_PSEUDO_DEVICE_ID. So we have to add a new function ( MiscInitializationForMicrovm ) for Microvm and delete the code in MiscInitialization. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 6d2ce5fd5ccdee1de7d28439a348692869011a2d https://github.com/tianocore/edk2/commit/6d2ce5fd5ccdee1de7d28439a348692869011a2d Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor MiscInitialization for CloudHV BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 Refactor MiscInitialization for CloudHV to set PCD as other platforms do. Because in the following patch we will split the functions which set PCDs into two, one for PlatformInitLib, one for PlatformPei. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 3dd47f9544633f195c5b047cca2c38c2f079d6b5 https://github.com/tianocore/edk2/commit/3dd47f9544633f195c5b047cca2c38c2f079d6b5 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor AddressWidthInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 From this patch we start to restruct the functions which set PCDs into two, one for PlatformInitLib, one for PlatformPei. AddressWidthInitialization is the first one. It is splitted into two: - PlatformAddressWidthInitialization is for PlatformInitLib - AddressWidthInitialization is for PlatformPei. It calls PlatformAddressWidthInitialization then set PCDs. Below functions are also refined for PlatformInitLib: - PlatformScanOrAdd64BitE820Ram - PlatformGetSystemMemorySizeAbove4gb - PlatformGetFirstNonAddress All the SetPcd codes are removed from above functions. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 432e4acd8751c4ea37dd6eb41924e6634e4dd761 https://github.com/tianocore/edk2/commit/432e4acd8751c4ea37dd6eb41924e6634e4dd761 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor MaxCpuCountInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 MaxCpuCountInitialization is splitted into two: - PlatformMaxCpuCountInitialization is for PlatformInitLib - MaxCpuCountInitialization is for PlatformPei. It calls PlatformMaxCpuCountInitialization then sets PCDs. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: f3801cf26c255828ee405177652ed6e9cc588d88 https://github.com/tianocore/edk2/commit/f3801cf26c255828ee405177652ed6e9cc588d88 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/Platform.h Log Message: ----------- OvmfPkg/PlatformPei: Refactor QemuUc32BaseInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 Rename QemuUc32BaseInitialization to PlatformQemuUc32BaseInitialization. This function is for PlatformInitLib. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: e51032624574bb5c79ce27005415ee2369533f53 https://github.com/tianocore/edk2/commit/e51032624574bb5c79ce27005415ee2369533f53 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/Platform.h Log Message: ----------- OvmfPkg/PlatformPei: Refactor InitializeRamRegions BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 InitializeRamRegions is refactored into 3 calls: - PlatformQemuInitializeRam - SevInitializeRam - PlatformQemuInitializeRamForS3 SevInitializeRam is not in PlatformInitLib. Because in the first stage PlatformInitLib only support the basic platform featues. PlatformQemuInitializeRamForS3 wraps the code which was previously in InitializeRamRegions (many code in 2 if-checks). Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 12e860a1e881b2fa997ebed17cc4918494a5f5fe https://github.com/tianocore/edk2/commit/12e860a1e881b2fa997ebed17cc4918494a5f5fe Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor MemMapInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 MemMapInitialization is split into 2 functions: - PlatformMemMapInitialization is for PlatformInfoLib - MemMapInitialization calls PlatformMemMapInitialization and then sets PCDs. It is for PlatformPei. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: cec82a64cfd40ca0858cdc7bfd57c4115716b639 https://github.com/tianocore/edk2/commit/cec82a64cfd40ca0858cdc7bfd57c4115716b639 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor NoexecDxeInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 NoexecDxeInitialization is split into 2 functions: - PlatformNoexecDxeInitialization is for PlatformInitLib - NoexecDxeInitialization calls PlatformNoexecDxeInitialization and then sets PCD. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: f53f449f15ddae8b2398b9419ba40186e6608ea3 https://github.com/tianocore/edk2/commit/f53f449f15ddae8b2398b9419ba40186e6608ea3 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformPei: Refactor MiscInitialization BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 MiscInitialization is split into 2 functions: - PlatformMiscInitialization is for PlatformInitLib. - MiscInitialization calls PlatformMiscInitialization and then sets PCD. It is for PlatformPei. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 10460942ff2102d9b00c5d754851a3bc1d246972 https://github.com/tianocore/edk2/commit/10460942ff2102d9b00c5d754851a3bc1d246972 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Include/Library/PlatformInitLib.h A OvmfPkg/Library/PlatformInitLib/MemDetect.c M OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.h Log Message: ----------- OvmfPkg/PlatformInitLib: Create MemDetect.c BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 Move functions in PlatformPei\MemDetect.c to PlatformInitLib\MemDetect.c. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 96047b6663ab312229bd4e9498c0185a7c238167 https://github.com/tianocore/edk2/commit/96047b6663ab312229bd4e9498c0185a7c238167 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Include/Library/PlatformInitLib.h M OvmfPkg/Library/PlatformInitLib/Platform.c M OvmfPkg/PlatformPei/Platform.c Log Message: ----------- OvmfPkg/PlatformInitLib: Move functions to Platform.c BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863 Move functions in PlatformPei/Platform.c to PlatformInitLib/Platform.c. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Sebastien Boeuf <sebastien.bo...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: b22ac35b754d1a071e0b40adc47f7c53c3d77893 https://github.com/tianocore/edk2/commit/b22ac35b754d1a071e0b40adc47f7c53c3d77893 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Include/Library/PlatformInitLib.h A OvmfPkg/Library/PlatformInitLib/IntelTdx.c A OvmfPkg/Library/PlatformInitLib/IntelTdxNull.c M OvmfPkg/Library/PlatformInitLib/PlatformInitLib.inf M OvmfPkg/OvmfPkg.dec Log Message: ----------- OvmfPkg: Update PlatformInitLib to process Tdx hoblist RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 When host VMM create the Td guest, the system memory informations are stored in TdHob, which is a memory region described in Tdx metadata. The system memory region in TdHob should be accepted before it can be accessed. So the newly added function (ProcessTdxHobList) is to process the TdHobList to accept the memory. Because TdHobList is provided by host VMM which is not trusted, so its content should be checked before it is consumed by TDVF. Because ProcessTdxHobList is to be called in SEC phase, so PlatformInitLib.inf is updated to support SEC. Note: In this patch it is BSP which accepts the pages. So there maybe boot performance issue. There are some mitigations to this issue, such as lazy accept, 2M accept page size, etc. We will re-visit here in the future. EFI_RESOURCE_MEMORY_UNACCEPTED is a new ResourceType in EFI_HOB_RESOURCE_DESCRIPTOR. It is defined for the unaccepted memory passed from Host VMM. This is proposed in microsoft/mu_basecore#66 files#diff-b20a11152d1ce9249c691be5690b4baf52069efadf2e2546cdd2eb663d80c9 e4R237 according to UEFI-Code-First. The proposal was approved in 2021 in UEFI Mantis, and will be added to the new PI.next specification. Per the MdePkg reviewer's comments, before this new ResourceType is added in the PI spec, it should not be in MdePkg. So it is now defined as an internal implementation and will be moved to MdePkg/Include/Pi/PiHob.h after it is added in PI spec. See https://edk2.groups.io/g/devel/message/87641 PcdTdxAcceptPageSize is added for page accepting. Currently TDX supports 4K and 2M accept page size. The default value is 2M. Tdx guest is only supported in X64. So for IA32 ProcessTdxHobList just returns EFI_UNSUPPORTED. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: ccca1c2d5d1dcd3a1535062368a8572cb6c19dc6 https://github.com/tianocore/edk2/commit/ccca1c2d5d1dcd3a1535062368a8572cb6c19dc6 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Sec/SecMain.c Log Message: ----------- OvmfPkg/Sec: Declare local variable as volatile in SecCoreStartupWithStack RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Declare the local variables in SecCoreStartupWithStack that actually move the data elements as volatile to prevent the optimizer from replacing this function with the intrinsic memcpy(). Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 2b80269d98626271d52445641f936e4543b333a9 https://github.com/tianocore/edk2/commit/2b80269d98626271d52445641f936e4543b333a9 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/AmdSev/AmdSevX64.dsc M OvmfPkg/Bhyve/BhyveX64.dsc M OvmfPkg/CloudHv/CloudHvX64.dsc A OvmfPkg/Include/TdxCommondefs.inc M OvmfPkg/Microvm/MicrovmX64.dsc M OvmfPkg/OvmfPkgIa32X64.dsc M OvmfPkg/OvmfPkgX64.dsc M OvmfPkg/OvmfXen.dsc M OvmfPkg/Sec/SecMain.c M OvmfPkg/Sec/SecMain.inf M OvmfPkg/Sec/X64/SecEntry.nasm Log Message: ----------- OvmfPkg: Update Sec to support Tdx RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 There are below major changes in this commit. 1. SecEntry.nasm In TDX BSP and APs goes to the same entry point in SecEntry.nasm. BSP initialize the temporary stack and then jumps to SecMain, just as legacy Ovmf does. APs spin in a modified mailbox loop using initial mailbox structure. Its structure defition is in OvmfPkg/Include/IndustryStandard/IntelTdx.h. APs wait for command to see if the command is for me. If so execute the command. 2. Sec/SecMain.c When host VMM create the Td guest, the system memory informations are stored in TdHob, which is a memory region described in Tdx metadata. The system memory region in TdHob should be accepted before it can be accessed. So the major task of this patch is to process the TdHobList to accept the memory. After that TDVF follow the standard OVMF flow and jump to PEI phase. PcdUse1GPageTable is set to FALSE by default in OvmfPkgX64.dsc. It gives no chance for Intel TDX to support 1G page table. To support 1G page table this PCD is set to TRUE in OvmfPkgX64.dsc. TDX_GUEST_SUPPORTED is defined in OvmfPkgX64.dsc. This macro wraps the Tdx specific code. TDX only works on X64, so the code is only valid in X64 arch. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 6b27c11690e7c093fa5670e854d10308c847a75d https://github.com/tianocore/edk2/commit/6b27c11690e7c093fa5670e854d10308c847a75d Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgLibInternal.h M OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPei.c M OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgPeiLib.inf Log Message: ----------- OvmfPkg: Check Tdx in QemuFwCfgPei to avoid DMA operation RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 If TDX is enabled then we do not support DMA operation in PEI phase. This is mainly because DMA in TDX guest requires using bounce buffer (which need to allocate dynamic memory and allocating a PAGE size'd buffer can be challenge in PEI phase). Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: bec9104201296e4161862a18f0ce3a3d376e68de https://github.com/tianocore/edk2/commit/bec9104201296e4161862a18f0ce3a3d376e68de Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdeModulePkg/Core/DxeIplPeim/X64/VirtualMemory.c Log Message: ----------- MdeModulePkg: Skip setting IA32_ERER.NXE if it has already been set RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 If IA32_ERER.NXE has already been set, skip setting it again. Cc: Jian J Wang <jian.j.w...@intel.com> Cc: Hao A Wu <hao.a...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jian J Wang <jian.j.w...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: fd306d1dbc36d10f744306e92366d73273c82c8f https://github.com/tianocore/edk2/commit/fd306d1dbc36d10f744306e92366d73273c82c8f Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M MdeModulePkg/MdeModulePkg.dec M OvmfPkg/AmdSev/AmdSevX64.dsc M OvmfPkg/Bhyve/BhyveX64.dsc M OvmfPkg/CloudHv/CloudHvX64.dsc M OvmfPkg/Microvm/MicrovmX64.dsc M OvmfPkg/OvmfPkgIa32.dsc M OvmfPkg/OvmfPkgIa32X64.dsc M OvmfPkg/OvmfPkgX64.dsc M OvmfPkg/OvmfXen.dsc Log Message: ----------- MdeModulePkg: Add PcdTdxSharedBitMask RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Guest Physical Address (GPA) space in Td guest is divided into private and shared sub-spaces, determined by the SHARED bit of GPA. This PCD holds the shared bit mask. Its default value is 0 and it will be set in PlatformPei driver if it is of Td guest. Cc: Jian J Wang <jian.j.w...@intel.com> Cc: Hao A Wu <hao.a...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jian J Wang <jian.j.w...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: cc3620f304acc8dce4af8149348919c4fdc22544 https://github.com/tianocore/edk2/commit/cc3620f304acc8dce4af8149348919c4fdc22544 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/CpuDxe/CpuDxe.inf M UefiCpuPkg/CpuDxe/CpuPageTable.c Log Message: ----------- UefiCpuPkg: Update AddressEncMask in CpuPageTable RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 MMIO region in Tdx guest is set with PcdTdxSharedBitMask in TdxDxe's entry point. In SEV guest the page table entries is set with PcdPteMemoryEncryptionAddressOrMask when creating 1:1 identity table. So the AddressEncMask in GetPageTableEntry (@CpuPageTable.c) is either PcdPteMemoryEncryptionAddressOrMask (in SEV guest), or PcdTdxSharedBitMask (in TDX guest), or all-0 (in Legacy guest). Cc: Brijesh Singh <brijesh.si...@amd.com> 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: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Cc: Rahul Kumar <rahul1.ku...@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: e23f8f52fd1ed86fb092959b9afa4ad1bd13802e https://github.com/tianocore/edk2/commit/e23f8f52fd1ed86fb092959b9afa4ad1bd13802e Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Include/Library/PlatformInitLib.h M OvmfPkg/Library/PlatformInitLib/IntelTdx.c M OvmfPkg/Library/PlatformInitLib/IntelTdxNull.c M OvmfPkg/Library/PlatformInitLib/MemDetect.c M OvmfPkg/Library/PlatformInitLib/Platform.c Log Message: ----------- OvmfPkg: Update PlatformInitLib for Tdx guest RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 There are below changes in PlatformInitLib for Tdx guest: 1. Publish ram regions In Tdx guest, the system memory is passed in TdHob by host VMM. So the major task of PlatformTdxPublishRamRegions is to walk thru the TdHob list and transfer the ResourceDescriptorHob and MemoryAllocationHob to the hobs in DXE phase. 2. Build MemoryAllocationHob for Tdx Mailbox and Ovmf work area. 3. Update of PlatformAddressWidthInitialization. The physical address width that Tdx guest supports is either 48 or 52. 4. Update of PlatformMemMapInitialization. 0xA0000 - 0xFFFFF is VGA bios region. Platform initialization marks the region as MMIO region. Dxe code maps MMIO region as IO region. As TDX guest, MMIO region is maps as shared. However VGA BIOS doesn't need to be shared. Guest TDX Linux maps VGA BIOS as private and accesses for BIOS and stuck on repeating EPT violation. VGA BIOS (more generally ROM region) should be private. Skip marking VGA BIOA region [0xa000, 0xfffff] as MMIO in HOB. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: cf17156d7d3dc89c8798d600b24110052d6c12fe https://github.com/tianocore/edk2/commit/cf17156d7d3dc89c8798d600b24110052d6c12fe Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/OvmfPkg.dec M OvmfPkg/PlatformPei/FeatureControl.c A OvmfPkg/PlatformPei/IntelTdx.c M OvmfPkg/PlatformPei/MemDetect.c M OvmfPkg/PlatformPei/Platform.c M OvmfPkg/PlatformPei/Platform.h M OvmfPkg/PlatformPei/PlatformPei.inf Log Message: ----------- OvmfPkg: Update PlatformPei to support Tdx guest RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 OvmfPkg/PlatformPei is updated to support Tdx guest. There are below major changes. - Set Tdx related PCDs - Publish Tdx RamRegions In this patch there is another new function BuildPlatformInfoHob (). This function builds EFI_HOB_PLATFORM_INFO which contains the HostBridgeDevId. The hob is built in both Td guest and Non-Td guest. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 9fdc70af6ba8982ba9c2a56e7dfc27f456884977 https://github.com/tianocore/edk2/commit/9fdc70af6ba8982ba9c2a56e7dfc27f456884977 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf M OvmfPkg/AcpiPlatformDxe/QemuFwCfgAcpi.c A OvmfPkg/Include/Protocol/QemuAcpiTableNotify.h Log Message: ----------- OvmfPkg: Update AcpiPlatformDxe to alter MADT table RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 In TDX the guest firmware is designed to publish a multiprocessor-wakeup structure to let the guest-bootstrap processor wake up guest-application processors with a mailbox. The mailbox is memory that the guest firmware can reserve so each guest virtual processor can have the guest OS send a message to them. The address of the mailbox is recorded in the MADT table. See [ACPI]. To maintain the simplicity of the AcpiPlatformDxe, the MADT ACPI table will be altered in another driver (TdxDxe) by installing a protocol to notify that the ACPI table provided by Qemu is ready. Then in TdxDxe a notification functioin will be called to alter the MADT table to recorded the mailbox address. The protocol is gQemuAcpiTableNotifyProtocolGuid. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 5aa8018639bb015e906f7fad88c72bfa8e5eb249 https://github.com/tianocore/edk2/commit/5aa8018639bb015e906f7fad88c72bfa8e5eb249 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: A OvmfPkg/Include/Library/MemEncryptTdxLib.h A OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf A OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLibNull.inf A OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemoryEncryptionNull.c A OvmfPkg/Library/BaseMemEncryptTdxLib/MemoryEncryption.c A OvmfPkg/Library/BaseMemEncryptTdxLib/VirtualMemory.h M OvmfPkg/OvmfPkg.dec M OvmfPkg/OvmfPkgIa32.dsc M OvmfPkg/OvmfPkgIa32X64.dsc Log Message: ----------- OvmfPkg/BaseMemEncryptTdxLib: Add TDX helper library RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 Add Intel Tdx helper library. The library provides the routines to: - set or clear Shared bit for a given memory region. - query whether TDX is enabled. Please be noted, there a lot of duplicated codes for Page Table operations. These codes should be moved to a common library (PageTablesLib) so that it is more friendly for review and maintain. There is a new feature requirement https://bugzilla.tianocore.org/show_bug.cgi?id=847 which is to implement the library. After the lib is introduced, BaseMemEncryptTdxLib will be refactored. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: fae5c1464dcd1d9b00c621a16699144566f71533 https://github.com/tianocore/edk2/commit/fae5c1464dcd1d9b00c621a16699144566f71533 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/OvmfPkg.dec M OvmfPkg/OvmfPkgX64.dsc M OvmfPkg/OvmfPkgX64.fdf A OvmfPkg/TdxDxe/TdxAcpiTable.c A OvmfPkg/TdxDxe/TdxAcpiTable.h A OvmfPkg/TdxDxe/TdxDxe.c A OvmfPkg/TdxDxe/TdxDxe.inf A OvmfPkg/TdxDxe/X64/ApRunLoop.nasm Log Message: ----------- OvmfPkg: Add TdxDxe driver RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 TdxDxe driver is dispatched early in DXE, due to being list in APRIORI. This module is responsible for below features: - Sets max logical cpus based on TDINFO - Sets PCI PCDs based on resource hobs - Set shared bit in MMIO region - Relocate Td mailbox and set its address in MADT table. 1. Set shared bit in MMIO region Qemu allows a ROM device to set to ROMD mode (default) or MMIO mode. When it is in ROMD mode, the device is mapped to guest memory and satisfies read access directly. In EDK2 Option ROM is treated as MMIO region. So Tdx guest access Option ROM via TDVMCALL(MMIO). But as explained above, since Qemu set the Option ROM to ROMD mode, the call of TDVMCALL(MMIO) always return INVALID_OPERAND. Tdvf then falls back to direct access. This requires to set the shared bit to corresponding PageTable entry. Otherwise it triggers GP fault. TdxDxe's entry point is the right place to set the shared bit in MMIO region because Option ROM has not been discoverd yet. 2. Relocate Td mailbox and set the new address in MADT Mutiprocessor Wakeup Table. In TDX the guest firmware is designed to publish a multiprocessor-wakeup structure to let the guest-bootstrap processor wake up guest-application processors with a mailbox. The mailbox is memory that the guest firmware can reserve so each guest virtual processor can have the guest OS send a message to them. The address of the mailbox is recorded in the MADT table. See [ACPI]. TdxDxe registers for protocol notification (gQemuAcpiTableNotifyProtocolGuid) to call the AlterAcpiTable(), in which MADT table is altered by the above Mailbox address. The protocol will be installed in AcpiPlatformDxe when the MADT table provided by Qemu is ready. This is to maintain the simplicity of the AcpiPlatformDxe. AlterAcpiTable is the registered function which traverses the ACPI table list to find the original MADT from Qemu. After the new MADT is configured and installed, the original one will be uninstalled. [ACPI] https://uefi.org/specs/ACPI/6.4/05_ACPI_Software_Programming_Model /ACPI_Software_Programming_Model.html#multiprocessor-wakeup-structure Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 07c721fea7d7d7ee6c4e2637c993dff7d46bb5bd https://github.com/tianocore/edk2/commit/07c721fea7d7d7ee6c4e2637c993dff7d46bb5bd Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxe.c M OvmfPkg/Library/QemuFwCfgLib/QemuFwCfgDxeLib.inf Log Message: ----------- OvmfPkg/QemuFwCfgLib: Support Tdx in QemuFwCfgDxe RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 In the previous QemuFwCfgDxe only SEV is supported. This commit introduce TDX support in QemuFwCfgDxe. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 25201821229e84197643053e9de595e512268616 https://github.com/tianocore/edk2/commit/25201821229e84197643053e9de595e512268616 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/AmdSev/AmdSevX64.dsc M OvmfPkg/Bhyve/BhyveX64.dsc M OvmfPkg/CloudHv/CloudHvX64.dsc M OvmfPkg/IoMmuDxe/AmdSevIoMmu.c M OvmfPkg/IoMmuDxe/AmdSevIoMmu.h M OvmfPkg/IoMmuDxe/IoMmuDxe.c M OvmfPkg/IoMmuDxe/IoMmuDxe.inf M OvmfPkg/Microvm/MicrovmX64.dsc M OvmfPkg/OvmfPkgX64.dsc M OvmfPkg/OvmfXen.dsc Log Message: ----------- OvmfPkg: Update IoMmuDxe to support TDX RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3429 The IOMMU protocol driver provides capabilities to set a DMA access attribute and methods to allocate, free, map and unmap the DMA memory for the PCI Bus devices. The current IoMmuDxe driver supports DMA operations inside SEV guest. To support DMA operation in TDX guest, CC_GUEST_IS_XXX (PcdConfidentialComputingGuestAttr) is used to determine if it is SEV guest or TDX guest. Due to security reasons all DMA operations inside the SEV/TDX guest must be performed on shared pages. The IOMMU protocol driver for the SEV/TDX guest uses a bounce buffer to map guest DMA buffer to shared pages in order to provide the support for DMA operations inside SEV/TDX guest. The call of SEV or TDX specific function to set/clear EncMask/SharedBit is determined by CC_GUEST_IS_XXX (PcdConfidentialComputingGuestAttr). Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: c2e7be4055cbfa604042dc0edac186a5f234163b https://github.com/tianocore/edk2/commit/c2e7be4055cbfa604042dc0edac186a5f234163b Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/CloudHv/CloudHvX64.dsc M OvmfPkg/CloudHv/CloudHvX64.fdf A OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c A OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.h A OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf M OvmfPkg/Microvm/MicrovmX64.dsc M OvmfPkg/Microvm/MicrovmX64.fdf M OvmfPkg/OvmfXen.dsc M OvmfPkg/OvmfXen.fdf R OvmfPkg/XenTimerDxe/XenTimerDxe.c R OvmfPkg/XenTimerDxe/XenTimerDxe.h R OvmfPkg/XenTimerDxe/XenTimerDxe.inf Log Message: ----------- OvmfPkg: Rename XenTimerDxe to LocalApicTimerDxe BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3711 XenTimerDxe is a local Apic timer driver and it has nothing to do with Xen. So rename it to LocalApicTimerDxe. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Cc: Anthony Perard <anthony.per...@citrix.com> Cc: Julien Grall <jul...@xen.org> Acked-by: Anthony PERARD <anthony.per...@citrix.com Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: 299c44cd4f53fe7493e7dad283f60e184f90b0b9 https://github.com/tianocore/edk2/commit/299c44cd4f53fe7493e7dad283f60e184f90b0b9 Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M UefiCpuPkg/Library/BaseXApicX2ApicLib/BaseXApicX2ApicLib.c Log Message: ----------- UefiCpuPkg: Setting initial-count register as the last step BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3711 Per SDM, changing the mode of APIC timer (from one-shot to periodic or vice versa) by writing to the timer LVT entry does not start the timer. To start the timer, it is necessary to write to the initial-count register. If initial-count is wrote before mode change, it's possible that timer expired before the mode change. Thus failing the periodic mode. Cc: Jiewen Yao <jiewen....@intel.com> Cc: Gerd Hoffmann <kra...@redhat.com> Cc: Anthony Perard <anthony.per...@citrix.com> Cc: Julien Grall <jul...@xen.org> Cc: Eric Dong <eric.d...@intel.com> Cc: Ray Ni <ray...@intel.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Ray Ni <ray...@intel.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Commit: c37cbc030d96631b3c795a1b4fdae7daece2499c https://github.com/tianocore/edk2/commit/c37cbc030d96631b3c795a1b4fdae7daece2499c Author: Min Xu <min.m...@intel.com> Date: 2022-04-02 (Sat, 02 Apr 2022) Changed paths: M OvmfPkg/AmdSev/AmdSevX64.dsc M OvmfPkg/AmdSev/AmdSevX64.fdf M OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.c M OvmfPkg/LocalApicTimerDxe/LocalApicTimerDxe.inf M OvmfPkg/OvmfPkgIa32.dsc M OvmfPkg/OvmfPkgIa32.fdf M OvmfPkg/OvmfPkgIa32X64.dsc M OvmfPkg/OvmfPkgIa32X64.fdf M OvmfPkg/OvmfPkgX64.dsc M OvmfPkg/OvmfPkgX64.fdf Log Message: ----------- OvmfPkg: Switch timer in build time for OvmfPkg BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3711 Discussion in https://bugzilla.tianocore.org/show_bug.cgi?id=1496 shows that 8254TimerDxe was not written for OVMF. It was moved over from PcAtChipsetPkg to OvmfPkg in 2019. Probably because OVMF was the only user left. Most likely the reason OVMF used 8254TimerDxe initially was that it could just use the existing driver in PcAtChipsetPkg. And it simply hasn't been changed ever. CSM support was moved in 2019 too. (CSM support depends on 8254/8259 drivers). So 8254TimerDxe will be used when CSM_ENABLE=TRUE. There are 4 .dsc which include the 8254Timer. - OvmfPkg/AmdSev/AmdSevX64.dsc - OvmfPkg/OvmfPkgIa32.dsc - OvmfPkg/OvmfPkgIa32X64.dsc - OvmfPkg/OvmfPkgX64.dsc For the three OvmfPkg* configs using 8254TimerDxe with CSM_ENABLE=TRUE and LapicTimerDxe otherwise. For the AmdSev config it doesn't make sense to support a CSM. So use the lapic timer unconditionally. Cc: Ard Biesheuvel <ardb+tianoc...@kernel.org> Cc: Jordan Justen <jordan.l.jus...@intel.com> Cc: Brijesh Singh <brijesh.si...@amd.com> 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> Suggested-by: Gerd Hoffmann <kra...@redhat.com> Acked-by: Gerd Hoffmann <kra...@redhat.com> Reviewed-by: Jiewen Yao <jiewen....@intel.com> Signed-off-by: Min Xu <min.m...@intel.com> Compare: https://github.com/tianocore/edk2/compare/b328bb54c6e5...c37cbc030d96 _______________________________________________ edk2-commits mailing list edk2-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/edk2-commits