aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorIzik Eidus <izike@qumranet.com>2007-11-11 15:02:22 -0500
committerAvi Kivity <avi@qumranet.com>2008-01-30 10:53:01 -0500
commitf9d46eb0e4a5b5e0926ca61c19f8c8bbb9496b28 (patch)
tree891e954d8c650641792e415ec6962d81dead116d /drivers
parent1a6f4d7fbd11e539630cd5637311a4e55fae60ef (diff)
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 <izike@qumranet.com> Signed-off-by: Avi Kivity <avi@qumranet.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/kvm/kvm.h1
-rw-r--r--drivers/kvm/kvm_main.c11
2 files changed, 12 insertions, 0 deletions
diff --git a/drivers/kvm/kvm.h b/drivers/kvm/kvm.h
index 3f5ffc37480d..64983240adca 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);
520extern struct page *bad_page; 520extern struct page *bad_page;
521 521
522int is_error_page(struct page *page); 522int is_error_page(struct page *page);
523int kvm_is_error_hva(unsigned long addr);
523int kvm_set_memory_region(struct kvm *kvm, 524int kvm_set_memory_region(struct kvm *kvm,
524 struct kvm_userspace_memory_region *mem, 525 struct kvm_userspace_memory_region *mem,
525 int user_alloc); 526 int user_alloc);
diff --git a/drivers/kvm/kvm_main.c b/drivers/kvm/kvm_main.c
index d395c987894e..dfb65e2f87ee 100644
--- a/drivers/kvm/kvm_main.c
+++ b/drivers/kvm/kvm_main.c
@@ -498,6 +498,17 @@ int is_error_page(struct page *page)
498} 498}
499EXPORT_SYMBOL_GPL(is_error_page); 499EXPORT_SYMBOL_GPL(is_error_page);
500 500
501static inline unsigned long bad_hva(void)
502{
503 return PAGE_OFFSET;
504}
505
506int kvm_is_error_hva(unsigned long addr)
507{
508 return addr == bad_hva();
509}
510EXPORT_SYMBOL_GPL(kvm_is_error_hva);
511
501gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn) 512gfn_t unalias_gfn(struct kvm *kvm, gfn_t gfn)
502{ 513{
503 int i; 514 int i;