From: Izik Eidus Date: Sun, 11 Nov 2007 20:02:22 +0000 (+0200) Subject: KVM: add kvm_is_error_hva() X-Git-Tag: v2.6.25-rc1~1138^2~155 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=f9d46eb0e4a5b5e0926ca61c19f8c8bbb9496b28;p=linux-2.6-omap-h63xx.git KVM: add kvm_is_error_hva() Check for the "error hva", an address outside the user address space that signals a bad gfn. Signed-off-by: Izik Eidus Signed-off-by: Avi Kivity --- diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h index 3f5ffc37480..64983240adc 100644 --- a/drivers/kvm/kvm.h +++ b/drivers/kvm/kvm.h @@ -520,6 +520,7 @@ struct page *gva_to_page(struct kvm_vcpu *vcpu, gva_t gva); extern struct page *bad_page; int is_error_page(struct page *page); +int kvm_is_error_hva(unsigned long addr); int kvm_set_memory_region(struct kvm *kvm, struct kvm_userspace_memory_region *mem, int user_alloc); diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c index d395c987894..dfb65e2f87e 100644 --- a/drivers/kvm/kvm_main.c +++ b/drivers/kvm/kvm_main.c @@ -498,6 +498,17 @@ int is_error_page(struct page *page) } EXPORT_SYMBOL_GPL(is_error_page); +static inline unsigned long bad_hva(void) +{ + return PAGE_OFFSET; +} + +int kvm_is_error_hva(unsigned long addr) +{ + return addr == bad_hva(); +} +EXPORT_SYMBOL_GPL(kvm_is_error_hva); + gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) { int i;