File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -193,25 +193,23 @@ mspec_close(struct vm_area_struct *vma)
193193}
194194
195195/*
196- * mspec_nopfn
196+ * mspec_fault
197197 *
198198 * Creates a mspec page and maps it to user space.
199199 */
200- static unsigned long
201- mspec_nopfn (struct vm_area_struct * vma , unsigned long address )
200+ static int
201+ mspec_fault (struct vm_area_struct * vma , struct vm_fault * vmf )
202202{
203203 unsigned long paddr , maddr ;
204204 unsigned long pfn ;
205- int index ;
205+ pgoff_t index = vmf -> pgoff ;
206206 struct vma_data * vdata = vma -> vm_private_data ;
207207
208- BUG_ON (address < vdata -> vm_start || address >= vdata -> vm_end );
209- index = (address - vdata -> vm_start ) >> PAGE_SHIFT ;
210208 maddr = (volatile unsigned long ) vdata -> maddr [index ];
211209 if (maddr == 0 ) {
212210 maddr = uncached_alloc_page (numa_node_id (), 1 );
213211 if (maddr == 0 )
214- return NOPFN_OOM ;
212+ return VM_FAULT_OOM ;
215213
216214 spin_lock (& vdata -> lock );
217215 if (vdata -> maddr [index ] == 0 ) {
@@ -231,13 +229,20 @@ mspec_nopfn(struct vm_area_struct *vma, unsigned long address)
231229
232230 pfn = paddr >> PAGE_SHIFT ;
233231
234- return pfn ;
232+ /*
233+ * vm_insert_pfn can fail with -EBUSY, but in that case it will
234+ * be because another thread has installed the pte first, so it
235+ * is no problem.
236+ */
237+ vm_insert_pfn (vma , (unsigned long )vmf -> virtual_address , pfn );
238+
239+ return VM_FAULT_NOPAGE ;
235240}
236241
237242static struct vm_operations_struct mspec_vm_ops = {
238243 .open = mspec_open ,
239244 .close = mspec_close ,
240- .nopfn = mspec_nopfn
245+ .fault = mspec_fault ,
241246};
242247
243248/*
You can’t perform that action at this time.
0 commit comments