On 27.05.25 20:02, Fuad Tabba wrote:
From: Ackerley Tng <ackerleytng@xxxxxxxxxx> This patch adds kvm_gmem_max_mapping_level(), which always returns PG_LEVEL_4K since guest_memfd only supports 4K pages for now. When guest_memfd supports shared memory, max_mapping_level (especially when recovering huge pages - see call to __kvm_mmu_max_mapping_level() from recover_huge_pages_range()) should take input from guest_memfd. Input from guest_memfd should be taken in these cases: + if the memslot supports shared memory (guest_memfd is used for shared memory, or in future both shared and private memory) or + if the memslot is only used for private memory and that gfn is private. If the memslot doesn't use guest_memfd, figure out the max_mapping_level using the host page tables like before. This patch also refactors and inlines the other call to __kvm_mmu_max_mapping_level(). In kvm_mmu_hugepage_adjust(), guest_memfd's input is already provided (if applicable) in fault->max_level. Hence, there is no need to query guest_memfd. lpage_info is queried like before, and then if the fault is not from guest_memfd, adjust fault->req_level based on input from host page tables.
Signed-off-by: Ackerley Tng <ackerleytng@xxxxxxxxxx>
Should there be a Co-developed-by?
Signed-off-by: Fuad Tabba <tabba@xxxxxxxxxx> ---
LGTM, but I am not particularly an expert on that code. Having some feedback from Sean Et. al would be great :)
-- Cheers, David / dhildenb