public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH 00/14] Introduce Lazy-accept for Tdx guest
@ 2022-06-06  2:59 Min Xu
  2022-06-06  2:59 ` [PATCH 01/14] MdeModulePkg: Add PrePiHob.h Min Xu
                   ` (14 more replies)
  0 siblings, 15 replies; 45+ messages in thread
From: Min Xu @ 2022-06-06  2:59 UTC (permalink / raw)
  To: devel
  Cc: Min Xu, Zhichao Gao, Michael D Kinney, Zhiguang Liu, Jian J Wang,
	Liming Gao, Ray Ni, Erdem Aktas, Gerd Hoffmann, James Bottomley,
	Jiewen Yao, Tom Lendacky, Jiaqi Gao

RFC: https://bugzilla.tianocore.org/show_bug.cgi?id=3937

UnacceptedMemory is one of the four defined types of TD memory in Intel
TDX guest. TDVF must invoke TDCALL [TDG.MEM.PAGE.ACCEPT] the unaccepted
memory before use it. See [TDVF] Section 7.1.
TDVF: https://www.intel.com/content/dam/develop/external/us/en/
documents/tdx-virtual-firmware-design-guide-rev-1.01.pdf 

It is a time-consuming task which impacts the boot performance badly.
One of the mitigation is the lazy-accept mechanism. That the whole system
memory is divided into 2 parts, one is accepted in bios phase, the other
is tagged as EfiGcdMemoryTypeUnaccepted and OS will handle these
"unaccepted" memories.
See "UEFI Spec v2.9 Table 7-5 Memory Type Usage before ExitBootServices()"

Patch 1-4: 
  Introduce lazy-accept related definitions.

Patch 5-6:
  Update Dxe and shell for unaccepted memory.

Patch 7 - 11:
  Update OvmfPkg for unaccepted memory.

Patch 12 - 13:
  Introduce EfiMemoryAcceptProtocol and realize it in TdxDxe.

Patch 14:
  Update Pool and Page functions to accept memory when OOM occurs.

Code: https://github.com/mxu9/edk2/tree/lazyaccept.v1

Cc: Zhichao Gao <zhichao.gao@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>

Jiaqi Gao (2):
  MdePkg: The prototype definition of EfiMemoryAcceptProtocol
  MdeModulePkg: Pool and page functions accept memory when OOM occurs

Min M Xu (12):
  MdeModulePkg: Add PrePiHob.h
  MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE
  OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in
    MdeModulePkg
  MdePkg: Add UEFI Unaccepted memory definition
  MdeModulePkg: Update Dxe to handle unaccepted memory type
  ShellPkg: Update shell command memmap to show unaccepted memory
  OvmfPkg: Add PCD and DEFINEs for Lazy Accept page.
  OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase
  OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area
  OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei
  OvmfPkg: Update ConstructFwHobList for lazy accept
  OvmfPkg: Realize EfiMemoryAcceptProtocol in TdxDxe

 MdeModulePkg/Core/Dxe/DxeMain.inf             |   1 +
 MdeModulePkg/Core/Dxe/Gcd/Gcd.c               |   5 +
 MdeModulePkg/Core/Dxe/Mem/Imem.h              |  16 ++
 MdeModulePkg/Core/Dxe/Mem/Page.c              | 218 ++++++++++++++++++
 MdeModulePkg/Core/Dxe/Mem/Pool.c              |  14 ++
 MdeModulePkg/Include/Pi/PrePiHob.h            |  20 ++
 MdePkg/Include/Pi/PiDxeCis.h                  |   5 +
 MdePkg/Include/Pi/PiHob.h                     |  11 +-
 MdePkg/Include/Protocol/MemoryAccept.h        |  37 +++
 MdePkg/Include/Uefi/UefiMultiPhase.h          |   5 +
 MdePkg/MdePkg.dec                             |   3 +
 OvmfPkg/Include/Library/PlatformInitLib.h     |   6 +
 OvmfPkg/Include/WorkArea.h                    |   1 +
 OvmfPkg/IntelTdx/IntelTdxX64.dsc              |   8 +
 .../PrePiHobListPointer.c                     |   4 +-
 .../PrePiHobListPointerLibTdx.inf             |   2 +-
 OvmfPkg/Library/PeilessStartupLib/Hob.c       |  26 ++-
 .../PeilessStartupLib/PeilessStartupLib.inf   |   1 +
 OvmfPkg/Library/PlatformInitLib/IntelTdx.c    | 145 +++++++++++-
 OvmfPkg/Library/PlatformInitLib/MemDetect.c   |  27 +++
 .../PlatformInitLib/PlatformInitLib.inf       |   1 +
 OvmfPkg/OvmfPkg.dec                           |   4 +
 OvmfPkg/OvmfPkgX64.dsc                        |   9 +
 OvmfPkg/PlatformPei/MemDetect.c               |   5 +
 OvmfPkg/TdxDxe/TdxDxe.c                       | 103 +++++++++
 OvmfPkg/TdxDxe/TdxDxe.inf                     |   2 +
 .../UefiShellDebug1CommandsLib/MemMap.c       |   6 +
 27 files changed, 666 insertions(+), 19 deletions(-)
 create mode 100644 MdeModulePkg/Include/Pi/PrePiHob.h
 create mode 100644 MdePkg/Include/Protocol/MemoryAccept.h

