Skip to content

Commit 6cede2e

Browse files
Xiao Guangrongavikivity
Xiao Guangrong
authored andcommitted
KVM: introduce KVM_ERR_PTR_BAD_PAGE
It is used to eliminate the overload of function call and cleanup the code Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent 9a592a9 commit 6cede2e

File tree

3 files changed

+9
-15
lines changed

3 files changed

+9
-15
lines changed

include/linux/kvm_host.h

+7-2
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ static inline int is_invalid_pfn(pfn_t pfn)
6868
return !is_noslot_pfn(pfn) && is_error_pfn(pfn);
6969
}
7070

71+
#define KVM_ERR_PTR_BAD_PAGE (ERR_PTR(-ENOENT))
72+
73+
static inline int is_error_page(struct page *page)
74+
{
75+
return IS_ERR(page);
76+
}
77+
7178
/*
7279
* vcpu->requests bit members
7380
*/
@@ -409,7 +416,6 @@ id_to_memslot(struct kvm_memslots *slots, int id)
409416
return slot;
410417
}
411418

412-
int is_error_page(struct page *page);
413419
int kvm_is_error_hva(unsigned long addr);
414420
int kvm_set_memory_region(struct kvm *kvm,
415421
struct kvm_userspace_memory_region *mem,
@@ -436,7 +442,6 @@ void kvm_arch_flush_shadow(struct kvm *kvm);
436442
int gfn_to_page_many_atomic(struct kvm *kvm, gfn_t gfn, struct page **pages,
437443
int nr_pages);
438444

439-
struct page *get_bad_page(void);
440445
struct page *gfn_to_page(struct kvm *kvm, gfn_t gfn);
441446
unsigned long gfn_to_hva(struct kvm *kvm, gfn_t gfn);
442447
void kvm_release_page_clean(struct page *page);

virt/kvm/async_pf.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ int kvm_async_pf_wakeup_all(struct kvm_vcpu *vcpu)
203203
if (!work)
204204
return -ENOMEM;
205205

206-
work->page = get_bad_page();
206+
work->page = KVM_ERR_PTR_BAD_PAGE;
207207
INIT_LIST_HEAD(&work->queue); /* for list_del to work */
208208

209209
spin_lock(&vcpu->async_pf.lock);

virt/kvm/kvm_main.c

+1-12
Original file line numberDiff line numberDiff line change
@@ -922,17 +922,6 @@ void kvm_disable_largepages(void)
922922
}
923923
EXPORT_SYMBOL_GPL(kvm_disable_largepages);
924924

925-
int is_error_page(struct page *page)
926-
{
927-
return IS_ERR(page);
928-
}
929-
EXPORT_SYMBOL_GPL(is_error_page);
930-
931-
struct page *get_bad_page(void)
932-
{
933-
return ERR_PTR(-ENOENT);
934-
}
935-
936925
static inline unsigned long bad_hva(void)
937926
{
938927
return PAGE_OFFSET;
@@ -1179,7 +1168,7 @@ static struct page *kvm_pfn_to_page(pfn_t pfn)
11791168
WARN_ON(kvm_is_mmio_pfn(pfn));
11801169

11811170
if (is_error_pfn(pfn) || kvm_is_mmio_pfn(pfn))
1182-
return get_bad_page();
1171+
return KVM_ERR_PTR_BAD_PAGE;
11831172

11841173
return pfn_to_page(pfn);
11851174
}

0 commit comments

Comments
 (0)