You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
kmod-anbox/SOURCES/0001-Fix-build-on-RedHat-9....

173 lines
6.5 KiB

4 months ago
From 9757b9e6b0d396163ae7e25d45ac80aae393e720 Mon Sep 17 00:00:00 2001
From: tigro <tigro@msvsphere-os.ru>
Date: Mon, 21 Oct 2024 12:06:03 +0300
Subject: [PATCH] Fix build on RedHat 9.5 kernel
---
ashmem/ashmem.c | 4 ++--
binder/binder.c | 10 +++++-----
binder/binder_alloc.c | 10 +++++-----
binder/deps.c | 8 ++++----
4 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/ashmem/ashmem.c b/ashmem/ashmem.c
index df9cf90..009a04e 100644
--- a/ashmem/ashmem.c
+++ b/ashmem/ashmem.c
@@ -390,7 +390,7 @@ static int ashmem_mmap(struct file *file, struct vm_area_struct *vma)
ret = -EPERM;
goto out;
}
- #if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 3, 0)
+ #if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 14, 0)
vm_flags_clear(vma, calc_vm_may_flags(~asma->prot_mask));
#else
vma->vm_flags &= ~calc_vm_may_flags(~asma->prot_mask);
@@ -897,7 +897,7 @@ static int __init ashmem_init(void)
} else {
return -ENOMEM;
}
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
register_shrinker(&ashmem_shrinker, "android-ashmem");
#else
register_shrinker(&ashmem_shrinker);
diff --git a/binder/binder.c b/binder/binder.c
index c0f6f12..3137760 100644
--- a/binder/binder.c
+++ b/binder/binder.c
@@ -2238,7 +2238,7 @@ static void binder_deferred_fd_close(int fd)
init_task_work(&twcb->twork, binder_do_fd_close);
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0))
twcb->file = file_close_fd(fd);
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
twcb->file = close_fd_get_file(fd);
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
close_fd_get_file(fd, &twcb->file);
@@ -4111,12 +4111,12 @@ static int binder_wait_for_work(struct binder_thread *thread,
struct binder_proc *proc = thread->proc;
int ret = 0;
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0))
freezer_do_not_count();
#endif
binder_inner_proc_lock(proc);
for (;;) {
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0))
prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE);
#else
prepare_to_wait(&thread->wait, &wait, TASK_INTERRUPTIBLE|TASK_FREEZABLE);
@@ -4137,7 +4137,7 @@ static int binder_wait_for_work(struct binder_thread *thread,
}
finish_wait(&thread->wait, &wait);
binder_inner_proc_unlock(proc);
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(6,1,0))
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,14,0))
freezer_count();
#endif
@@ -5236,7 +5236,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM);
return -EPERM;
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
vm_flags_mod(vma, VM_DONTCOPY | VM_MIXEDMAP, VM_MAYWRITE);
#else
vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
diff --git a/binder/binder_alloc.c b/binder/binder_alloc.c
index bfdec52..d94fe82 100644
--- a/binder/binder_alloc.c
+++ b/binder/binder_alloc.c
@@ -235,7 +235,7 @@ static int binder_update_page_range(struct binder_alloc *alloc, int allocate,
if (page->page_ptr) {
trace_binder_alloc_lru_start(alloc, index);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
on_lru = list_lru_del_obj(&binder_alloc_lru, &page->lru);
#else
on_lru = list_lru_del(&binder_alloc_lru, &page->lru);
@@ -290,7 +290,7 @@ free_range:
trace_binder_free_lru_start(alloc, index);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
ret = list_lru_add_obj(&binder_alloc_lru, &page->lru);
#else
ret = list_lru_add(&binder_alloc_lru, &page->lru);
@@ -854,7 +854,7 @@ void binder_alloc_deferred_release(struct binder_alloc *alloc)
if (!alloc->pages[i].page_ptr)
continue;
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
on_lru = list_lru_del_obj(&binder_alloc_lru,
&alloc->pages[i].lru);
#else
@@ -1024,7 +1024,7 @@ enum lru_status binder_alloc_free_page(struct list_head *item,
if (vma) {
trace_binder_unmap_user_start(alloc, index);
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
zap_page_range_single(vma, page_addr, PAGE_SIZE, NULL);
#else
zap_page_range(vma, page_addr, PAGE_SIZE);
@@ -1110,7 +1110,7 @@ int binder_alloc_shrinker_init(void)
} else {
ret = -ENOMEM;
}
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(6,0,0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
ret = register_shrinker(&binder_shrinker, "android-binder");
#else
ret = register_shrinker(&binder_shrinker);
diff --git a/binder/deps.c b/binder/deps.c
index 63accc0..c8e7db1 100644
--- a/binder/deps.c
+++ b/binder/deps.c
@@ -70,7 +70,7 @@ static unsigned long kallsyms_lookup_name_wrapper(const char *name)
#endif
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
static struct file *(*close_fd_get_file_ptr)(unsigned int fd)
#else
static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res)
@@ -79,7 +79,7 @@ static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res)
#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0))
struct file *file_close_fd(unsigned int fd)
-#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
struct file *close_fd_get_file(unsigned int fd)
#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0))
int close_fd_get_file(unsigned int fd, struct file **res)
@@ -96,7 +96,7 @@ int __close_fd_get_file(unsigned int fd, struct file **res)
close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("__close_fd_get_file");
#endif
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
return close_fd_get_file_ptr(fd);
#else
return close_fd_get_file_ptr(fd, res);
@@ -168,7 +168,7 @@ int task_work_add(struct task_struct *task, struct callback_head *work,
return task_work_add_ptr(task, work, notify);
}
-#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,3,0))
+#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,14,0))
static void (*zap_page_range_single_ptr)(struct vm_area_struct *, unsigned long, unsigned long, struct zap_details *) = NULL;
void zap_page_range_single(struct vm_area_struct *vma, unsigned long address, unsigned long size, struct zap_details *details)
--
2.47.0