aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--kernel/relay.c24
1 files changed, 9 insertions, 15 deletions
diff --git a/kernel/relay.c b/kernel/relay.c
index 7c0373322f18..d080b9d161a7 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -37,37 +37,31 @@ static void relay_file_mmap_close(struct vm_area_struct *vma)
37} 37}
38 38
39/* 39/*
40 * nopage() vm_op implementation for relay file mapping. 40 * fault() vm_op implementation for relay file mapping.
41 */ 41 */
42static struct page *relay_buf_nopage(struct vm_area_struct *vma, 42static int relay_buf_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
43 unsigned long address,
44 int *type)
45{ 43{
46 struct page *page; 44 struct page *page;
47 struct rchan_buf *buf = vma->vm_private_data; 45 struct rchan_buf *buf = vma->vm_private_data;
48 unsigned long offset = address - vma->vm_start; 46 pgoff_t pgoff = vmf->pgoff;
49 47
50 if (address > vma->vm_end)
51 return NOPAGE_SIGBUS; /* Disallow mremap */
52 if (!buf) 48 if (!buf)
53 return NOPAGE_OOM; 49 return VM_FAULT_OOM;
54 50
55 page = vmalloc_to_page(buf->start + offset); 51 page = vmalloc_to_page(buf->start + (pgoff << PAGE_SHIFT));
56 if (!page) 52 if (!page)
57 return NOPAGE_OOM; 53 return VM_FAULT_SIGBUS;
58 get_page(page); 54 get_page(page);
55 vmf->page = page;
59 56
60 if (type) 57 return 0;
61 *type = VM_FAULT_MINOR;
62
63 return page;
64} 58}
65 59
66/* 60/*
67 * vm_ops for relay file mappings. 61 * vm_ops for relay file mappings.
68 */ 62 */
69static struct vm_operations_struct relay_file_mmap_ops = { 63static struct vm_operations_struct relay_file_mmap_ops = {
70 .nopage = relay_buf_nopage, 64 .fault = relay_buf_fault,
71 .close = relay_file_mmap_close, 65 .close = relay_file_mmap_close,
72}; 66};
73 67