Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OvmfPkg/Library/TdxStartupLib: Add lazy memory accept to the TDVF. #9

Open
wants to merge 5 commits into
base: tdvf_dev
Choose a base branch
from

Conversation

gaojiaqi7
Copy link

Add unaccepted memory type to several structure and macro definition to
indicate the unaccepted memory.

SEC Phase: Modify the Hob process function to partially accept the memory.
Modify the Hob transfer funtion to build different types of system memory
Hobs for DXE phase, system memory is split to type of system memory and
unaccepted memory.

DXE Phase: Add case of unaccepted memory in the GCD memory service process
and memory map.

@gaojiaqi7 gaojiaqi7 force-pushed the tdvf_dev branch 5 times, most recently from f7e0986 to e4da6c9 Compare April 26, 2021 08:22
Add unaccepted memory type to several structures and macro definitions to
indicate the unaccepted memory.

SEC Phase: Modify the Hob process function to partially accept memory.
Modify the Hob transfer function to build different types of system memory
Hobs for DXE phase, system memory is split to type of system memory and
unaccepted memory.

DXE Phase: Add case of unaccepted memory in the GCD memory service process
and memory map.
Kernel/Initrd image size maybe significant so we cannot decide the
memory size to be accepted at build-time.
In SEC, we read the size of kernel/initrd image from QEMU and accept
memory used for them additionally.
@gaojiaqi7 gaojiaqi7 force-pushed the tdvf_dev branch 3 times, most recently from 7c0c52c to 47627d1 Compare August 30, 2021 10:53
Memory usage may exceed the amount accepted at the begining (SEC), TDVF
need to accept memory dynamically when OUT_OF_RESOURCE occurs.

EfiMemoryAcceptProtocol is defined in MdePkg and there's an implementation
in the TdxDxe for Intel TDX memory acceptance.

When DXE memory service need more memory to be accepted, it can call the
interface installed by TdxDxe.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
When CoreAllocatePages()/CoreAllocatePool() meets error of
EFI_OUT_OF_RESOURCES, locate the EfiMemoryAcceptProtocol and accept extra
memory.

Firstly, find the unaccpeted memory region with enough size in GCD
entries. Then locate the EfiMemoryAcceptProtocol and accept the memory.
Finally, update the GCD memory and gMemoryMap entries.

After updating the memory infomation, CoreInternalAllocatePages()/
CoreInternalAllocatePool() will be recalled to allocate pages/pool.

To do (existing issue):
1. CoreAddMemorySpace() should not be called directly in
AcceptMemoryResource() until gMemoryMap is updated because it will try to
allocate another piece of memory for GCD map entry.
2. AcceptMemoryResource() is called in both CoreAllocatePool() and
CoreAllocatePages(). Refine this by changing FindFreePages() and the
CoreConvertPagesEx() to handle *AllocateAddress* case.

Signed-off-by: Jiaqi Gao <jiaqi.gao@intel.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant