/* Get host physical address for gpa */
        hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
-       if (is_error_pfn(hpaddr)) {
+       if (is_error_noslot_pfn(hpaddr)) {
                printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n",
                                 orig_pte->eaddr);
                r = -EINVAL;
 
 
        /* Get host physical address for gpa */
        hpaddr = kvmppc_gfn_to_pfn(vcpu, orig_pte->raddr >> PAGE_SHIFT);
-       if (is_error_pfn(hpaddr)) {
+       if (is_error_noslot_pfn(hpaddr)) {
                printk(KERN_INFO "Couldn't get guest page for gfn %lx!\n", orig_pte->eaddr);
                r = -EINVAL;
                goto out;
 
        if (likely(!pfnmap)) {
                unsigned long tsize_pages = 1 << (tsize + 10 - PAGE_SHIFT);
                pfn = gfn_to_pfn_memslot(slot, gfn);
-               if (is_error_pfn(pfn)) {
+               if (is_error_noslot_pfn(pfn)) {
                        printk(KERN_ERR "Couldn't get real page for gfn %lx!\n",
                                        (long)gfn);
                        return;
 
         * PT_PAGE_TABLE_LEVEL and there would be no adjustment done
         * here.
         */
-       if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn) &&
+       if (!is_error_noslot_pfn(pfn) && !kvm_is_mmio_pfn(pfn) &&
            level == PT_PAGE_TABLE_LEVEL &&
            PageTransCompound(pfn_to_page(pfn)) &&
            !has_wrprotected_page(vcpu->kvm, gfn, PT_DIRECTORY_LEVEL)) {
        bool ret = true;
 
        /* The pfn is invalid, report the error! */
-       if (unlikely(is_invalid_pfn(pfn))) {
+       if (unlikely(is_error_pfn(pfn))) {
                *ret_val = kvm_handle_bad_page(vcpu, gfn, pfn);
                goto exit;
        }
 
        protect_clean_gpte(&pte_access, gpte);
        pfn = pte_prefetch_gfn_to_pfn(vcpu, gfn,
                        no_dirty_log && (pte_access & ACC_WRITE_MASK));
-       if (is_invalid_pfn(pfn))
+       if (is_error_pfn(pfn))
                return false;
 
        /*
 
         * instruction -> ...
         */
        pfn = gfn_to_pfn(vcpu->kvm, gpa_to_gfn(gpa));
-       if (!is_error_pfn(pfn)) {
+       if (!is_error_noslot_pfn(pfn)) {
                kvm_release_pfn_clean(pfn);
                return true;
        }
 
 
 /*
  * For the normal pfn, the highest 12 bits should be zero,
- * so we can mask these bits to indicate the error.
+ * so we can mask bit 62 ~ bit 52  to indicate the error pfn,
+ * mask bit 63 to indicate the noslot pfn.
  */
-#define KVM_PFN_ERR_MASK       (0xfffULL << 52)
+#define KVM_PFN_ERR_MASK       (0x7ffULL << 52)
+#define KVM_PFN_ERR_NOSLOT_MASK        (0xfffULL << 52)
+#define KVM_PFN_NOSLOT         (0x1ULL << 63)
 
 #define KVM_PFN_ERR_FAULT      (KVM_PFN_ERR_MASK)
 #define KVM_PFN_ERR_HWPOISON   (KVM_PFN_ERR_MASK + 1)
-#define KVM_PFN_ERR_BAD                (KVM_PFN_ERR_MASK + 2)
-#define KVM_PFN_ERR_RO_FAULT   (KVM_PFN_ERR_MASK + 3)
+#define KVM_PFN_ERR_RO_FAULT   (KVM_PFN_ERR_MASK + 2)
 
+/*
+ * error pfns indicate that the gfn is in slot but faild to
+ * translate it to pfn on host.
+ */
 static inline bool is_error_pfn(pfn_t pfn)
 {
        return !!(pfn & KVM_PFN_ERR_MASK);
 }
 
-static inline bool is_noslot_pfn(pfn_t pfn)
+/*
+ * error_noslot pfns indicate that the gfn can not be
+ * translated to pfn - it is not in slot or failed to
+ * translate it to pfn.
+ */
+static inline bool is_error_noslot_pfn(pfn_t pfn)
 {
-       return pfn == KVM_PFN_ERR_BAD;
+       return !!(pfn & KVM_PFN_ERR_NOSLOT_MASK);
 }
 
-static inline bool is_invalid_pfn(pfn_t pfn)
+/* noslot pfn indicates that the gfn is not in slot. */
+static inline bool is_noslot_pfn(pfn_t pfn)
 {
-       return !is_noslot_pfn(pfn) && is_error_pfn(pfn);
+       return pfn == KVM_PFN_NOSLOT;
 }
 
 #define KVM_HVA_ERR_BAD                (PAGE_OFFSET)
 
        end_gfn = gfn + (size >> PAGE_SHIFT);
        gfn    += 1;
 
-       if (is_error_pfn(pfn))
+       if (is_error_noslot_pfn(pfn))
                return pfn;
 
        while (gfn < end_gfn)
                 * important because we unmap and unpin in 4kb steps later.
                 */
                pfn = kvm_pin_pages(slot, gfn, page_size);
-               if (is_error_pfn(pfn)) {
+               if (is_error_noslot_pfn(pfn)) {
                        gfn += 1;
                        continue;
                }
 
                return KVM_PFN_ERR_RO_FAULT;
 
        if (kvm_is_error_hva(addr))
-               return KVM_PFN_ERR_BAD;
+               return KVM_PFN_NOSLOT;
 
        /* Do not map writable pfn in the readonly memslot. */
        if (writable && memslot_is_readonly(slot)) {
 
 static struct page *kvm_pfn_to_page(pfn_t pfn)
 {
-       if (is_error_pfn(pfn))
+       if (is_error_noslot_pfn(pfn))
                return KVM_ERR_PTR_BAD_PAGE;
 
        if (kvm_is_mmio_pfn(pfn)) {
 
 void kvm_release_pfn_clean(pfn_t pfn)
 {
-       if (!is_error_pfn(pfn) && !kvm_is_mmio_pfn(pfn))
+       if (!is_error_noslot_pfn(pfn) && !kvm_is_mmio_pfn(pfn))
                put_page(pfn_to_page(pfn));
 }
 EXPORT_SYMBOL_GPL(kvm_release_pfn_clean);