From 44e5ba79f515b3cd22d96b4e3ab0f74d5361eb79 Mon Sep 17 00:00:00 2001 From: ssfdust Date: Wed, 24 Jan 2024 12:45:28 +0800 Subject: [PATCH] Fixes for kernel 6.8 --- binder/binder.c | 4 +++- binder/binder_alloc.c | 13 +++++++++++++ binder/deps.c | 8 ++++++-- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/binder/binder.c b/binder/binder.c index 99f47c3..c0f6f12 100644 --- a/binder/binder.c +++ b/binder/binder.c @@ -2236,7 +2236,9 @@ static void binder_deferred_fd_close(int fd) if (!twcb) return; init_task_work(&twcb->twork, binder_do_fd_close); -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0)) + twcb->file = file_close_fd(fd); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)) twcb->file = close_fd_get_file(fd); #elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)) close_fd_get_file(fd, &twcb->file); diff --git a/binder/binder_alloc.c b/binder/binder_alloc.c index aed9c7a..bfdec52 100644 --- a/binder/binder_alloc.c +++ b/binder/binder_alloc.c @@ -235,7 +235,11 @@ 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)) + on_lru = list_lru_del_obj(&binder_alloc_lru, &page->lru); +#else on_lru = list_lru_del(&binder_alloc_lru, &page->lru); +#endif WARN_ON(!on_lru); trace_binder_alloc_lru_end(alloc, index); @@ -286,7 +290,11 @@ free_range: trace_binder_free_lru_start(alloc, index); +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0)) + ret = list_lru_add_obj(&binder_alloc_lru, &page->lru); +#else ret = list_lru_add(&binder_alloc_lru, &page->lru); +#endif WARN_ON(!ret); trace_binder_free_lru_end(alloc, index); @@ -846,8 +854,13 @@ 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)) + on_lru = list_lru_del_obj(&binder_alloc_lru, + &alloc->pages[i].lru); +#else on_lru = list_lru_del(&binder_alloc_lru, &alloc->pages[i].lru); +#endif page_addr = alloc->buffer + i * PAGE_SIZE; binder_alloc_debug(BINDER_DEBUG_BUFFER_ALLOC, "%s: %d: page %d at %pK %s\n", diff --git a/binder/deps.c b/binder/deps.c index 232bded..63accc0 100644 --- a/binder/deps.c +++ b/binder/deps.c @@ -77,7 +77,9 @@ static int (*close_fd_get_file_ptr)(unsigned int fd, struct file **res) #endif = NULL; -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,19,0)) +#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)) 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) @@ -86,7 +88,9 @@ int __close_fd_get_file(unsigned int fd, struct file **res) #endif { if (!close_fd_get_file_ptr) -#if (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)) +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(6,8,0)) + close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("file_close_fd"); +#elif (LINUX_VERSION_CODE >= KERNEL_VERSION(5,11,0)) close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("close_fd_get_file"); #else close_fd_get_file_ptr = kallsyms_lookup_name_wrapper("__close_fd_get_file");