public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 05/18] kvm: nopage
       [not found] <20071205071547.701344000@nick.local0.net>
@ 2007-12-05  7:15 ` npiggin-l3A5Bk7waGM
       [not found]   ` <20071205071627.251516000-wDNK3PsPySm71z1jCTBXHQ@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: npiggin-l3A5Bk7waGM @ 2007-12-05  7:15 UTC (permalink / raw)
  To: akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA, avi-atKUWr5tajBWk0Htik3J/w

[-- Attachment #1: kvm-nopage.patch --]
[-- Type: text/plain, Size: 2758 bytes --]

Convert KVM from nopage to fault.

Signed-off-by: Nick Piggin <npiggin-l3A5Bk7waGM@public.gmane.org>
Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org
Cc: avi-atKUWr5tajBWk0Htik3J/w@public.gmane.org
Cc: linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
---
 drivers/kvm/kvm_main.c |   38 +++++++++++++-------------------------
 1 file changed, 13 insertions(+), 25 deletions(-)

Index: linux-2.6/drivers/kvm/kvm_main.c
===================================================================
--- linux-2.6.orig/drivers/kvm/kvm_main.c
+++ linux-2.6/drivers/kvm/kvm_main.c
@@ -2533,30 +2533,24 @@ static int kvm_vcpu_ioctl_debug_guest(st
 	return r;
 }
 
-static struct page *kvm_vcpu_nopage(struct vm_area_struct *vma,
-				    unsigned long address,
-				    int *type)
+static int kvm_vcpu_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct kvm_vcpu *vcpu = vma->vm_file->private_data;
-	unsigned long pgoff;
 	struct page *page;
 
-	pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
-	if (pgoff == 0)
+	if (vmf->pgoff == 0)
 		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);
 	else
-		return NOPAGE_SIGBUS;
+		return VM_FAULT_SIGBUS;
 	get_page(page);
-	if (type != NULL)
-		*type = VM_FAULT_MINOR;
-
-	return page;
+	vmf->page = page;
+	return 0;
 }
 
 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)
@@ -3111,27 +3105,21 @@ out:
 	return r;
 }
 
-static struct page *kvm_vm_nopage(struct vm_area_struct *vma,
-				  unsigned long address,
-				  int *type)
+static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
 {
 	struct kvm *kvm = vma->vm_file->private_data;
-	unsigned long pgoff;
 	struct page *page;
 
-	pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
-	page = gfn_to_page(kvm, pgoff);
+	page = gfn_to_page(kvm, vmf->pgoff);
 	if (!page)
-		return NOPAGE_SIGBUS;
+		return VM_FAULT_SIGBUS;
 	get_page(page);
-	if (type != NULL)
-		*type = VM_FAULT_MINOR;
-
-	return page;
+	vmf->page = page;
+	return 0;
 }
 
 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)

-- 


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [patch 05/18] kvm: nopage
       [not found]   ` <20071205071627.251516000-wDNK3PsPySm71z1jCTBXHQ@public.gmane.org>
@ 2007-12-05 10:40     ` Avi Kivity
  0 siblings, 0 replies; 2+ messages in thread
From: Avi Kivity @ 2007-12-05 10:40 UTC (permalink / raw)
  To: npiggin-l3A5Bk7waGM
  Cc: kvm-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f,
	akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA

npiggin-l3A5Bk7waGM@public.gmane.org wrote:
> Convert KVM from nopage to fault.
>
>   

> @@ -3111,27 +3105,21 @@ out:
>  	return r;
>  }
>  
> -static struct page *kvm_vm_nopage(struct vm_area_struct *vma,
> -				  unsigned long address,
> -				  int *type)
> +static int kvm_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
>  {
>  	struct kvm *kvm = vma->vm_file->private_data;
> -	unsigned long pgoff;
>  	struct page *page;
>  
> -	pgoff = ((address - vma->vm_start) >> PAGE_SHIFT) + vma->vm_pgoff;
> -	page = gfn_to_page(kvm, pgoff);
> +	page = gfn_to_page(kvm, vmf->pgoff);
>  	if (!page)
> -		return NOPAGE_SIGBUS;
> +		return VM_FAULT_SIGBUS;
>  	get_page(page);
> -	if (type != NULL)
> -		*type = VM_FAULT_MINOR;
> -
> -	return page;
> +	vmf->page = page;
> +	return 0;
>  }
>  
>   

This part has changed in kvm.git, so this won't apply to -mm.  I ported 
it and applied to my tree, so it should arrive in -mm when Andrew 
re-fetches.

-- 
error compiling committee.c: too many arguments to function


-------------------------------------------------------------------------
SF.Net email is sponsored by: The Future of Linux Business White Paper
from Novell.  From the desktop to the data center, Linux is going
mainstream.  Let it simplify your IT future.
http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-12-05 10:40 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <20071205071547.701344000@nick.local0.net>
2007-12-05  7:15 ` [patch 05/18] kvm: nopage npiggin-l3A5Bk7waGM
     [not found]   ` <20071205071627.251516000-wDNK3PsPySm71z1jCTBXHQ@public.gmane.org>
2007-12-05 10:40     ` Avi Kivity

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox