On Tue, Feb 27, 2024 at 06:20:50PM -0500, Paolo Bonzini wrote: > From: Isaku Yamahata <isaku.yamahata@xxxxxxxxx> > > Refactor tdp_mmu_alloc_sp() and tdp_mmu_init_sp and eliminate ^ tdp_mmu_init_sp() > tdp_mmu_init_child_sp(). Currently tdp_mmu_init_sp() (or > tdp_mmu_init_child_sp()) sets kvm_mmu_page.role after tdp_mmu_alloc_sp() > allocating struct kvm_mmu_page and its page table page. This patch makes > tdp_mmu_alloc_sp() initialize kvm_mmu_page.role instead of > tdp_mmu_init_sp(). > > To handle private page tables, argument of is_private needs to be passed > down. Given that already page level is passed down, it would be cumbersome > to add one more parameter about sp. Instead replace the level argument with > union kvm_mmu_page_role. Thus the number of argument won't be increased This section is hard to understand. I'm lost at which functions are mentioned here that took the level argument and should be replaced by role. > and more info about sp can be passed down. My understanding of the change is: Extra handling is need for Allocation of private page tables, so earlier caculate the kvm_mmu_page_role for the sp and pass it to tdp_mmu_alloc_sp(). Since the sp.role could be decided on sp allocation, in turn remove the role argument for tdp_mmu_init_sp(), also eliminate the helper tdp_mmu_init_child_sp(). > > For private sp, secure page table will be also allocated in addition to > struct kvm_mmu_page and page table (spt member). The allocation functions > (tdp_mmu_alloc_sp() and __tdp_mmu_alloc_sp_for_split()) need to know if the > allocation is for the conventional page table or private page table. Pass > union kvm_mmu_role to those functions and initialize role member of struct ^ Should be kvm_mmu_page_role Thanks, Yilun