On November 3, 2021 2:31 PM, Gerd Hoffmann wrote: > Hi, > > > - AcceptPages: > > To mitigate the performance impact of accepting pages in SEC phase on > > BSP, BSP will parse memory resources and assign each AP the task of > > accepting a subset of pages. This command may be called several times > > until all memory resources are processed. In accepting pages, PageLevel > > may fall back to smaller one if SIZE_MISMATCH error is returned. > > Why add an assembler version of this? There already is a C version (in > TdxLib, > patch #2). When adding lazy accept at some point in the future we will stop > accepting all pages in the SEC phase anyway. There is Mp support (patch #14) > so you can distribute the load to all CPUs in PEI / DXE phase if you want > (although the benefits of parallel accept will be much smaller once lazy > accept is there). There are below considerations about accept pages in SEC phase.
1. There is a minimal memory requirement in DxeCore [1]. In legacy Ovmf the memory is initialized in PEI phase. But TDVF has 2 configurations (Config-A and Config-B) [2]. PEI phase is skipped in Config-B. So we have to accept memories in SEC phase. This is to make the code consistent in Config-A and Config-B. 2. TDVF's MP support is via Mailbox [3] . BSP wakes up APs by putting command/parameters in Mailbox. So we have this patch [4]. While EDK2's MP support (CpuMpPei/CpuDxe) is via INIT-SIPI-SIPI. They're different. We cannot distribute the load to all CPUs with EDK2's MP service. Patch #14 [5] is the commit to enable TDX in MpInitLib. Actually this is to make sure the CpuMpPei/CpuDxe will not break in Td guest in run-time. Patch #14 is rather simple, for example, ApWorker is not supported. 3. In current TDVF implementation, Stack is not set for APs. So C functions cannot be called for APs. If stack is set for APs, then more memories should be reserved in MEMFD. For example, if 1 AP needs 4k size stack, then 15 AP need 60k memory. (We assume only 1+15 CPUs accept memory). This makes things complicated. Based on above considerations, we use the current design that BSP-APs accept memory in SEC phase (in assembly code). [1] https://github.com/tianocore/edk2/blob/master/MdeModulePkg/Core/Dxe/Gcd/Gcd.c#L2245 [2] https://edk2.groups.io/g/devel/message/76367 [3] https://www.intel.com/content/dam/develop/external/us/en/documents/intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf Section 4.1 [4] https://github.com/mxu9/edk2/commit/4501df794c2c4dbfc5ba63c93a1e2c96660c072e [5] https://github.com/mxu9/edk2/commit/189ad46fb732460eaa3e3f0787f098466b1504a6 Thanks Min -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#83784): https://edk2.groups.io/g/devel/message/83784 Mute This Topic: https://groups.io/mt/86739864/21656 Group Owner: devel+ow...@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com] -=-=-=-=-=-=-=-=-=-=-=-