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 | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index 5a782849521c..7b6172810f34 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -3047,7 +3047,8 @@ kvm_pfn_t hva_to_pfn(struct kvm_follow_pfn *kfp) if (r < 0) pfn = KVM_PFN_ERR_FAULT; } else { - if ((kfp->flags & FOLL_NOWAIT) && + /* Note, GUP returns '0' if retry is needed. */ + if (!npages && (kfp->flags & FOLL_NOWAIT) && vma_is_valid(vma, kfp->flags & FOLL_WRITE)) pfn = KVM_PFN_ERR_NEEDS_IO; else -- 2.53.0