Skip to content

Commit 6c8ee57

Browse files
Xiao Guangrongavikivity
authored andcommitted
KVM: introduce KVM_PFN_ERR_FAULT
After that, the exported and un-inline function, get_fault_pfn, can be removed Signed-off-by: Xiao Guangrong <[email protected]> Signed-off-by: Avi Kivity <[email protected]>
1 parent 16b854c commit 6c8ee57

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

arch/x86/kvm/mmu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ static pfn_t pte_prefetch_gfn_to_pfn(struct kvm_vcpu *vcpu, gfn_t gfn,
25122512

25132513
slot = gfn_to_memslot_dirty_bitmap(vcpu, gfn, no_dirty_log);
25142514
if (!slot)
2515-
return get_fault_pfn();
2515+
return KVM_PFN_ERR_FAULT;
25162516

25172517
hva = gfn_to_hva_memslot(slot, gfn);
25182518

include/linux/kvm_host.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@
4848
#define KVM_MAX_MMIO_FRAGMENTS \
4949
(KVM_MMIO_SIZE / KVM_USER_MMIO_SIZE + KVM_EXTRA_MMIO_FRAGMENTS)
5050

51+
#define KVM_PFN_ERR_FAULT (-EFAULT)
52+
5153
/*
5254
* vcpu->requests bit members
5355
*/
@@ -443,7 +445,6 @@ void kvm_release_pfn_clean(pfn_t pfn);
443445
void kvm_set_pfn_dirty(pfn_t pfn);
444446
void kvm_set_pfn_accessed(pfn_t pfn);
445447
void kvm_get_pfn(pfn_t pfn);
446-
pfn_t get_fault_pfn(void);
447448

448449
int kvm_read_guest_page(struct kvm *kvm, gfn_t gfn, void *data, int offset,
449450
int len);

virt/kvm/kvm_main.c

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -939,12 +939,6 @@ static pfn_t get_bad_pfn(void)
939939
return -ENOENT;
940940
}
941941

942-
pfn_t get_fault_pfn(void)
943-
{
944-
return -EFAULT;
945-
}
946-
EXPORT_SYMBOL_GPL(get_fault_pfn);
947-
948942
static pfn_t get_hwpoison_pfn(void)
949943
{
950944
return -EHWPOISON;
@@ -1115,7 +1109,7 @@ static pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
11151109
struct vm_area_struct *vma;
11161110

11171111
if (atomic)
1118-
return get_fault_pfn();
1112+
return KVM_PFN_ERR_FAULT;
11191113

11201114
down_read(&current->mm->mmap_sem);
11211115
if (npages == -EHWPOISON ||
@@ -1127,15 +1121,15 @@ static pfn_t hva_to_pfn(unsigned long addr, bool atomic, bool *async,
11271121
vma = find_vma_intersection(current->mm, addr, addr+1);
11281122

11291123
if (vma == NULL)
1130-
pfn = get_fault_pfn();
1124+
pfn = KVM_PFN_ERR_FAULT;
11311125
else if ((vma->vm_flags & VM_PFNMAP)) {
11321126
pfn = ((addr - vma->vm_start) >> PAGE_SHIFT) +
11331127
vma->vm_pgoff;
11341128
BUG_ON(!kvm_is_mmio_pfn(pfn));
11351129
} else {
11361130
if (async && (vma->vm_flags & VM_WRITE))
11371131
*async = true;
1138-
pfn = get_fault_pfn();
1132+
pfn = KVM_PFN_ERR_FAULT;
11391133
}
11401134
up_read(&current->mm->mmap_sem);
11411135
} else

0 commit comments

Comments
 (0)