aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/kvm_host.h
diff options
context:
space:
mode:
authorXiao Guangrong <xiaoguangrong@linux.vnet.ibm.com>2012-10-16 08:10:59 -0400
committerMarcelo Tosatti <mtosatti@redhat.com>2012-10-29 18:31:04 -0400
commit81c52c56e2b43589091ee29038bcf793d3f184ab (patch)
tree763236629eb034e519db87d8568946883499a155 /include/linux/kvm_host.h
parent19bf7f8ac3f8131100027281c495dbbe00cd5ae0 (diff)
KVM: do not treat noslot pfn as a error pfn
This patch filters noslot pfn out from error pfns based on Marcelo comment: noslot pfn is not a error pfn After this patch, - is_noslot_pfn indicates that the gfn is not in slot - is_error_pfn indicates that the gfn is in slot but the error is occurred when translate the gfn to pfn - is_error_noslot_pfn indicates that the pfn either it is error pfns or it is noslot pfn And is_invalid_pfn can be removed, it makes the code more clean Signed-off-by: Xiao Guangrong <xiaoguangrong@linux.vnet.ibm.com> Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Diffstat (limited to 'include/linux/kvm_host.h')
-rw-r--r--include/linux/kvm_host.h28
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 */
70static inline bool is_error_pfn(pfn_t pfn) 76static 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
75static 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 */
86static 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
80static inline bool is_invalid_pfn(pfn_t pfn) 91/* noslot pfn indicates that the gfn is not in slot. */
92static 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)