-- 
2.29.2.windows.2


^ permalink raw reply	[flat|nested] 45+ messages in thread

end of thread, other threads:[~2022-09-22 20:29 UTC | newest]

Thread overview: 45+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-06-06  2:59 [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-06-06  2:59 ` [PATCH 01/14] MdeModulePkg: Add PrePiHob.h Min Xu
2022-06-06  2:59 ` [PATCH 02/14] MdePkg: Increase EFI_RESOURCE_MAX_MEMORY_TYPE Min Xu
2022-06-06  3:23   ` Yao, Jiewen
2022-06-07 10:39   ` Gerd Hoffmann
2022-06-08  0:02     ` [edk2-devel] " Min Xu
2022-06-06  2:59 ` [PATCH 03/14] OvmfPkg: Use EFI_RESOURCE_MEMORY_UNACCEPTED which defined in MdeModulePkg Min Xu
2022-06-06  2:59 ` [PATCH 04/14] MdePkg: Add UEFI Unaccepted memory definition Min Xu
2022-06-06  3:23   ` Yao, Jiewen
     [not found]     ` <004301d87ec6$72e53d00$58afb700$@byosoft.com.cn>
2022-06-15  5:39       ` Min Xu
2022-06-06  2:59 ` [PATCH 05/14] MdeModulePkg: Update Dxe to handle unaccepted memory type Min Xu
     [not found]   ` <005601d87ec8$7f6f7700$7e4e6500$@byosoft.com.cn>
2022-06-15  6:18     ` [edk2-devel] " Min Xu
2022-06-06  2:59 ` [PATCH 06/14] ShellPkg: Update shell command memmap to show unaccepted memory Min Xu
2022-06-06  3:01   ` Ni, Ray
2022-06-06  3:19     ` Min Xu
2022-06-06  2:59 ` [PATCH 07/14] OvmfPkg: Add PCD and DEFINEs for Lazy Accept page Min Xu
2022-06-07 10:45   ` Gerd Hoffmann
2022-06-08  0:06     ` Min Xu
2022-06-08  6:18       ` Gerd Hoffmann
2022-06-15  3:07         ` Min Xu
2022-06-15  8:05           ` Gerd Hoffmann
2022-06-15 20:51             ` Dionna Glaze
2022-06-16  0:05               ` [edk2-devel] " Min Xu
2022-06-16  5:51                 ` Gerd Hoffmann
2022-06-16  7:33                   ` Min Xu
2022-06-16 13:09                   ` Lendacky, Thomas
2022-06-16 16:44                 ` Dionna Glaze
2022-06-16 18:33                   ` Lendacky, Thomas
2022-06-16 23:47                     ` Dionna Glaze
2022-06-14 16:10   ` Dionna Glaze
2022-06-15  3:08     ` Min Xu
2022-06-06  2:59 ` [PATCH 08/14] OvmfPkg: Use PcdOvmfWorkAreaBase instead of PcdSevEsWorkAreaBase Min Xu
2022-06-07 10:48   ` Gerd Hoffmann
2022-06-08  0:08     ` Min Xu
2022-06-06  2:59 ` [PATCH 09/14] OvmfPkg: Add MaxAcceptedMemoryAddress in TDX work area Min Xu
2022-06-06  2:59 ` [PATCH 10/14] OvmfPkg: Introduce lazy accept in PlatformInitLib and PlatformPei Min Xu
2022-06-06  2:59 ` [PATCH 11/14] OvmfPkg: Update ConstructFwHobList for lazy accept Min Xu
2022-06-06  3:00 ` [PATCH 12/14] MdePkg: The prototype definition of EfiMemoryAcceptProtocol Min Xu
2022-06-06  3:22   ` Yao, Jiewen
2022-06-08  0:49     ` Min Xu
2022-06-06  3:00 ` [PATCH 13/14] OvmfPkg: Realize EfiMemoryAcceptProtocol in TdxDxe Min Xu
2022-06-06  3:00 ` [PATCH 14/14] MdeModulePkg: Pool and page functions accept memory when OOM occurs Min Xu
2022-08-11  3:17 ` [PATCH 00/14] Introduce Lazy-accept for Tdx guest Min Xu
2022-08-16  6:47   ` Gerd Hoffmann
2022-09-22 20:29     ` Dionna Glaze

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox