Re: [PATCH v2 09/15] KVM: x86/tdp_mmu: Support mirror root for TDP MMU

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux