Re: [PATCH v9 5/6] KVM: x86: Migrate to __kvm_follow_pfn

From: Sean Christopherson
Date: Tue Oct 03 2023 - 16:58:53 EST


On Tue, Oct 03, 2023, Maxim Levitsky wrote:
> У пн, 2023-09-11 у 11:16 +0900, David Stevens пише:
> > From: David Stevens <stevensd@xxxxxxxxxxxx>
> > @@ -4283,12 +4290,20 @@ static int __kvm_faultin_pfn(struct kvm_vcpu *vcpu, struct kvm_page_fault *fault
> > return RET_PF_EMULATE;
> > }
> >
> > - async = false;
> > - fault->pfn = __gfn_to_pfn_memslot(slot, fault->gfn, false, false, &async,
> > - fault->write, &fault->map_writable,
> > - &fault->hva);
> > - if (!async)
> > - return RET_PF_CONTINUE; /* *pfn has correct page already */
> > + foll.flags |= FOLL_NOWAIT;
> > + fault->pfn = __kvm_follow_pfn(&foll);
> > +
> > + if (!is_error_noslot_pfn(fault->pfn))
> > + goto success;
> Unrelated but I can't say I like the 'is_error_noslot_pfn()' name,
> I wish it was called something like is_valid_pfn().

I don't love the name either, but is_valid_pfn() would be extremely confusing
because the kernel already provides pfn_valid() to identify pfns/pages that are
managed by the kernel. Trying to shove "guest" somewhere in the name also gets
confusing because it's a host pfn, not a guest pfn.