Re: [PATCH v2 05/10] KVM: x86/mmu: Introduce kvm_tdp_map_page() to populate guest memory

From: Edgecombe, Rick P
Date: Tue Apr 16 2024 - 10:47:00 EST


On Wed, 2024-04-10 at 15:07 -0700, isaku.yamahata@xxxxxxxxx wrote:
>  
> +int kvm_tdp_map_page(struct kvm_vcpu *vcpu, gpa_t gpa, u64 error_code,
> +                    u8 *level)
> +{
> +       int r;
> +
> +       /* Restrict to TDP page fault. */
> +       if (vcpu->arch.mmu->page_fault != kvm_tdp_page_fault)
> +               return -EINVAL;
> +
> +       r = __kvm_mmu_do_page_fault(vcpu, gpa, error_code, false, NULL,
> level);

Why not prefetch = true? Doesn't it fit? It looks like the behavior will be to
not set the access bit.

> +       if (r < 0)
> +               return r;
> +
> +       switch (r) {
> +       case RET_PF_RETRY:
> +               return -EAGAIN;
> +
> +       case RET_PF_FIXED:
> +       case RET_PF_SPURIOUS:
> +               return 0;
> +
> +       case RET_PF_EMULATE:
> +               return -EINVAL;
> +
> +       case RET_PF_CONTINUE:
> +       case RET_PF_INVALID:
> +       default:
> +               WARN_ON_ONCE(r);
> +               return -EIO;
> +       }
> +}