451521c OvmfPkg/PlatformInitLib: Implement multi-core accept memory for TDVF

2 files Authored by Min M Xu a year ago, Committed by mergify[bot] a year ago,
    OvmfPkg/PlatformInitLib: Implement multi-core accept memory 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 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.
    
    AcceptMemoryForAPsStack accepts as small memory as possible and then jump
    to AcceptMemory. It fully takes advantage of BSP/APs to work together.
    After accept memory is done, the memory region for APsStack is not used
    anymore. It can be used as other private memory. Because accept-memory
    is in the very beginning of boot process and it will not impact other
    phases.
    
    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>
    Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>