-
Notifications
You must be signed in to change notification settings - Fork 233
Solution for building binder and ashmem modules on kernel version above 5.7 #75
Comments
Same here. |
Hello all, I just came across the same problem. After some research on this topic, I found out that the build fails because "kallsyms_lookup_name()" is now no longer exported by the kernel for reasons described here: https://lwn.net/Articles/813350 . However, Anbox kernel modules are using kallsyms_lookup_name() to access some internal kernel functions that they otherwise wouldn't be able to call (such as "zap_page_range"). The Anbox kernel modules should never have used these functions in the first place as they are not supposed to be used by kernel modules (they are lacking an "EXPORT_SYMBOL()" annotation). There is probably nothing that we can do to get these kernel modules to compile for kernels 5.10 and 5.11 anymore. To solve the problems, changes to the upstream kernel would be required to export the (up to now) internal functions like "zap_page_range()" and add an EXPORT_SYMBOL annotation to them. You are probably best off by asking the kernel maintainers of your Linux distribution to include binder and ashmem in their kernels per default. The way it looks right now, building ashmen and binder as kernel modules is no longer a way to go. To make it work again, the Linux kernel devs would need to expose a whole lot of up-to-now internal functions - I am not sure if even they's be willing to do that. Best regards, Christian |
Essentially, this is a duplicate of issue #49 , though the error message you see is slightly different. Please check my last commit in that issue if you really need a solution that makes binder and ashmem work again as modules with the latest kernels. I am using it with kernel 5.10 and it works fine. |
So okay im writing down how i am trying to fix the issue for me. (12.03.21 - i reviewed the procedure after some testing.) New edit: successfully compiled and tested! - [13.03.21] Compile kernel with android options enabled: -->> Scripts for automate the following steps can be obtained and improved here: . [28.03.23]
. ### For the second use you need to delete all files generated by the script / tool to work correctly again:
. i am using Linux Mint 21.1 with Kernel 6.1.12 from UKUU utility which downloads and installs the kernels from official source. (you can always manually download and install them on http://kernel.ubuntu.com/~kernel-ppa/mainline/ but ukuu automates that with a nice gui - its not for free so manually installing them is the recommend way for most ppl.) Steps to manually compile your kernel with ANDROID options: Show your current installed kernel:
**download and install dependency dwarves: (deprecated since newer linux versions already include this) **
I downloaded official kernel source from here: Create a folder where we download the source code, create the compile-configuration parameter file and finally compile the kernel with it:
Information::: I copied the original .config file for building the kernel from my installed one: KERNEL 5.18.X and above Aslong as anbox is using ASHMEM instead of MEMFD we need to revert the deletion of the Revert the patch with: Patch the source code with the reverted patch code: Proceed with the next steps described here - the ASHMEM is now back in the afterwards executing:
or if you build from an already enabled android options enabled kernel make an oldconfig with
scroll through the menu and look for ashmem and binder. (One is inside stageing driver if i remember correct.) Scroll further down to the next Android section: Double click to activate the marked points and save as you are ready.
To fix the certificate error while compiling you need to remove path data in " " the line:
Start compile with a simple: If you want to compile with more cores run the command Note: The time command counts how long the build process have taken after it finished. Then install the deb packages which should be in your parent directory
Restart and enter:
it should print something like *android-1 then you know it booted the newly generated kernel. Warning: Edit 13.03.21: Successfully compiled the kernel with older 4 core-laptop in about 3 hours. Linux 5.11.6android1 #1 SMP Fri Mar 12 11:32:19 CET 2021 x86_64 x86_64 x86_64 GNU/Linux Pre-compiled *.debs:5.11.x Branch
5.12.x Branch
5.13.x Branch
5.14.x Branch
5.15.x Branch
5.16.x Branch[EOL]
5.17.x Branch
5.18.x Branch - EOL
5.19.x Branch 6.x Branch
NOTE: DUE TO LIMITED TIME FOR THESE THINGS I AM NOT GOING TO UPDATE THE LIST FREQUENTLY. I WILL UPDATE THE GDRIVE FOLDER FROM TIME TO TIME WITHOUT NOTICE HERE ´ WARNING! In 5.18.x ASHMEM has been completely removed from the kernel according to this commit from torvalds: - Future plan is to compile some kernel branches with the latest / last EOL kernel for other use cases and clean/remove old/deprecated ones. Note as of now: (09.07.21) To be able to successfully build and run the latest kernel versions with linux mint 20.x you need newer glibc and gcc versions which are included in ubuntu 21.10 already. Unfortunately i didn't figure out yet how i could update them without "heart touching" the whole linux mint 20.x system. It is until now very complicated as you need to compile gcc and glibc from source and maybe many other dependencys that relay on other updated dependencys and updated gcc and glibc. So if you want to compile newer kernels i'll suggest to stick to older ones actually or maybe to the 5.12.x branch where compiling could be done with the included files and apps from linux mint 20.x system. Secure Boot / UEFI: (05.04.22) . 28.03.23: /v6.x/signkernel/cfs_signkernel.sh . ### And for the lazy ones that want to copy and paste into a terminal:
. |
Hello all, It did compile and install but it did not install the modules and therefore i couldn't boot into the system. Also it said it compiled 5.10 instead 5.11. Anyone wants to provide help to this topic as the best way seems to be to enable the in built modules as for now. And the new ubuntu kernels seems to not have them enabled by default (v.5.11;v5.10 etc.) |
Hello @SoulInfernoDE , first of all, as soon as you build something into the kernel, it's not a module anymore. Modules are just dynamically loadable "plugins" for the kernel. So, if you have compiled ashmem and binder support into your kernel, ashmem and binder are not modules. They are just part of the main kernel. What is the error message you see from Anbox? Is it complaining that either ashmem or binder kernel module is not loaded? Maybe in that case, it will help to upgrade Anbox... Maybe Anbox some time ago only supported the external kernel modules and not yet the built-in ashmem and binder functionality that is now available with recent kernels. You should try to check the kernel config of your hand-compiled kernel with one of the methods described here: https://superuser.com/questions/287371/obtain-kernel-config-from-currently-running-linux-system and verify that ashmem and binder are indeed enabled. Do at least my "hacked" kernel modules for ashmem and binder work for you? Christian |
Hello Christian, Also the copied config from actual kernel says: ANDROID Which make menuconfig confirms this |
Hello @SoulInfernoDE , all right, then you know the root cause at the very least :-) I think you are using some Ubuntu-based distributon. Ubuntu applies its own patches to the kernel and building a kernel for Ubuntu is described here: https://wiki.ubuntu.com/Kernel/BuildYourOwnKernel . This description also tells you how you can modify the kernel configuration. If you use a standard kernel without Ubuntu modifications, a simple "make menuconfig" will do the trick. But Ubuntu kernels are built in a different way and different commands need to be used there, so a "make menuconfig" will likely not work and you need to follow the instructions from the Ubuntu page that I have linked above. Best regards, Christian |
Hello Christian, I have found this guide and will check that when I'm back home: https://tutorialforlinux.com/2021/01/15/how-to-install-kernel-5-11-from-source-on-linux-mint-20/ WARNING: Edit: Also found this video guide: 13.03.21 - I collected informations and successfully tested and compiled the kernel with the android options enabled. You can read the solution here if you want to try it yourself and dont know how yet: Edit: 18.03.21
|
@SoulInfernoDE aren't the configs, ASHMEM/BINDER depended on here is menuconfig help for ashmem
Edited |
Small update for anyone who comes across this thread...
For me there was no
I needed to remove the path from both trusted keys and revocation keys in my
|
I added that info and updated my notes. |
I been having hard time trying to build and install this kernel modules, this issues' comment seem to have a solution however not being an expert in the Linux kernel am lost in the technicalities. Can some one help me out by linking a script that just works...I am on Ubuntu |
i can try to make a script for you. You can also use my precompiled .deb files if you like: https://drive.google.com/drive/folders/1X4ojO2KYExc94yc5XFlPx7M_tKu-5gBy?usp=sharing Kernel 5.17.5 direct link: Instructions for the deb files:
Reboot and open terminal: If you see something like this: Then you have the modules built in and loaded.. What you need to do now is to activate the binder to make anbox work: #49 (comment) and #50 (comment). For the one shot script i will try to write it now. Edit: Creating the scripts is ongoing - the goal is a one shot nogui version and a gui version where you can manually add/change options. As i am doing all this in my spare time i will update and improve it from time to time. You can find the scripts here: |
#75 (comment), took care of this issue for me. Thanks to @SoulInfernoDE for help . And can you consider creating pull request |
Sure, pull request is opened to your fork. If you have any ideas or suggestions feel free to contribute and pull request them back to my main branch. |
Wow thanks my friend :D It works fine. Thanks It can remove ... :D Then I will resolve again... |
Very cool - glad it worked 😄 Could you boot your newly installed kernel and did you check the output of I think checking of installed module and removing it with the script is a good update. Will add that now 😀 |
I am very disappointed why is binder not successful for me :( ? I am broken on floor. :/ I can't fix that. I don't understand why does it happen with Ubuntu 22.04 I don't believe that if it doesn't support for me. |
So binder is not active? Could you try this and show me the output?:
If you have anbox installed could you also check:
If it is in the kernel sources it is definitly supported. I guess it is. I'll help you out as far as i can 😃 Also this output should be of a good help for me: |
Do you still need help for this? :-) |
i need help i have binder module running but ashmem module is not there and i dont have android.img too my os 6.1.0-1parrot1-amd64 |
For Ashmem you could try the fix from @choff First remove the ashmem dkms module you already have installed and delete the copied files from the original source. Then download the ashmem folder with the ashmem.c fix from here: Finally follow the readme for the part with Ashmem. |
You have linux system with kernel 5.15 it seems that binder is not present in some way. Could you please show us the output of this command: This will show us if you have BINDER inside your kernel or not. |
Oh seems the file is named else maybe this works?: |
oof that is very strange but then lets try to find out if binder is there anyhow with this:
|
If it helps earlier I managed to run these two commands successfully and downloaded the latest version from the pre-built ones you had in the google drive folder.
|
alright . It seems binder is now loaded, can you try to run waydroid again? |
it seems it only searches binder at that specific directory. But your config file for your kernel seems also be missing somehow. |
v5.15 kernel is a bit old. Maybe a newer kernel like 5.19 or higher works? I recommended to try a newer kernel version from kernel.org to see if that fixes the path problem. The script from my repo can help you with this if you are new to compile a kernel from source. But if you are on an unofficial kernel can you boot to your official kernel and then start the build process so that you get a config file from your running kernel (its not necesarly needed though but it includes configurations to your kernel on the system that you are running) |
Hello,
here are the log:
ASHMEM
DKMS make.log for anbox-ashmem-1 for kernel 5.11.0-051100-generic (x86_64) Sa 27. Feb 08:00:47 CET 2021 make -C /lib/modules/5.11.0-051100-generic/build V=0 M=$PWD make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird betreten CC [M] /var/lib/dkms/anbox-ashmem/1/build/deps.o CC [M] /var/lib/dkms/anbox-ashmem/1/build/ashmem.o LD [M] /var/lib/dkms/anbox-ashmem/1/build/ashmem_linux.o MODPOST /var/lib/dkms/anbox-ashmem/1/build/Module.symvers ERROR: modpost: "kallsyms_lookup_name" [/var/lib/dkms/anbox-ashmem/1/build/ashmem_linux.ko] undefined! make[2]: *** [scripts/Makefile.modpost:111: /var/lib/dkms/anbox-ashmem/1/build/Module.symvers] Fehler 1 make[2]: *** Datei „/var/lib/dkms/anbox-ashmem/1/build/Module.symvers“ wird gelöscht make[1]: *** [Makefile:1710: modules] Fehler 2 make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird verlassen make: *** [Makefile:12: all] Fehler 2
BINDER
DKMS make.log for anbox-binder-1 for kernel 5.11.0-051100-generic (x86_64) Sa 27. Feb 08:00:50 CET 2021 make -C /lib/modules/5.11.0-051100-generic/build V=0 M=$PWD make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird betreten 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:444:9: error: implicit declaration of function ‘__alloc_fd’ [-Werror=implicit-function-declaration] 444 | 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:454:3: error: implicit declaration of function ‘__fd_install’; did you mean ‘fd_install’? [-Werror=implicit-function-declaration] 454 | __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:467:11: error: implicit declaration of function ‘__close_fd’; did you mean ‘close_fd’? [-Werror=implicit-function-declaration] 467 | 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:3498:16: error: implicit declaration of function ‘get_files_struct’; did you mean ‘put_files_struct’? [-Werror=implicit-function-declaration] 3498 | 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] Fehler 1 make[1]: *** [Makefile:1806: /var/lib/dkms/anbox-binder/1/build] Fehler 2 make[1]: Verzeichnis „/usr/src/linux-headers-5.11.0-051100-generic“ wird verlassen make: *** [Makefile:8: all] Fehler 2
The text was updated successfully, but these errors were encountered: