Re: [RFC PATCH v6 034/104] KVM: x86/mmu: Add address conversion functions for TDX shared bits

From: Isaku Yamahata
Date: Thu May 12 2022 - 05:50:22 EST


On Tue, May 10, 2022 at 12:16:58PM +1200,
Kai Huang <kai.huang@xxxxxxxxx> wrote:

> On Thu, 2022-05-05 at 11:14 -0700, isaku.yamahata@xxxxxxxxx wrote:
> > From: Rick Edgecombe <rick.p.edgecombe@xxxxxxxxx>
...
> > diff --git a/arch/x86/kvm/mmu/mmu.c b/arch/x86/kvm/mmu/mmu.c
> > index 909372762363..d1c37295bb6e 100644
> > --- a/arch/x86/kvm/mmu/mmu.c
> > +++ b/arch/x86/kvm/mmu/mmu.c
> > @@ -264,8 +264,10 @@ static void kvm_flush_remote_tlbs_with_range(struct kvm *kvm,
> > {
> > int ret = -ENOTSUPP;
> >
> > - if (range && kvm_x86_ops.tlb_remote_flush_with_range)
> > + if (range && kvm_available_flush_tlb_with_range()) {
> > + /* Callback should flush both private GFN and shared GFN. */
> > ret = static_call(kvm_x86_tlb_remote_flush_with_range)(kvm, range);
> > + }
>
> ??

Dropped this hunk.


> > if (ret)
> > kvm_flush_remote_tlbs(kvm);
> > @@ -4048,7 +4050,7 @@ static int direct_page_fault(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
> > unsigned long mmu_seq;
> > int r;
> >
> > - fault->gfn = fault->addr >> PAGE_SHIFT;
> > + fault->gfn = gpa_to_gfn(fault->addr) & ~kvm_gfn_shared_mask(vcpu->kvm);
> > fault->slot = kvm_vcpu_gfn_to_memslot(vcpu, fault->gfn);
> >
> > if (page_fault_handle_page_track(vcpu, fault))
>
> As I said in previous version, this above change alone is broken:
>
> https://lore.kernel.org/lkml/cover.1646422845.git.isaku.yamahata@xxxxxxxxx/T/#mcd5c235e3577f5129810f3183f151a1c5f63466e
>
> Why cannot this patch be merged to other patch(es) which truly adds
> private/shared mapping support?
>
> Or did I get something wrong?

Oops. Somehow I missed this part. I moved this part to "TDP MMU TDX support".

--
Isaku Yamahata <isaku.yamahata@xxxxxxxxx>