]> www.infradead.org Git - users/hch/dma-mapping.git/commitdiff
kvm: Add KVM_PFN_ERR_SIGPENDING
authorPeter Xu <peterx@redhat.com>
Tue, 11 Oct 2022 19:58:07 +0000 (15:58 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 9 Nov 2022 17:31:27 +0000 (12:31 -0500)
Add a new pfn error to show that we've got a pending signal to handle
during hva_to_pfn_slow() procedure (of -EINTR retval).

Signed-off-by: Peter Xu <peterx@redhat.com>
Reviewed-by: Sean Christopherson <seanjc@google.com>
Message-Id: <20221011195809.557016-3-peterx@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
include/linux/kvm_host.h
virt/kvm/kvm_main.c

index 18592bdf4c1bfa3c35c639fca04a36d8d9d9b67f..911b064878dfa3a372234a0ff0d73b8295ccb646 100644 (file)
@@ -96,6 +96,7 @@
 #define KVM_PFN_ERR_FAULT      (KVM_PFN_ERR_MASK)
 #define KVM_PFN_ERR_HWPOISON   (KVM_PFN_ERR_MASK + 1)
 #define KVM_PFN_ERR_RO_FAULT   (KVM_PFN_ERR_MASK + 2)
+#define KVM_PFN_ERR_SIGPENDING (KVM_PFN_ERR_MASK + 3)
 
 /*
  * error pfns indicate that the gfn is in slot but faild to
@@ -106,6 +107,15 @@ static inline bool is_error_pfn(kvm_pfn_t pfn)
        return !!(pfn & KVM_PFN_ERR_MASK);
 }
 
+/*
+ * KVM_PFN_ERR_SIGPENDING indicates that fetching the PFN was interrupted
+ * by a pending signal.  Note, the signal may or may not be fatal.
+ */
+static inline bool is_sigpending_pfn(kvm_pfn_t pfn)
+{
+       return pfn == KVM_PFN_ERR_SIGPENDING;
+}
+
 /*
  * error_noslot pfns indicate that the gfn can not be
  * translated to pfn - it is not in slot or failed to
index 25d7872b29c17ee554eff1f3b5702a33b17a4143..558f52dbebbde8f3abcbea9e864f1ec5010b4655 100644 (file)
@@ -2667,6 +2667,8 @@ kvm_pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
        npages = hva_to_pfn_slow(addr, async, write_fault, writable, &pfn);
        if (npages == 1)
                return pfn;
+       if (npages == -EINTR)
+               return KVM_PFN_ERR_SIGPENDING;
 
        mmap_read_lock(current->mm);
        if (npages == -EHWPOISON ||