On Fri, Jun 7, 2024 at 10:27 PM Edgecombe, Rick P <rick.p.edgecombe@xxxxxxxxx> wrote: > > static inline struct kvm_mmu_page * > > tdp_mmu_get_root_for_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault > > *fault) > > { > > hpa_t root_hpa; > > if (unlikely(fault->is_private && kvm_has_mirror_tdp(kvm))) > > root_hpa = vcpu->arch.mmu->mirror_root_hpa; > > else > > root_hpa = vcpu->arch.mmu->root.hpa; > > return root_to_sp(root_hpa); > > } > > I was not loving the amount of indirection here in the patch, but thought it > centralized the logic a bit better. This way seems good, given that the actual > logic is not that complex. My proposed implementation is a bit TDX-specific though... Something like this is more agnostic, and it exploits nicely the difference between fault->addr and fault->gfn: if (!kvm_gfn_direct_mask(kvm) || (gpa_to_gfn(fault->addr) & kvm_gfn_direct_mask(kvm)) root_hpa = vcpu->arch.mmu->root.hpa; else root_hpa = vcpu->arch.mmu->mirror_root_hpa; return root_to_sp(root_hpa); Paolo