提交 e4a533a4 编写于 作者: N npiggin@suse.de 提交者: Avi Kivity

KVM: Convert KVM from ->nopage() to ->fault()

Signed-off-by: NNick Piggin <npiggin@suse.de>
Cc: kvm-devel@lists.sourceforge.net
Cc: avi@qumranet.com
Cc: linux-kernel@vger.kernel.org
Signed-off-by: NAvi Kivity <avi@qumranet.com>
上级 53e0aa7b
...@@ -662,30 +662,24 @@ void kvm_resched(struct kvm_vcpu *vcpu) ...@@ -662,30 +662,24 @@ void kvm_resched(struct kvm_vcpu *vcpu)
} }
EXPORT_SYMBOL_GPL(kvm_resched); EXPORT_SYMBOL_GPL(kvm_resched);
static struct page *kvm_vcpu_nopage(struct vm_area_struct *vma, static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
unsigned long address,
int *type)
{ {
struct kvm_vcpu *vcpu = vma->vm_file->private_data; struct kvm_vcpu *vcpu = vma->vm_file->private_data;
unsigned long pgoff;
struct page *page; struct page *page;
pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; if (vmf->pgoff == 0)
if (pgoff == 0)
page = virt_to_page(vcpu->run); page = virt_to_page(vcpu->run);
else if (pgoff == KVM_PIO_PAGE_OFFSET) else if (vmf->pgoff == KVM_PIO_PAGE_OFFSET)
page = virt_to_page(vcpu->pio_data); page = virt_to_page(vcpu->pio_data);
else else
return NOPAGE_SIGBUS; return VM_FAULT_SIGBUS;
get_page(page); get_page(page);
if (type != NULL) vmf->page = page;
*type = VM_FAULT_MINOR; return 0;
return page;
} }
static struct vm_operations_struct kvm_vcpu_vm_ops = { static struct vm_operations_struct kvm_vcpu_vm_ops = {
.nopage = kvm_vcpu_nopage, .fault = kvm_vcpu_fault,
}; };
static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma) static int kvm_vcpu_mmap(struct file *file, struct vm_area_struct *vma)
...@@ -976,31 +970,25 @@ static long kvm_vm_ioctl(struct file *filp, ...@@ -976,31 +970,25 @@ static long kvm_vm_ioctl(struct file *filp,
return r; return r;
} }
static struct page *kvm_vm_nopage(struct vm_area_struct *vma, static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
unsigned long address,
int *type)
{ {
struct kvm *kvm = vma->vm_file->private_data; struct kvm *kvm = vma->vm_file->private_data;
unsigned long pgoff;
struct page *page; struct page *page;
pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff; if (!kvm_is_visible_gfn(kvm, vmf->pgoff))
if (!kvm_is_visible_gfn(kvm, pgoff)) return VM_FAULT_SIGBUS;
return NOPAGE_SIGBUS;
/* current->mm->mmap_sem is already held so call lockless version */ /* current->mm->mmap_sem is already held so call lockless version */
page = __gfn_to_page(kvm, pgoff); page = __gfn_to_page(kvm, vmf->pgoff);
if (is_error_page(page)) { if (is_error_page(page)) {
kvm_release_page_clean(page); kvm_release_page_clean(page);
return NOPAGE_SIGBUS; return VM_FAULT_SIGBUS;
} }
if (type != NULL) vmf->page = page;
*type = VM_FAULT_MINOR; return 0;
return page;
} }
static struct vm_operations_struct kvm_vm_vm_ops = { static struct vm_operations_struct kvm_vm_vm_ops = {
.nopage = kvm_vm_nopage, .fault = kvm_vm_fault,
}; };
static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma) static int kvm_vm_mmap(struct file *file, struct vm_area_struct *vma)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册