mirror of
https://github.com/SCST-project/scst.git
synced 2026-08-19 05:36:22 +00:00
scst: Fix the get_user_pages() backport for kernel versions >= v4.4.168
The get_user_pages() calling convention has been changed in kernel v4.4.168. Make sure that SCST passes the correct arguments. git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@7997 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
+47
-4
@@ -664,19 +664,62 @@ static inline bool list_entry_in_list(const struct list_head *entry)
|
||||
|
||||
/* <linux/kernel.h> */
|
||||
|
||||
#if (!defined(CONFIG_SUSE_KERNEL) && \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0)) || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
|
||||
#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,
|
||||
int write, int force,
|
||||
unsigned int gup_flags,
|
||||
struct page **pages,
|
||||
struct vm_area_struct **vmas)
|
||||
{
|
||||
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
|
||||
#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);
|
||||
}
|
||||
#define get_user_pages get_user_pages_backport
|
||||
#endif
|
||||
|
||||
/* <linux/preempt.h> */
|
||||
|
||||
@@ -1274,15 +1274,8 @@ static int dev_user_map_buf(struct scst_user_cmd *ucmd, unsigned long ubuff,
|
||||
(ucmd->cmd != NULL) ? ucmd->cmd->bufflen : -1);
|
||||
|
||||
down_read(&tsk->mm->mmap_sem);
|
||||
#if (!defined(CONFIG_SUSE_KERNEL) && \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 9, 0)) || \
|
||||
LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
|
||||
rc = get_user_pages(ubuff, ucmd->num_data_pages, 1/*writable*/,
|
||||
0/*don't force*/, ucmd->data_pages, NULL);
|
||||
#else
|
||||
rc = get_user_pages(ubuff, ucmd->num_data_pages, FOLL_WRITE,
|
||||
ucmd->data_pages, NULL);
|
||||
#endif
|
||||
up_read(&tsk->mm->mmap_sem);
|
||||
|
||||
/* get_user_pages() flushes dcache */
|
||||
|
||||
Reference in New Issue
Block a user