From a73447d3c76138672ebcb33ab315b61fca2e4ea4 Mon Sep 17 00:00:00 2001 From: Nicolas Vazquez <67982635+nivzqz@users.noreply.github.com> Date: Thu, 8 Feb 2024 11:12:19 -0600 Subject: [PATCH] Fix to build with Linux version 6.5 and later (#9) * account for modify get_user_pages prototype for linux version 6.5 and later --- u3v_stream.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/u3v_stream.c b/u3v_stream.c index 609dc68..de00ecc 100644 --- a/u3v_stream.c +++ b/u3v_stream.c @@ -1355,22 +1355,20 @@ static struct page **lock_user_pages(struct u3v_stream *stream, #else down_read(¤t->mm->mmap_lock); #endif - /* will store a page locked array of physical pages in pages var */ - ret = get_user_pages( + +/* will store a page locked array of physical pages in pages var */ #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) - current, - current->mm, -#endif - uaddr, - num_pages, -#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) - WRITE, - 0, /* Don't force */ + ret = get_user_pages(current, current->mm, uaddr, num_pages, WRITE, 0, pages, NULL); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0) + ret = get_user_pages(uaddr, num_pages, WRITE, 0, pages, NULL); +#elif LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0) + // replace get_user_pages() write/force parameters with gup_flags in Commit 768ae30 + ret = get_user_pages(uaddr, num_pages, FOLL_WRITE, pages, NULL); #else - FOLL_WRITE, + // vmas parameter removed from get_user_pages() in Commit 54d0206 + ret = get_user_pages(uaddr, num_pages, FOLL_WRITE, pages); #endif - pages, - NULL); + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 10, 0) up_read(¤t->mm->mmap_sem); #else