diff options
author | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-06-25 03:25:25 -0400 |
---|---|---|
committer | Bjoern Brandenburg <bbb@mpi-sws.org> | 2012-07-23 06:05:39 -0400 |
commit | d85fc52b409dc4007ab848388c3e096eec85268d (patch) | |
tree | c872758f6f76f6d4668f2f885345cc7deaf7125f | |
parent | b83f375cdcaf08055ff8bff9d76944edca4202dc (diff) |
control page: use vm_insert_page() instead of remap_pfn_range()
vm_insert_page() is the simpler and preferred interface for remapping
individual pages and includes additional error checks. It suffices for
our purposes, so let's use it instead.
-rw-r--r-- | litmus/ctrldev.c | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/litmus/ctrldev.c b/litmus/ctrldev.c index 6677a67cc945..294d134a4a6d 100644 --- a/litmus/ctrldev.c +++ b/litmus/ctrldev.c | |||
@@ -30,27 +30,19 @@ static int alloc_ctrl_page(struct task_struct *t) | |||
30 | static int map_ctrl_page(struct task_struct *t, struct vm_area_struct* vma) | 30 | static int map_ctrl_page(struct task_struct *t, struct vm_area_struct* vma) |
31 | { | 31 | { |
32 | int err; | 32 | int err; |
33 | unsigned long pfn; | ||
34 | 33 | ||
35 | struct page* ctrl = virt_to_page(tsk_rt(t)->ctrl_page); | 34 | struct page* ctrl = virt_to_page(tsk_rt(t)->ctrl_page); |
36 | 35 | ||
37 | /* Increase ref count. Is decreased when vma is destroyed. */ | ||
38 | get_page(ctrl); | ||
39 | |||
40 | /* compute page frame number */ | ||
41 | pfn = page_to_pfn(ctrl); | ||
42 | |||
43 | TRACE_CUR(CTRL_NAME | 36 | TRACE_CUR(CTRL_NAME |
44 | ": mapping %p (pfn:%lx, %lx) to 0x%lx (prot:%lx)\n", | 37 | ": mapping %p (pfn:%lx) to 0x%lx (prot:%lx)\n", |
45 | tsk_rt(t)->ctrl_page, pfn, page_to_pfn(ctrl), vma->vm_start, | 38 | tsk_rt(t)->ctrl_page,page_to_pfn(ctrl), vma->vm_start, |
46 | vma->vm_page_prot); | 39 | vma->vm_page_prot); |
47 | 40 | ||
48 | /* Map it into the vma. Make sure to use PAGE_SHARED, otherwise | 41 | /* Map it into the vma. */ |
49 | * userspace actually gets a copy-on-write page. */ | 42 | err = vm_insert_page(vma, vma->vm_start, ctrl); |
50 | err = remap_pfn_range(vma, vma->vm_start, pfn, PAGE_SIZE, PAGE_SHARED); | ||
51 | 43 | ||
52 | if (err) | 44 | if (err) |
53 | TRACE_CUR(CTRL_NAME ": remap_pfn_range() failed (%d)\n", err); | 45 | TRACE_CUR(CTRL_NAME ": vm_insert_page() failed (%d)\n", err); |
54 | 46 | ||
55 | return err; | 47 | return err; |
56 | } | 48 | } |