File itrace-nopage.patch of Package itrace

---
 src/driver/pi_init.c |   44 ++++++++++++++++++++++++++------------------
 1 file changed, 26 insertions(+), 18 deletions(-)

--- a/src/driver/pi_init.c
+++ b/src/driver/pi_init.c
@@ -94,7 +94,7 @@ int pitrace_release(struct inode *, stru
 int           pitrace_mmap(struct file *, struct vm_area_struct *);
 void          pitrace_vma_open(struct vm_area_struct *);
 void          pitrace_vma_close(struct vm_area_struct *);
-struct page * pitrace_vma_nopage(struct vm_area_struct *, unsigned long, int *);
+int pitrace_vma_fault(struct vm_area_struct *, struct vm_fault *);
 
 int pitrace_cpu_init(void);
 
@@ -131,7 +131,7 @@ struct file_operations pitrace_ops = {
 struct vm_operations_struct pitrace_vm_ops = {
 	.open   = pitrace_vma_open,
 	.close  = pitrace_vma_close,
-	.nopage = pitrace_vma_nopage
+	.fault  = pitrace_vma_fault
 };
 
 //
@@ -620,14 +620,13 @@ void pitrace_vma_close(struct vm_area_st
 }
 
 
-struct page *pitrace_vma_nopage(struct vm_area_struct *vma,
-                                unsigned long address, 
-                                int *type)
+int pitrace_vma_fault(struct vm_area_struct *vma,
+                               struct vm_fault * fdata)
 {
-	struct page *page = NOPAGE_SIGBUS;
+	struct page *page = NULL;
 		
-//	PDEBUG("In pitrace_vma_nopage\n");
-//	PDEBUG("vma->pgoff: %lu\n", vma->vm_pgoff << PAGE_SHIFT);	
+//	PDEBUG("In pitrace_vma_fault\n");
+//	PDEBUG("vma->vm_pgoff: %lu\n", vma->vm_pgoff);
 //	PDEBUG("address: %lx, vma->vm_start: %lx\n", address, vma->vm_start);
 		
 	switch(vma->vm_pgoff << PAGE_SHIFT) {
@@ -635,21 +634,27 @@ struct page *pitrace_vma_nopage(struct v
 		case PI_PTT_DATA_OFFSET:
 		    if (PttBuffer == NULL) {
 		            printk("PttBuffer not allocated\n");
-		            return(page);
+		            return(VM_FAULT_OOM);
 		    }        
-	            page = vmalloc_to_page((void*)PttBuffer + (address - vma->vm_start));
+	            page = vmalloc_to_page((void*)PttBuffer +
+					((unsigned long)fdata->virtual_address -
+					vma->vm_start));
 	            break;
 #endif	            
 	        case PI_MAPPED_DATA_OFFSET:
-	            page = vmalloc_to_page((void*)MappedData + (address - vma->vm_start));
+	            page = vmalloc_to_page((void*)MappedData +
+					((unsigned long)fdata->virtual_address -
+					vma->vm_start));
 	            break;
 	        case PI_MAPPED_TRACE_OFFSET:
 		    if ( MappedData->CPUSelector < driver_info.num_cpus ) {
 		        if (ptr_btrace_buffers[MappedData->CPUSelector] == NULL) {
 		            printk("ptr_btrace_buffers not allocated\n");
-		            return(page);
+		            return(VM_FAULT_OOM);
 		        }    
-		        page = vmalloc_to_page((void*)ptr_btrace_buffers[MappedData->CPUSelector] + (address - vma->vm_start));
+		        page = vmalloc_to_page((void*)ptr_btrace_buffers[MappedData->CPUSelector]
+						+ ((unsigned long)fdata->virtual_address
+						- vma->vm_start));
 //		        PDEBUG("In PI_MAPPED_TRACE_OFFSET for i = %d \n", MappedData->CPUSelector);
                     }
 		    break;
@@ -657,21 +662,24 @@ struct page *pitrace_vma_nopage(struct v
 		    if ( MappedData->CPUSelector < driver_info.num_cpus ) {
 		        if (ptr_mte_buffers[MappedData->CPUSelector] == NULL) {
 		            printk("ptr_mte_buffers not allocated\n");
-		            return(page);
+		            return(VM_FAULT_OOM);
 		        }    
-		        page = vmalloc_to_page((void*)ptr_mte_buffers[MappedData->CPUSelector] + (address - vma->vm_start));
+		        page = vmalloc_to_page((void*)ptr_mte_buffers[MappedData->CPUSelector]
+						+ ((unsigned long)fdata->virtual_address
+						- vma->vm_start));
 //		        PDEBUG("In PI_MAPPED_MTE_OFFSET for i = %d \n", MappedData->CPUSelector);
                     }
 		    break;	           
 	        default:
-	           printk("ERROR pitrace_vma_nopage: incorrect offset\n");
-	           return(page);
+	           printk("ERROR pitrace_vma_fault: incorrect offset\n");
+	           return(VM_FAULT_SIGBUS);
 	           break;   
 	}
 	
 	// increment kernel page usage count	
 	get_page(page);
-	return(page);	
+	fdata->page = page;
+	return(0);
 }                                
 
 module_init(pi_init_module);