remote-android / redroid-modules

redroid kernel modules (binderfs, ashmem etc.)
GNU General Public License v2.0
82 stars 56 forks source link

Support for the binderfs instead of binder #3

Closed kebugcheckex closed 2 years ago

kebugcheckex commented 2 years ago

Summary

redroid doesn't work on Arch Linux zen kernel, which is built with binder in a slightly different way.

Context

I'm using Arch Linux with zen-kernel. The kernel is built with ashmem and binder support. Redroid crash-loops in the container trigger by binder related errors.

After some research, I found a subtle difference in the kernel build config where zen kernel is built with

CONFIG_ANDROID_BINDER_DEVICES=""

while other distros are build with

CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

This difference resulted in different devices when binder is mounted. In zen-kernel, after mounting binder device, there is only one item

$ ls /dev/binderfs
binder-control

Otherwise, there should be 4 items in it

$ ls /dev/binderfs
binder  binder-control  hwbinder  vndbinder

I didn't find any docs explaining the difference, although the Arch Linux Anbox wiki does mention the two ways of building binder module.

Since Anbox works with both binder and binderfs, I'm wondering if redroid can support that too, if not too difficult. I feel that binderfs is the new version of binder, if I understand correctly.

I'm happy to contribute code but my knowledge on these specific topics is limited.

Update

I found this article roughly described the difference between binder and binderfs.

zhouziyang commented 2 years ago

Redroid works only in binderfs. Some distribution like Ubuntu make binderfs as a kernel module, and you can load with device parameters (sudo modprobe binder_linux devices=binder,hwbinder,vndbinder).

FYI, redroid can allocate binder devices by it’s own and this behavior is changed recently.

Sent from my iPhone

On Sep 26, 2021, at 7:35 AM, Xinyu Chen @.***> wrote:



Summary

redroid doesn't work on Arch Linux zen kernel, which is built with binder in a slightly different way.

Context

I'm using Arch Linux with zen-kernelhttps://github.com/zen-kernel/zen-kernel. The kernel is built with ashmem and binder support. Redroid crash-loops in the container trigger by binder related errors.

After some research, I found a subtle difference in the kernel build config where zen kernel is built with

CONFIG_ANDROID_BINDER_DEVICES=""

while other distros are build with

CONFIG_ANDROID_BINDER_DEVICES="binder,hwbinder,vndbinder"

This difference resulted in different devices when binder is mounted. In zen-kernel, after mounting binder device, there is only one item

$ ls /dev/binderfs binder-control

Otherwise, there should be 4 items in it

$ ls /dev/binderfs binder binder-control hwbinder vndbinder

I didn't find any docs explaining the difference, although the Arch Linux Anbox wikihttps://wiki.archlinux.org/title/Anbox does mention the two ways of building binder module.

Since Anbox works with both binder and binderfs, I'm wondering if redroid can support that too, if not too difficult. I feel that binderfs is the new version of binder, if I understand correctly.

I'm happy to contribute code but my knowledge on these specific topics is limited.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/remote-android/redroid-modules/issues/3, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAP5VMTCH2UYYJ7MRTP6AHDUDZMEXANCNFSM5EYDKE6A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

kebugcheckex commented 2 years ago

Logcat shows the following error message

ProcessState: Opening '/dev/binder' failed: No such file or directory
...
Abort message: 'Binder driver '/dev/binder' could not be opened.  Terminating.'

I've verified that /dev/binderfs is properly mounted. As the container crash-loops, running ls -l /dev/binderfs shows another item binder_log in addition to binder-control. But I didn't see binder.

A brief search in the source code, I found that the error message is logged in ProcessState.cpp. I thought it should first create a binder device inside /dev/binderfs and then try to open that. But the code seems indicate that the default binder driver name is /dev/binder.

Can you give me some hints on how to further debug?

zhouziyang commented 2 years ago

default device of your binderfs is empty. whether the binderfs of zen kernel is a kernel module (just like ubuntu)?if so, you can try sudo modprobe binder_linux devices=binder,hwbinder,vndbinder

there is test project of binderfs in vendor_redroid repo, you can try to allocate all these binder devices. FYI, the binderfs is mounted in init.rc or init.redroid.rc

Someone already report redroid works out of the box in arch Linux. Can you help to test again?

Sent from my iPhone

On Sep 26, 2021, at 11:50 AM, Xinyu Chen @.***> wrote:



Logcat shows the following error message

ProcessState: Opening '/dev/binder' failed: No such file or directory ... Abort message: 'Binder driver '/dev/binder' could not be opened. Terminating.'

I've verified that /dev/binderfs is properly mounted. As the container crash-loops, running ls -l /dev/binderfs shows an addition item binder_log in addition to binder-control. But I didn't see binder.

A brief search in the source code, I found that the error message is logged in ProcessState.cpphttps://cs.android.com/android/platform/superproject/+/android-11.0.0_r20:frameworks/native/libs/binder/ProcessState.cpp;l=372. I thought it should first create a binder device inside /dev/binderfs and then try to open that. But the code seems indicate that the default binder driver name is /dev/binder.

Can you give me some hints on how to further debug?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/remote-android/redroid-modules/issues/3#issuecomment-927225152, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAP5VMUFOQZEETOZKCR3AVDUD2J7VANCNFSM5EYDKE6A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

zhouziyang commented 2 years ago

For new issues, please create under redroid-doc repo. More people can dive into this. Thanks

Sent from my iPhone

On Sep 26, 2021, at 7:13 PM, Zhou Ziyang @.***> wrote:

 default device of your binderfs is empty. whether the binderfs of zen kernel is a kernel module (just like ubuntu)?if so, you can try sudo modprobe binder_linux devices=binder,hwbinder,vndbinder

there is test project of binderfs in vendor_redroid repo, you can try to allocate all these binder devices. FYI, the binderfs is mounted in init.rc or init.redroid.rc

Someone already report redroid works out of the box in arch Linux. Can you help to test again?

Sent from my iPhone

On Sep 26, 2021, at 11:50 AM, Xinyu Chen @.***> wrote:



Logcat shows the following error message

ProcessState: Opening '/dev/binder' failed: No such file or directory ... Abort message: 'Binder driver '/dev/binder' could not be opened. Terminating.'

I've verified that /dev/binderfs is properly mounted. As the container crash-loops, running ls -l /dev/binderfs shows an addition item binder_log in addition to binder-control. But I didn't see binder.

A brief search in the source code, I found that the error message is logged in ProcessState.cpphttps://cs.android.com/android/platform/superproject/+/android-11.0.0_r20:frameworks/native/libs/binder/ProcessState.cpp;l=372. I thought it should first create a binder device inside /dev/binderfs and then try to open that. But the code seems indicate that the default binder driver name is /dev/binder.

Can you give me some hints on how to further debug?

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/remote-android/redroid-modules/issues/3#issuecomment-927225152, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAP5VMUFOQZEETOZKCR3AVDUD2J7VANCNFSM5EYDKE6A. Triage notifications on the go with GitHub Mobile for iOShttps://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Androidhttps://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.