On Thu, Apr 24, 2025 at 11:05:00AM +0800, Yan Zhao wrote: > During the TD build phase (i.e., before the TD becomes RUNNABLE), enforce a > 4KB mapping level both in the S-EPT managed by the TDX module and the > mirror page table managed by KVM. > > During this phase, TD's memory is added via tdh_mem_page_add(), which only > accepts 4KB granularity. Therefore, return PG_LEVEL_4K in TDX's > .private_max_mapping_level hook to ensure KVM maps at the 4KB level in the > mirror page table. Meanwhile, iterate over each 4KB page of a large gmem > backend page in tdx_gmem_post_populate() and invoke tdh_mem_page_add() to > map at the 4KB level in the S-EPT. > > Still allow huge pages in gmem backend during TD build time. Based on [1], > which gmem series allows 2MB TPH and non-in-place conversion, pass in s/TPH/THP/ -- Kiryl Shutsemau / Kirill A. Shutemov