Open choff opened 3 years ago
This seems to work nicely on Fedora 33 with kernel 5.10. However, on Fedora 34 pre-release with kernel 5.11, it doesn't seem like the modules can be built at all. I am not sure if this is an issue with kernel 5.11 or if it is simply because Fedora 34 pre-release is still somewhat buggy, but it would be awesome if you can have a look :)
Oh, and to add a bit more info, dkms was complaining about incompatible gcc/plugin versions when I tried it.
Hello @tommytran732 ,
unfortunately, I cannot invest the time to install Fedora 34 on my machine to duplicate this error... The only kind of help I can offer is to take a look at the error and see if something comes to my mind.. But for this I need the full console output.
Best regards,
Christian
Hi,
Fedora 33 just got updated to kernel 5.11 today and it seems like it broke binder. It is a different error from what I got on Fedora 34 last time, but here are the logs:
`[Tomster@dhcp-172-30-79-244 ~]$ sudo ls -la /dev/{ashmem,binder} [sudo] password for Tomster: ls: cannot access '/dev/binder': No such file or directory crw-------. 1 root root 10, 124 Mar 20 01:08 /dev/ashmem [Tomster@dhcp-172-30-79-244 ~]$ sudo dkms status anbox-ashmem, 1, 5.10.22-200.fc33.x86_64, x86_64: installed anbox-ashmem, 1, 5.10.23-200.fc33.x86_64, x86_64: installed anbox-ashmem, 1, 5.11.7-200.fc33.x86_64, x86_64: installed anbox-binder, 1, 5.10.22-200.fc33.x86_64, x86_64: installed anbox-binder, 1, 5.10.23-200.fc33.x86_64, x86_64: installed [Tomster@dhcp-172-30-79-244 ~]$ sudo dkms install anbox-binder/1
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j12 KERNELRELEASE=5.11.7-200.fc33.x86_64 all KERNEL_SRC=/lib/modules/5.11.7-200.fc33.x86_64/build...(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.11.7-200.fc33.x86_64 (x86_64)
Consult /var/lib/dkms/anbox-binder/1/build/make.log for more information.
[Tomster@dhcp-172-30-79-244 ~]$ cat /var/lib/dkms/anbox-binder/1/build/make.log
cat: /var/lib/dkms/anbox-binder/1/build/make.log: Permission denied
[Tomster@dhcp-172-30-79-244 ~]$ sudo cat /var/lib/dkms/anbox-binder/1/build/make.log
DKMS make.log for anbox-binder-1 for kernel 5.11.7-200.fc33.x86_64 (x86_64)
Sat 20 Mar 2021 01:10:05 AM EDT
make -C /lib/modules/5.11.7-200.fc33.x86_64/build V=0 M=$PWD
make[1]: Entering directory '/usr/src/kernels/5.11.7-200.fc33.x86_64'
CC [M] /var/lib/dkms/anbox-binder/1/build/deps.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o
/var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_get_unused_fd_flags’:
/var/lib/dkms/anbox-binder/1/build/binder.c:447:9: error: implicit declaration of function ‘__alloc_fd’ [-Werror=implicit-function-declaration]
447 | return alloc_fd(files, 0, rlim_cur, flags);
| ^~~~~~
/var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_fd_install’:
/var/lib/dkms/anbox-binder/1/build/binder.c:457:3: error: implicit declaration of function ‘fd_install’; did you mean ‘fd_install’? [-Werror=implicit-function-declaration]
457 | fd_install(proc->files, fd, file);
| ^~~~
| fd_install
/var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘task_close_fd’:
/var/lib/dkms/anbox-binder/1/build/binder.c:470:11: error: implicit declaration of function ‘close_fd’; did you mean ‘close_fd’? [-Werror=implicit-function-declaration]
470 | retval = __close_fd(proc->files, fd);
| ^~~~~~
| close_fd
/var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘binder_mmap’:
/var/lib/dkms/anbox-binder/1/build/binder.c:3501:16: error: implicit declaration of function ‘get_files_struct’; did you mean ‘put_files_struct’? [-Werror=implicit-function-declaration]
3501 | proc->files = get_files_struct(current);
| ^~~~
| put_files_struct
cc1: some warnings being treated as errors
make[2]: [scripts/Makefile.build:279: /var/lib/dkms/anbox-binder/1/build/binder.o] Error 1
make[1]: [Makefile:1807: /var/lib/dkms/anbox-binder/1/build] Error 2
make[1]: Leaving directory '/usr/src/kernels/5.11.7-200.fc33.x86_64'
make: *** [Makefile:8: all] Error 2`
Hello @tommytran732 ,
yes, indeed it seems like some kernel changes broke the build. Unfortunately, I am travelling tomorrow and will be away for the next 3 weeks. Today I need to pack my things and it is unlikely that I find the time to look into it. I will try to have a look after I return.
Best regards,
Christian
Is there any update on this? I'm too facing the same issue
Hello @vikashraghavan ,
no, no update on this. And I don't know when / if I will look into it at all because kernel 5.11 is not yet available for Raspsberry Pi OS. If you have the skills (or someone else who is affected), you could try to fix it yourself and set a PR to my branch, which I will be happy to integrate. I cannot give any commitment if I find time for it at all.
Best regards,
Christian
Hi @chrihoff
I found some patch docs related to the error
__alloc_fd __fd_install __close_fd
I'm not sure whether it would be useful or not. Any assistance would be really helpful if you think it's a simple bug to fix.
Hello @vikashraghavan ,
I just had a look at these kernel patches. The links are helpful indeed and pointed me in the right direction. So, it seems like the functions alloc_fd(), __fd_install() and close_fd() were removed from the kernel without replacement. However, Binder was refactored upstream upstream in 2018 (see http://driverdev.linuxdriverproject.org/pipermail/driverdev-devel/2018-August/125424.html). Since that refactoring, binder no longer needs to use these three functions and can use standard functions instead.
So the task here would be to backport this refactoring to binder also to anbox-modules. That should fix those issues. Unfortunately, this refactoring is quite complex and involves some restructuring, so I am not sure how easy it would be to backport it.
Then the only problem remaining would be the compile error in 'binder_mmap' that @tommytran732 reported. As of now, I cannot tell what the root cause of this other error is or how to fix it as I simply didn't have the time to look into it.
Best regards,
Christian
hey @chrihoff,
I found a binder code for latest kernels binder.c
Is something possible to do with these?
Hello @vikashraghavan ,
well, you could try to replace binder.c in anbox-modules by the latest one you found... Maybe you'd need to copy over other files, too... But this is not a generic solution for every user as anbox-modules were designed to be compilable against old kernels also. So, there is a lot of compatibility code in there that is missing in the version of binder.c for the latest kernel.
Best regards,
Christian
Can you please mention which are the other files to be copied? should all the files in the previous directory should be used?
Hello @vikashraghavan ,
unfortunately, I cannot tell and I don't have time to look into it, either. I guess you'd need to try yourself. I am not sure how well this approach works at all...
Best regards,
Christian
Stuck over here while trying to compile latest binder module
DKMS make.log for anbox-binder-1 for kernel 5.11.18-300.fc34.x86_64 (x86_64) Mon May 10 06:42:54 PM IST 2021 make -C /lib/modules/5.11.18-300.fc34.x86_64/build V=0 M=$PWD make[1]: Entering directory '/usr/src/kernels/5.11.18-300.fc34.x86_64' CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o CC [M] /var/lib/dkms/anbox-binder/1/build/binder_alloc.o LD [M] /var/lib/dkms/anbox-binder/1/build/binder_linux.o MODPOST /var/lib/dkms/anbox-binder/1/build/Module.symvers ERROR: modpost: "can_nice" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "mmput_async" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "task_work_add" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "security_binder_transaction" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "security_binder_transfer_file" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "security_binder_set_context_mgr" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "security_binder_transfer_binder" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "close_fd_get_file" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! ERROR: modpost: "zap_page_range" [/var/lib/dkms/anbox-binder/1/build/binder_linux.ko] undefined! make[2]: [scripts/Makefile.modpost:111: /var/lib/dkms/anbox-binder/1/build/Module.symvers] Error 1 make[2]: Deleting file '/var/lib/dkms/anbox-binder/1/build/Module.symvers' make[1]: [Makefile:1725: modules] Error 2 make[1]: Leaving directory '/usr/src/kernels/5.11.18-300.fc34.x86_64' make: [Makefile:9: all] Error 2
Is there some changes should be done to deps.c? I tried to compile both with and without deps.c (I just suspect it... I really don't know why that file is used)
Any suggestions to direct me in the right way would be really helpful !!!
hi,
make -C /lib/modules/5.13.0-21-generic/build V=0 M=$PWD
make[1]: 进入目录“/usr/src/linux-headers-5.13.0-21-generic”
CC [M] /var/lib/dkms/anbox-binder/1/build/deps.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder_alloc.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binderfs.o
In file included from ././include/linux/kconfig.h:5,
from |
#define CONFIG_ANDROID_BINDER_DEVICES "" |
---|
Any chance to look at @Catiks problem ? I had the exactly same issue on ubuntu 21.10. Maybe something related to https://patchwork.kernel.org/project/linux-nfs/patch/20210924175441.7943-16-casey@schaufler-ca.com/ ?
Hello @enz0nun3s15 and @Catiks ,
to me it looks like you are trying to compile anbox-modules even though binder and ashmem are already compiled with your kernel. But anbox-modules are intended only for the corner case that the kernel of your distribution doesn't include binder and ashmem already. Ubuntu 21.10 and also earlier versions include binder and ashmem in their kernel image, so no need to use anbox-modules.
Best regards,
Christian
Actually I was trying to install it in a server with ubuntu server with custom kernel which hasn't the binder installed - there is no /lib/modules/5.13.0-22-X/kernel/drivers/android/ (I tried both Azure and Oracle). Any idea of how to handle it ?
Hello @enz0nun3s15 ,
binder and ashmem are not compiled as kernel modules anymore. Instead, they are built into the main kernel (vmlinux). Therefore, you cannot find binder and ashmem under drivers/android. The only way to check if you kernel has binder and ashmem is to check the kernel config. I suppose that is the case, both because of the error message you see when compiling anbox-modules and then also because you are running Ubuntu (where the default kernel comes with binder and ashmem).
Best regards,
Christian
Actually I was trying to install it in a server with ubuntu server with custom kernel which hasn't the binder installed - there is no /lib/modules/5.13.0-22-X/kernel/drivers/android/ (I tried both Azure and Oracle). Any idea of how to handle it ?
If you are trying to use anbox try this anbox command:
anbox system-info | grep -E 'name|version|binder|ashmem'
output should be printing something like this:
binder: true
ashmem: true
best regards SI
Managed to build ashmem but got error on binder.
DKMS make.log for anbox-binder-1 for kernel 5.13.0-1028-oracle (aarch64)
Mon Jun 20 07:33:45 UTC 2022
make -C /lib/modules/5.13.0-1028-oracle/build V=0 M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-5.13.0-1028-oracle'
CC [M] /var/lib/dkms/anbox-binder/1/build/deps.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder_alloc.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binderfs.o
In file included from ././include/linux/kconfig.h:5,
from |
#define CONFIG_ANDROID_BINDER_DEVICES "" |
---|
In file included from ././include/linux/kconfig.h:5,
from |
#define CONFIG_ANDROID_BINDER_DEVICES "" |
---|
It is very likely that you are seeing these errors because binder is already part of your current kernel. In that case, you don't have to (and should not!) compile binder from anbox-modules. Please check your kernel config to confirm. anbox-modules is intended only for the case that your distribution provides a kernel that doesn't enable ashmem and binder.
I tried building it but throws ERROR: modpost: "kallsyms_lookup_name" officially.
So I tried your fork to build.
heres a result of grep of "BINDER" in my current kernel config
CONFIG_ANDROID_BINDER_IPC=m CONFIG_ANDROID_BINDERFS=m CONFIG_ANDROID_BINDER_DEVICES=""
Thanks.
Thanks and that proves that you already have Binder. You can ignore "BINDER_IPC_SELFTEST" as that is just for debugging. The important think is that "BINDER_IPC" and "BINDERFS" are set. As they are compiled as kernel modules (since the value of the options is 'm'), you have to load these kernel modules with 'modprobe' before you can use them.
I assume that you also have ashmem support in your kernel since Binder and Ashmem are usually enabled together. So, there should be no reason for you to use anbox-modules.
Thank you. When I try sudo modprobe binder_linux and ashmem It throws a modprobe: FATAL: Module binder_linux not found in directory /lib/modules/5.13.0-1028-oracle
You are welcome :-)
This is a strange error message - clearly, your kernel was built with binder, so you should be able to load it. Maybe you are missing an RPM / Debian package that contains these extra kernel modules; that would be the only obvious explanation I have. If that doesn't help, I'm afraid you'll have to ask your distribution maintainers for advice.
Yeah I think so too, maybe it was removed or wahtever purposely by oracle. Ill try to built a kernel if possible or roll back to 18.04. Thanks again. Cheers.
Thank you. When I try sudo modprobe binder_linux and ashmem It throws a modprobe: FATAL: Module binder_linux not found in directory /lib/modules/5.13.0-1028-oracle
Are you sure that it is in your kernel as a module? ..as far as i know module compatibility for the android section has been removed in newer kernels! If it is build as module i guess it should be already loaded in your kernel without the module way.
Can you check the output of:
ls -1 /dev/{ashmem,binder} && uname -a
Are you using this kernel ?: https://github.com/oracle/linux-uek
@SoulInfernoDE , you are right; I forgot. In newer kernels (and I think this includes version 5.13), binder cannot be built as a kernel module anymore as it uses functions from the Linux kernel that are not available to kernel modules. So, probably binder and ashmem are compiled into your kernel. You can try to check /dev/ashmem and mount binderfs to double check.
Hello, and thank you.
This is the output of ls -1 /dev/{ashmem,binder} && uname -a
ls: cannot access '/dev/ashmem': No such file or directory ls: cannot access '/dev/binder': No such file or directory Linux a1-instance 5.13.0-1028-oracle #33~20.04.1-Ubuntu SMP Mon May 2 03:56:22 UTC 2022 aarch64 aarch64 aarch64 GNU/Linux
No, Its the kernel that come off with oracles ubuntu os for their vps.
I see... And what I read was that ashmem and binder were once compiled as kernel modules in Ubuntu. Who knows what kernel patches Oracle and Ubuntu have applied - they might also have patched their kernel such that ashmem and binder can still be compiled as modules.
As the modules have been compile (the kernel config shows this), but cannot be loaded, I suspect that they can either be installed as a separate Debian package or that they have been accidentally removed.
@datsoy I really think the kernel .config is malformed due to no ashmem and binder present. I would recommend to recompile the kernel from the oracle os. I guess you are using the oracle os and as far as i know they are using their UEK kernel. https://github.com/oracle/linux-uek
Here is a write up how i did compile my kernel: https://github.com/anbox/anbox-modules/issues/75#issuecomment-794079944
If it is a debian based system with apt manager you can try my script to build it: https://github.com/SoulInfernoDE/compile-kernel-from-source
compile-from-source.sh
Im not sure where to locate the correct kernel source for your linux system. So you may need to search a bit for yourself. In most linux systems the original kernel from kernel.org still works. But if there is a customized one you could try to find that source code and use that instead of the one located at kernel.org.
best regards
Thank you, I'll check them out.
My system shows, Ubuntu 20.04.4 LTS aarch64 5.13.0-1028-oracle
and upon searching I find This Im not sure if its the correct source though.
As an average user, and new to this, I will read and search more, before trying this out and if time permits. Ill let you know, maybe creating issue on your git.
I really appreciate all the help. Thank you.
Some basic information to kernel building and installation:
sudo update-grub
afterwards:cat /etc/default/grub | grep GRUB_TIMEOUT
@datsoy i rewrote my script for you. :heart_on_fire:
Please have a look at:
How to use it:
The source code will be pulled with apt source from the ubuntu repository with the oracle branch… ..you need to enable source code sources in your system settings first:
Hi, thanks for the updates. Currently i am running debian on a surface Linux 5.19.4-surface
.
By checkout this pr i get the following.
sudo dkms install anbox-binder/1
works
sudo dkms install anbox-binder/1
does not work.
The output of the command is:
Kernel preparation unnecessary for this kernel. Skipping...
Building module:
cleaning build area...
make -j8 KERNELRELEASE=5.19.4-surface all KERNEL_SRC=/lib/modules/5.19.4-surface/build...(bad exit status: 2)
Error! Bad return status for module build on kernel: 5.19.4-surface (x86_64)
Consult /var/lib/dkms/anbox-binder/1/build/make.log for more information.
The output of make.log:
DKMS make.log for anbox-binder-1 for kernel 5.19.4-surface (x86_64)
Wed 31 Aug 2022 03:13:57 PM CEST
make -C /lib/modules/5.19.4-surface/build V=0 M=$PWD
make[1]: Entering directory '/usr/src/linux-headers-5.19.4-surface'
warning: the compiler differs from the one used to build the kernel
The kernel was built by: gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
You are using: gcc (Debian 10.2.1-6) 10.2.1 20210110
CC [M] /var/lib/dkms/anbox-binder/1/build/deps.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binder_alloc.o
CC [M] /var/lib/dkms/anbox-binder/1/build/binderfs.o
/var/lib/dkms/anbox-binder/1/build/deps.c:76:5: error: conflicting types for ‘close_fd_get_file’
76 | int close_fd_get_file(unsigned int fd, struct file **res)
| ^~~~~~~~~~~~~~~~~
In file included from /var/lib/dkms/anbox-binder/1/build/deps.c:3:
./include/linux/fdtable.h:128:21: note: previous declaration of ‘close_fd_get_file’ was here
128 | extern struct file *close_fd_get_file(unsigned int fd);
| ^~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:249: /var/lib/dkms/anbox-binder/1/build/deps.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/var/lib/dkms/anbox-binder/1/build/binder.c: In function ‘binder_deferred_fd_close’:
/var/lib/dkms/anbox-binder/1/build/binder.c:2240:2: error: too many arguments to function ‘close_fd_get_file’
2240 | close_fd_get_file(fd, &twcb->file);
| ^~~~~~~~~~~~~~~~~
In file included from /var/lib/dkms/anbox-binder/1/build/binder.c:45:
./include/linux/fdtable.h:128:21: note: declared here
128 | extern struct file *close_fd_get_file(unsigned int fd);
| ^~~~~~~~~~~~~~~~~
make[2]: *** [scripts/Makefile.build:249: /var/lib/dkms/anbox-binder/1/build/binder.o] Error 1
make[1]: *** [Makefile:1853: /var/lib/dkms/anbox-binder/1/build] Error 2
make[1]: Leaving directory '/usr/src/linux-headers-5.19.4-surface'
make: *** [Makefile:8: all] Error 2
Hello Rick,
yes, for kernel 5.19 there is currently an open pull request, which I first have to review and then merge into my branch: https://github.com/choff/anbox-modules/pull/4 . Feel free to try it out and let me know the result.
Best regards,
Christian
Message ID: @.***
Hey, just tried the fork, can confirm it works
Thanks! I can also confirm that for kernel 5.19 the pull request choff#4 works.
@choff Is this PR up-to-date? Happy to merge it
Hello @morphis ,
yes, the PR is up to date. After my original fixes (which fixed the compilation for kernel versions up to 5.13), I also received fixes for version 5.15 and 5.19 by the community (thank you all!). They are part of this PR, too.
Best regards,
Christian
Hello @morphis,
one last thing. I think this PR will break compilation with old kernels (older than v5.12 or v5.11). The reason for this is that I updated the code for binder inside anbox-modules to the upstream state of binder from kernel 5.12 or 5.11 (cannot exactly remember which version I used).
The main reason for this update of the binder inside anbox-modules was that the binder code shipped with anbox-modules was outdated. The upstream version of binder has received many fixes meanwhile. Also, the function signature of many functions used by binder changed in newer kernel versions and I remember that it was very hard to backport these changes to the outdated binder code in anbox-modules. This is why I decided to update binder.
There is also an "old-kernel" branch in my GIIT repo that works (only) with older kernels up to 5.11. On that branch, I did not update the code of binder.
Best regards,
Christian
Hi @choff,
FYI: this is a possible fix for kernel 6.0 based on this request. It compiles, but is currently untested:
diff -ruNp a/ashmem/ashmem.c b/ashmem/ashmem.c
--- a/ashmem/ashmem.c
+++ b/ashmem/ashmem.c
@@ -874,7 +874,11 @@ static int __init ashmem_init(void)
return ret;
}
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+ register_shrinker(&ashmem_shrinker, "ashmem-shrinker");
+#else
register_shrinker(&ashmem_shrinker);
+#endif
return 0;
}
diff -ruNp a/binder/binder_alloc.c b/binder/binder_alloc.c
--- a/binder/binder_alloc.c
+++ b/binder/binder_alloc.c
@@ -23,6 +23,7 @@
#include <linux/uaccess.h>
#include <linux/highmem.h>
#include <linux/sizes.h>
+#include <linux/version.h>
#include "binder_alloc.h"
#include "binder_trace.h"
@@ -1079,7 +1080,11 @@ int binder_alloc_shrinker_init(void)
int ret = list_lru_init(&binder_alloc_lru);
if (ret == 0) {
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(6, 0, 0)
+ ret = register_shrinker(&binder_shrinker, "binder-shrinker");
+#else
ret = register_shrinker(&binder_shrinker);
+#endif
if (ret)
list_lru_destroy(&binder_alloc_lru);
}
Various changes were made to get the kernel modules for Anbox working with kernels 5.7 and later:
I know that ashmem and binder are now upstream in the kernel, but there are still many distributions that don't enable ashmem and binder support in their kernel config. In that case, one might still want to try "anbox-modules" if nothing else helps. This patch makes it possible to compile ashmem and binder as kernel modules with such newer kernels. It's surely not a great solution, but it's a solution of last resort.