From: Sean Christopherson Date: Thu, 10 Oct 2024 18:23:16 +0000 (-0700) Subject: KVM: Return ERR_SIGPENDING from hva_to_pfn() if GUP returns -EGAIN X-Git-Tag: v6.13-rc1~97^2~17^2~71 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=d1331a44694abbdb309cd3eb3e3d400134c670cf;p=thirdparty%2Fkernel%2Flinux.git KVM: Return ERR_SIGPENDING from hva_to_pfn() if GUP returns -EGAIN Treat an -EAGAIN return from GUP the same as -EINTR and immediately report to the caller that a signal is pending. GUP only returns -EAGAIN if the _initial_ mmap_read_lock_killable() fails, which in turn onnly fails if a signal is pending Note, rwsem_down_read_slowpath() actually returns -EINTR, so GUP is really just making life harder than it needs to be. And the call to mmap_read_lock_killable() in the retry path returns its -errno verbatim, i.e. GUP (and thus KVM) is already handling locking failure this way, but only some of the time. Suggested-by: Paolo Bonzini Signed-off-by: Sean Christopherson Tested-by: Dmitry Osipenko Signed-off-by: Paolo Bonzini Message-ID: <20241010182427.1434605-15-seanjc@google.com> --- diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index c60b542c7241b..88db55f9a8b61 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c @@ -2946,7 +2946,7 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool interruptible, bool *async, writable, &pfn); if (npages == 1) return pfn; - if (npages == -EINTR) + if (npages == -EINTR || npages == -EAGAIN) return KVM_PFN_ERR_SIGPENDING; mmap_read_lock(current->mm);