[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CABgObfb1L4SLGLOPwUKTBusN9bVKACJp7cyvgL8LPhGz0QTNAA@mail.gmail.com>
Date: Sat, 8 Jun 2024 11:13:53 +0200
From: Paolo Bonzini <pbonzini@...hat.com>
To: "Edgecombe, Rick P" <rick.p.edgecombe@...el.com>
Cc: "seanjc@...gle.com" <seanjc@...gle.com>, "Huang, Kai" <kai.huang@...el.com>,
"sagis@...gle.com" <sagis@...gle.com>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "Aktas, Erdem" <erdemaktas@...gle.com>,
"Zhao, Yan Y" <yan.y.zhao@...el.com>, "dmatlack@...gle.com" <dmatlack@...gle.com>,
"kvm@...r.kernel.org" <kvm@...r.kernel.org>, "Yamahata, Isaku" <isaku.yamahata@...el.com>,
"isaku.yamahata@...il.com" <isaku.yamahata@...il.com>
Subject: Re: [PATCH v2 09/15] KVM: x86/tdp_mmu: Support mirror root for TDP MMU
On Fri, Jun 7, 2024 at 10:27 PM Edgecombe, Rick P
<rick.p.edgecombe@...el.com> 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
Powered by blists - more mailing lists