From 443f984b1a4eecf464b0081820e87e351c5d7c36 Mon Sep 17 00:00:00 2001 From: Christian Hoff Date: Mon, 8 Mar 2021 20:44:14 +0100 Subject: [PATCH] Compile fixes for kernel >= 5.8 With the commit 64fe66e8a95e in the Linux kernel, the member "mmap_sem" in the struct mm_struct was renamed to "mmap_lock". This patch fixes the resulting compile errors. --- binder/binder.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/binder/binder.c b/binder/binder.c index d3829a0..1814084 100644 --- a/binder/binder.c +++ b/binder/binder.c @@ -46,6 +46,9 @@ #include #include #include +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) +#include +#endif #ifdef CONFIG_ANDROID_BINDER_IPC_32BIT #define BINDER_IPC_32BIT 1 @@ -630,7 +633,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate, mm = get_task_mm(proc->tsk); if (mm) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) + mmap_write_lock(mm); +#else down_write(&mm->mmap_sem); +#endif vma = proc->vma; if (vma && mm != proc->vma_vm_mm) { pr_err("%d: vma mm and task mm mismatch\n", @@ -680,7 +687,11 @@ static int binder_update_page_range(struct binder_proc *proc, int allocate, /* vm_insert_page does not seem to increment the refcount */ } if (mm) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) + mmap_write_unlock(mm); +#else up_write(&mm->mmap_sem); +#endif mmput(mm); } return 0; @@ -707,7 +718,11 @@ err_alloc_page_failed: } err_no_vma: if (mm) { +#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 8, 0) + mmap_write_unlock(mm); +#else up_write(&mm->mmap_sem); +#endif mmput(mm); } return -ENOMEM;