hva_to_pfn() checks a FOLL_NOWAIT gup() for EINTR, EAGAIN and EHWPOISON. There might be others like -EFAULT for VM_FAULT_SIGBUS. For those other errors, reporting KVM_PFN_ERR_NEEDS_IO would be wrong as it triggers an async_pf resulting in endless retries. Return KVM_PFN_ERR_NEEDS_IO only if gup() returned 0 pages and report the error otherwise. Fixes: 0857b9e95c1a ("KVM: Enable async page fault processing") Signed-off-by: Christian Borntraeger --- virt/kvm/kvm_main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5a782849521c..34b38d7512c3 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3048,6 +3048,7 @@ kvm_pfn_t hva_to_pfn(struct kvm_follow_pfn *kfp) pfn = KVM_PFN_ERR_FAULT; } else { if ((kfp->flags & FOLL_NOWAIT) && + npages == 0 && /* no PFN_ERR_NEEDS_IO on errors */ vma_is_valid(vma, kfp->flags & FOLL_WRITE)) pfn = KVM_PFN_ERR_NEEDS_IO; else -- 2.53.0