From: Sean Christopherson <seanjc@google.com>
To: Christian Borntraeger <borntraeger@linux.ibm.com>
Cc: Janosch Frank <frankja@linux.ibm.com>,
Claudio Imbrenda <imbrenda@linux.ibm.com>,
Paolo Bonzini <pbonzini@redhat.com>, KVM <kvm@vger.kernel.org>,
linux-s390 <linux-s390@vger.kernel.org>,
Shuah Khan <shuah@kernel.org>
Subject: Re: [PATCH 1/2] KVM: Set up async page faults only for faults that need to wait
Date: Tue, 20 Oct 2026 08:44:26 -0700 [thread overview]
Message-ID: <ateMWvgHjLLjYkYk@google.com> (raw)
In-Reply-To: <20261020143308.228328-2-borntraeger@linux.ibm.com>
On Tue, Oct 20, 2026, Christian Borntraeger wrote:
> 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 <borntraeger@linux.ibm.com>
> ---
> 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 */
!npages is generally preferred over "== 0".
> vma_is_valid(vma, kfp->flags & FOLL_WRITE))
> pfn = KVM_PFN_ERR_NEEDS_IO;
> else
Maybe instead of calling out "on errors", explicitly call out that GUP returns '0'
when the fault needs to be retried? And if we move the npages check first, then
IMO we can use a block comment instead of a trailing comment, e.g.
/* 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
pfn = KVM_PFN_ERR_FAULT;
For anyone else that found this surprising, while faultin_page() returns -EBUSY
or -EAGAIN, __get_user_pages() converts those to '0':
ret = faultin_page(vma, start, gup_flags,
PTR_ERR(page) == -EMLINK, locked);
switch (ret) {
case 0:
goto retry;
case -EBUSY:
case -EAGAIN:
ret = 0;
fallthrough;
case -EFAULT:
case -ENOMEM:
case -EHWPOISON:
goto out;
}
It'd be loved if GUP return EWOULDBLOCK for this case, but I can only imagine the
pain that could cause for the rest of the kernel.
next prev parent reply other threads:[~2026-10-20 15:44 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-20 14:33 [PATCH 0/2] Fix error handling for async_pf Christian Borntraeger
2026-10-20 14:33 ` [PATCH 1/2] KVM: Set up async page faults only for faults that need to wait Christian Borntraeger
2026-10-20 14:38 ` sashiko-bot
2026-10-20 15:44 ` Sean Christopherson [this message]
2026-10-20 14:33 ` [PATCH 2/2] KVM: selftests: Test that KVM_RUN fails for unresolvable host faults Christian Borntraeger
2026-10-20 14:40 ` sashiko-bot
2026-10-20 14:45 ` Christian Borntraeger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ateMWvgHjLLjYkYk@google.com \
--to=seanjc@google.com \
--cc=borntraeger@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=imbrenda@linux.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pbonzini@redhat.com \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.