@@ -97,6 +97,7 @@
#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)
+#define KVM_PFN_ERR_USERFAULT (KVM_PFN_ERR_MASK + 4)
/*
* error pfns indicate that the gfn is in slot but faild to
@@ -3009,9 +3009,11 @@ kvm_pfn_t __gfn_to_pfn_memslot(const struct kvm_memory_slot *slot, gfn_t gfn,
if (kvm_is_error_hva(addr)) {
if (writable)
*writable = false;
-
- return addr == KVM_HVA_ERR_RO_BAD ? KVM_PFN_ERR_RO_FAULT :
- KVM_PFN_NOSLOT;
+ if (addr == KVM_HVA_ERR_RO_BAD)
+ return KVM_PFN_ERR_RO_FAULT;
+ if (addr == KVM_HVA_ERR_USERFAULT)
+ return KVM_PFN_ERR_USERFAULT;
+ return KVM_PFN_NOSLOT;
}
/* Do not map writable pfn in the readonly memslot. */
When a GFN -> HVA translation (__gfn_to_hva_many()) fails with KVM_HVA_ERR_USERFAULT as part of a GFN -> PFN conversion (__gfn_to_pfn_memslot()), we need to return some kind of KVM_PFN_ERR. Introduce a new KVM_PFN_ERR_USERFAULT so that callers know that it is a userfault. Signed-off-by: James Houghton <jthoughton@google.com> --- include/linux/kvm_host.h | 1 + virt/kvm/kvm_main.c | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-)