diff options
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r-- | include/linux/kvm_host.h | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/include/linux/kvm_host.h b/include/linux/kvm_host.h index 82e2c783a21e..99a47627e046 100644 --- a/include/linux/kvm_host.h +++ b/include/linux/kvm_host.h | |||
@@ -58,28 +58,40 @@ | |||
58 | 58 | ||
59 | /* | 59 | /* |
60 | * For the normal pfn, the highest 12 bits should be zero, | 60 | * For the normal pfn, the highest 12 bits should be zero, |
61 | * so we can mask these bits to indicate the error. | 61 | * so we can mask bit 62 ~ bit 52 to indicate the error pfn, |
62 | * mask bit 63 to indicate the noslot pfn. | ||
62 | */ | 63 | */ |
63 | #define KVM_PFN_ERR_MASK (0xfffULL << 52) | 64 | #define KVM_PFN_ERR_MASK (0x7ffULL << 52) |
65 | #define KVM_PFN_ERR_NOSLOT_MASK (0xfffULL << 52) | ||
66 | #define KVM_PFN_NOSLOT (0x1ULL << 63) | ||
64 | 67 | ||
65 | #define KVM_PFN_ERR_FAULT (KVM_PFN_ERR_MASK) | 68 | #define KVM_PFN_ERR_FAULT (KVM_PFN_ERR_MASK) |
66 | #define KVM_PFN_ERR_HWPOISON (KVM_PFN_ERR_MASK + 1) | 69 | #define KVM_PFN_ERR_HWPOISON (KVM_PFN_ERR_MASK + 1) |
67 | #define KVM_PFN_ERR_BAD (KVM_PFN_ERR_MASK + 2) | 70 | #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 2) |
68 | #define KVM_PFN_ERR_RO_FAULT (KVM_PFN_ERR_MASK + 3) | ||
69 | 71 | ||
72 | /* | ||
73 | * error pfns indicate that the gfn is in slot but faild to | ||
74 | * translate it to pfn on host. | ||
75 | */ | ||
70 | static inline bool is_error_pfn(pfn_t pfn) | 76 | static inline bool is_error_pfn(pfn_t pfn) |
71 | { | 77 | { |
72 | return !!(pfn & KVM_PFN_ERR_MASK); | 78 | return !!(pfn & KVM_PFN_ERR_MASK); |
73 | } | 79 | } |
74 | 80 | ||
75 | static inline bool is_noslot_pfn(pfn_t pfn) | 81 | /* |
82 | * error_noslot pfns indicate that the gfn can not be | ||
83 | * translated to pfn - it is not in slot or failed to | ||
84 | * translate it to pfn. | ||
85 | */ | ||
86 | static inline bool is_error_noslot_pfn(pfn_t pfn) | ||
76 | { | 87 | { |
77 | return pfn == KVM_PFN_ERR_BAD; | 88 | return !!(pfn & KVM_PFN_ERR_NOSLOT_MASK); |
78 | } | 89 | } |
79 | 90 | ||
80 | static inline bool is_invalid_pfn(pfn_t pfn) | 91 | /* noslot pfn indicates that the gfn is not in slot. */ |
92 | static inline bool is_noslot_pfn(pfn_t pfn) | ||
81 | { | 93 | { |
82 | return !is_noslot_pfn(pfn) && is_error_pfn(pfn); | 94 | return pfn == KVM_PFN_NOSLOT; |
83 | } | 95 | } |
84 | 96 | ||
85 | #define KVM_HVA_ERR_BAD (PAGE_OFFSET) | 97 | #define KVM_HVA_ERR_BAD (PAGE_OFFSET) |