scst_user: Port to Linux kernel v6.5

Support for the following mm layer changes in the Linux kernel v6.5:

- 54d020692b34 ("mm/gup: remove unused vmas parameter from
  get_user_pages()")
This commit is contained in:
Gleb Chesnokov
2023-07-04 18:22:56 +03:00
parent 7a1ea234e7
commit a62b094f4f
2 changed files with 35 additions and 46 deletions

View File

@@ -572,60 +572,49 @@ static inline u32 int_sqrt64(u64 x)
}
#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(6, 5, 0)
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages)
{
#if LINUX_VERSION_CODE >> 8 == KERNEL_VERSION(4, 4, 0) >> 8 && \
LINUX_VERSION_CODE >= KERNEL_VERSION(4, 4, 168)
/*
* See also commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.4.168.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
/*
* See also commit 8e50b8b07f46 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.4.168.
*/
return get_user_pages(current, current->mm, start, nr_pages, gup_flags,
pages, vmas);
}
#define get_user_pages get_user_pages_backport
#elif !defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
/*
* See also commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions")
* # v4.6.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
const bool write = gup_flags & FOLL_WRITE;
const bool force = 0;
WARN_ON_ONCE(gup_flags & ~FOLL_WRITE);
return get_user_pages(current, current->mm, start, nr_pages, write,
force, pages, vmas);
}
#define get_user_pages get_user_pages_backport
pages, NULL);
#elif (!defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
/*
* See also commit 768ae309a961 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.9.
*/
static inline long get_user_pages_backport(unsigned long start,
unsigned long nr_pages,
unsigned int gup_flags,
struct page **pages,
struct vm_area_struct **vmas)
{
const bool write = gup_flags & FOLL_WRITE;
const bool force = 0;
WARN_ON_ONCE(gup_flags & ~FOLL_WRITE);
return get_user_pages(start, nr_pages, write, force, pages, vmas);
#if !defined(CONFIG_SUSE_KERNEL) && \
LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)
/*
* See also commit cde70140fed8 ("mm/gup: Overload get_user_pages() functions")
* # v4.6.
*/
return get_user_pages(current, current->mm, start, nr_pages, write,
force, pages, NULL);
#else
/*
* See also commit 768ae309a961 ("mm: replace get_user_pages() write/force
* parameters with gup_flags") # v4.9.
*/
return get_user_pages(start, nr_pages, write, force, pages, NULL);
#endif
#else
/*
* See also commit 54d020692b34 ("mm/gup: remove unused vmas parameter from
* get_user_pages()") # v6.5.
*/
return get_user_pages(start, nr_pages, gup_flags, pages, NULL);
#endif
}
#define get_user_pages get_user_pages_backport
#endif

View File

@@ -1261,12 +1261,12 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0)
down_read(&tsk->mm->mmap_sem);
rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE,
ucmd->data_pages, NULL);
ucmd->data_pages);
up_read(&tsk->mm->mmap_sem);
#else
mmap_read_lock(tsk->mm);
rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE,
ucmd->data_pages, NULL);
ucmd->data_pages);
mmap_read_unlock(tsk->mm);
#endif