diff options
author | Suman Anna <s-anna@ti.com> | 2017-02-14 16:08:02 -0600 |
---|---|---|
committer | Sam Nelson <sam.nelson@ti.com> | 2017-02-16 06:07:06 -0500 |
commit | cf3e96041979b18ee272e2f221a880809342439b (patch) | |
tree | 887ce2497e9ce24633f7849283cc402cc56ff6f2 | |
parent | db57f481c01c4c39946707d06d04f3039bb5a9d3 (diff) | |
download | linuxutils-cf3e96041979b18ee272e2f221a880809342439b.tar.gz |
cmemk: Fix usage of get_user_pages() on 4.6+ kernels
The get_user_pages() function has gone through a bunch of changes
between 4.4 and 4.9 Linux kernel versions. The function first lost
the first two arguments - the task_struct and the mm_struct pointers
in 4.6 kernel (and got replaced with a new get_user_pages_remote()
function)[1][2], and then replaced two other arguments 'write' and
'force' with a single 'gup_flags' argument in 4.9 kernel[3][4]. Fix
the current get_user_pages() invocation in cmemk kernel with the
appropriate functions to build properly for these kernels.
[1]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=1e9877902dc7e11d2be038371c6fbf2dfcd469d7
[2]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=c12d2da56d0e07d230968ee2305aaa86b93a6832
[3]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=768ae309a96103ed02eb1e111e838c87854d8b51
[4]
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/include/linux/mm.h?id=9beae1ea89305a9667ceaab6d0bf46a045ad71e7
Signed-off-by: Suman Anna <s-anna@ti.com>
Signed-off-by: Sam Nelson <sam.nelson@ti.com>
-rw-r--r-- | src/cmem/module/cmemk.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/cmem/module/cmemk.c b/src/cmem/module/cmemk.c index b1e39d4..1aa2a0b 100644 --- a/src/cmem/module/cmemk.c +++ b/src/cmem/module/cmemk.c @@ -650,8 +650,16 @@ static phys_addr_t get_phys(void *virtp) struct page *pages; down_read(¤t->mm->mmap_sem); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 9, 0)) + res = get_user_pages_remote(current, current->mm, virt, nr_pages, + FOLL_WRITE, &pages, NULL); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 6, 0)) + res = get_user_pages_remote(current, current->mm, virt, nr_pages, + 1, 0, &pages, NULL); +#else res = get_user_pages(current, current->mm, virt, nr_pages, 1, 0, &pages, NULL); +#endif up_read(¤t->mm->mmap_sem); if (res == nr_pages) { |