Skip to content

Commit

Permalink
KVM: introduce KVM_HVA_ERR_BAD
Browse files Browse the repository at this point in the history
Then, remove bad_hva and inline kvm_is_error_hva

Signed-off-by: Xiao Guangrong <[email protected]>
Signed-off-by: Avi Kivity <[email protected]>
  • Loading branch information
Xiao Guangrong authored and avikivity committed Aug 22, 2012
1 parent 69552c2 commit ca3a490
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
8 changes: 7 additions & 1 deletion include/linux/kvm_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,13 @@ static inline bool is_invalid_pfn(pfn_t pfn)
return !is_noslot_pfn(pfn) && is_error_pfn(pfn);
}

#define KVM_HVA_ERR_BAD (PAGE_OFFSET)

static inline bool kvm_is_error_hva(unsigned long addr)
{
return addr == PAGE_OFFSET;
}

#define KVM_ERR_PTR_BAD_PAGE (ERR_PTR(-ENOENT))

static inline bool is_error_page(struct page *page)
Expand Down Expand Up @@ -430,7 +437,6 @@ id_to_memslot(struct kvm_memslots *slots, int id)
return slot;
}

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);
Expand Down
13 changes: 1 addition & 12 deletions virt/kvm/kvm_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -931,17 +931,6 @@ void kvm_disable_largepages(void)
}
EXPORT_SYMBOL_GPL(kvm_disable_largepages);

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);

struct kvm_memory_slot *gfn_to_memslot(struct kvm *kvm, gfn_t gfn)
{
return __gfn_to_memslot(kvm_memslots(kvm), gfn);
Expand Down Expand Up @@ -988,7 +977,7 @@ static unsigned long gfn_to_hva_many(struct kvm_memory_slot *slot, gfn_t gfn,
gfn_t *nr_pages)
{
if (!slot || slot->flags & KVM_MEMSLOT_INVALID)
return bad_hva();
return KVM_HVA_ERR_BAD;

if (nr_pages)
*nr_pages = slot->npages - (gfn - slot->base_gfn);
Expand Down

0 comments on commit ca3a490

Please sign in to comment.