[edk2-devel] [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF

Min Xu posted 6 patches 1 year, 3 months ago
Failed in applying to current master (apply log)
OvmfPkg/AmdSev/AmdSevX64.dsc                  |   1 +
OvmfPkg/CloudHv/CloudHvX64.dsc                |   1 +
OvmfPkg/Include/TdxCommondefs.inc             |   4 +-
OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm     | 119 +++++
OvmfPkg/IntelTdx/Sec/X64/SecEntry.nasm        |  58 +--
OvmfPkg/Library/PlatformInitLib/IntelTdx.c    | 411 +++++++++++++++---
.../PlatformInitLib/PlatformInitLib.inf       |   1 +
OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c    |  22 +-
.../Library/TdxMailboxLib/TdxMailboxLib.inf   |   7 +-
.../TdxMailboxLib/TdxMailboxLibNull.inf       |  34 ++
OvmfPkg/Microvm/MicrovmX64.dsc                |   1 +
OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
OvmfPkg/OvmfPkgIa32X64.dsc                    |   2 +-
OvmfPkg/Sec/X64/SecEntry.nasm                 |  58 +--
14 files changed, 545 insertions(+), 175 deletions(-)
create mode 100644 OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm
create mode 100644 OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
[edk2-devel] [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF
Posted by Min Xu 1 year, 3 months ago
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4172

TDVF once accepts memory only by BSP. To improve the boot performance
this patch-set introduce the multi-core accpet memory. Multi-core means
BSP and APs work together to accept memory.

TDVF leverages mailbox to wake up APs. It is not enabled in MpInitLib
(Which requires SIPI). So multi-core accept memory cannot leverages
MpInitLib to coordinate BSP and APs to work together.

So TDVF split the accept memory into 2 phases.
- AcceptMemoryForAPsStack:
  BSP accepts a small piece of memory which is then used by APs to setup
  stack. We assign a 16KB stack for each AP. So a td-guest with 256 vCPU
  requires 255*16KB = 4080KB.
- AcceptMemory:
  After above small piece of memory is accepted, BSP commands APs to
  accept memory by sending AcceptPages command in td-mailbox. Together
  with the command and accpet-function, the APsStack address is send
  as well. APs then set the stack and jump to accept-function to accept
  memory.

Patch 1-3:
  TdxMailboxLib is refactored to help multi-core lazy accept.
Patch 4-5:
  Refactor APs' logical to support accpet page.
Patch 6:
  Implement multi-core accept in TDVF.

Code: https://github.com/mxu9/edk2/tree/Multi-Core-Lazy-Accept.v2

v2 changes:
 - Fix an override error when vCPU number is larger than 64.

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: Min Xu <min.m.xu@intel.com>

Min M Xu (6):
  OvmfPkg/TdxMailboxLib: Delete global variables
  OvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib
  OvmfPkg: Add TdxMailboxLibNull in some platform dsc
  OvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm
  OvmfPkg: Enable APs to accept memory for TDVF
  OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF

 OvmfPkg/AmdSev/AmdSevX64.dsc                  |   1 +
 OvmfPkg/CloudHv/CloudHvX64.dsc                |   1 +
 OvmfPkg/Include/TdxCommondefs.inc             |   4 +-
 OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm     | 119 +++++
 OvmfPkg/IntelTdx/Sec/X64/SecEntry.nasm        |  58 +--
 OvmfPkg/Library/PlatformInitLib/IntelTdx.c    | 411 +++++++++++++++---
 .../PlatformInitLib/PlatformInitLib.inf       |   1 +
 OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c    |  22 +-
 .../Library/TdxMailboxLib/TdxMailboxLib.inf   |   7 +-
 .../TdxMailboxLib/TdxMailboxLibNull.inf       |  34 ++
 OvmfPkg/Microvm/MicrovmX64.dsc                |   1 +
 OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
 OvmfPkg/OvmfPkgIa32X64.dsc                    |   2 +-
 OvmfPkg/Sec/X64/SecEntry.nasm                 |  58 +--
 14 files changed, 545 insertions(+), 175 deletions(-)
 create mode 100644 OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm
 create mode 100644 OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf

-- 
2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97618): https://edk2.groups.io/g/devel/message/97618
Mute This Topic: https://groups.io/mt/95782426/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [edk2-devel] [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF
Posted by Yao, Jiewen 1 year, 3 months ago
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>

Merged https://github.com/tianocore/edk2/pull/3813

> -----Original Message-----
> From: Xu, Min M <min.m.xu@intel.com>
> Sent: Tuesday, December 20, 2022 4:43 PM
> To: devel@edk2.groups.io
> Cc: Xu, Min M <min.m.xu@intel.com>; Aktas, Erdem
> <erdemaktas@google.com>; Gerd Hoffmann <kraxel@redhat.com>; James
> Bottomley <jejb@linux.ibm.com>; Yao, Jiewen <jiewen.yao@intel.com>; Tom
> Lendacky <thomas.lendacky@amd.com>
> Subject: [PATCH V2 0/6] Enable Multi-core based lazy-accept for TDVF
> 
> BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4172
> 
> TDVF once accepts memory only by BSP. To improve the boot performance
> this patch-set introduce the multi-core accpet memory. Multi-core means
> BSP and APs work together to accept memory.
> 
> TDVF leverages mailbox to wake up APs. It is not enabled in MpInitLib
> (Which requires SIPI). So multi-core accept memory cannot leverages
> MpInitLib to coordinate BSP and APs to work together.
> 
> So TDVF split the accept memory into 2 phases.
> - AcceptMemoryForAPsStack:
>   BSP accepts a small piece of memory which is then used by APs to setup
>   stack. We assign a 16KB stack for each AP. So a td-guest with 256 vCPU
>   requires 255*16KB = 4080KB.
> - AcceptMemory:
>   After above small piece of memory is accepted, BSP commands APs to
>   accept memory by sending AcceptPages command in td-mailbox. Together
>   with the command and accpet-function, the APsStack address is send
>   as well. APs then set the stack and jump to accept-function to accept
>   memory.
> 
> Patch 1-3:
>   TdxMailboxLib is refactored to help multi-core lazy accept.
> Patch 4-5:
>   Refactor APs' logical to support accpet page.
> Patch 6:
>   Implement multi-core accept in TDVF.
> 
> Code: https://github.com/mxu9/edk2/tree/Multi-Core-Lazy-Accept.v2
> 
> v2 changes:
>  - Fix an override error when vCPU number is larger than 64.
> 
> 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: Min Xu <min.m.xu@intel.com>
> 
> Min M Xu (6):
>   OvmfPkg/TdxMailboxLib: Delete global variables
>   OvmfPkg/TdxMailboxLib: Add NULL instance of TdxMailboxLib
>   OvmfPkg: Add TdxMailboxLibNull in some platform dsc
>   OvmfPkg/Sec: Move TDX APs related nasm code to IntelTdxAPs.nasm
>   OvmfPkg: Enable APs to accept memory for TDVF
>   OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF
> 
>  OvmfPkg/AmdSev/AmdSevX64.dsc                  |   1 +
>  OvmfPkg/CloudHv/CloudHvX64.dsc                |   1 +
>  OvmfPkg/Include/TdxCommondefs.inc             |   4 +-
>  OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm     | 119 +++++
>  OvmfPkg/IntelTdx/Sec/X64/SecEntry.nasm        |  58 +--
>  OvmfPkg/Library/PlatformInitLib/IntelTdx.c    | 411 +++++++++++++++---
>  .../PlatformInitLib/PlatformInitLib.inf       |   1 +
>  OvmfPkg/Library/TdxMailboxLib/TdxMailbox.c    |  22 +-
>  .../Library/TdxMailboxLib/TdxMailboxLib.inf   |   7 +-
>  .../TdxMailboxLib/TdxMailboxLibNull.inf       |  34 ++
>  OvmfPkg/Microvm/MicrovmX64.dsc                |   1 +
>  OvmfPkg/OvmfPkgIa32.dsc                       |   1 +
>  OvmfPkg/OvmfPkgIa32X64.dsc                    |   2 +-
>  OvmfPkg/Sec/X64/SecEntry.nasm                 |  58 +--
>  14 files changed, 545 insertions(+), 175 deletions(-)
>  create mode 100644 OvmfPkg/IntelTdx/Sec/X64/IntelTdxAPs.nasm
>  create mode 100644 OvmfPkg/Library/TdxMailboxLib/TdxMailboxLibNull.inf
> 
> --
> 2.29.2.windows.2



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#97680): https://edk2.groups.io/g/devel/message/97680
Mute This Topic: https://groups.io/mt/95782426/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-