Suggested patches for Linux 4.9 issues

447 views
Skip to first unread message

lambd...@gmail.com

unread,
Aug 23, 2017, 7:47:37 AM8/23/17
to Android-x86
Hi,

I personally don't use Android x86, but I maintain an Android port for a x86 device using a Linux 4.9 kernel just like Android x86. Recently I had to backport a few commits from AOSP's master branch to fix issues with the newer kernel together with some Android components and I thought I'd suggest them here if you haven't applied them already.

Note: I didn't test them on Android x86 but I assume it's affected by the same issues as my device.

Patch for ART crash in Linux 4.9.34+:
There was a change in Linux 4.9.34 (and probably newer kernels too) that causes a crash in ART when booting the device. It's related to some memory management change that was back-ported to the 4.9 kernel. The commit below fixes it for me.


Patch for system_netd issues:
I've had a short glance at the netd hack patch that was posted here a few times and it looks related, but for me back-porting two commits fixed it properly. It's related to a change that was made when upstreaming a change to some network routing code, which requires a change in system_netd:



On the Android 4.9 kernel from Google, the netd issue wasn't as obvious because it only happens when cleaning up a network interface (e.g. when switching to VPN) with a really weird error. That's due to a kernel bug that has been only fixed in newer kernel versions. After I back-ported the patch below there was an error when initializing the network interface (that was hidden before). This is fixed by the two patches I posted above.


I hope they are helpful for you. :)
Lambdadroid

youling 257

unread,
Aug 23, 2017, 8:10:57 AM8/23/17
to Android-x86
But,i from kernel source to solved art crash,https://github.com/youling257/android-4.9/commits/update?author=youling257

revert "mm... ",i won't to build 50GB+ Android source,i build kernel source,use custom kernel to boot Phoenix/lineage/Bliss/Androidx86,i only can wating the iso.

在 2017年8月23日星期三 UTC+8下午7:47:37,lambdadroid写道:

lambdadroid

unread,
Aug 23, 2017, 8:18:39 AM8/23/17
to Android-x86
Reverting the kernel patches that have caused the issue only avoids the problem, it doesn't solve it. The patches improve kernel hardening, so reverting them is not the best solution in my opinion.

It's an issue that should be fixed in ART, not in the kernel.

youling 257

unread,
Aug 23, 2017, 8:34:10 AM8/23/17
to Android-x86
if 4.9 kernel add this patch,https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=adeb45cbb5057731ce9c47aad93756135d7947bf
nougat vpn should be working ?
i haven't test vpn on 4.12/4.13 kernel,here has a netd hack for 4.12/4.13 kernel

在 2017年8月23日星期三 UTC+8下午8:18:39,lambdadroid写道:

lambdadroid

unread,
Aug 23, 2017, 8:38:36 AM8/23/17
to Android-x86
The kernel patch doesn't do anything except for making the problem visible, it won't make VPN working.

For me, VPN was working after I applied the two netd patches I posted above. It's possible that it's also working using the netd hack but I haven't tested that.

youling 257

unread,
Aug 23, 2017, 8:46:51 AM8/23/17
to Android-x86
yes,4.13 kernel vpn not working.
https://android.googlesource.com/platform/system/netd/+/2b078678aafceeefea6a70e96ab8ddefe515d027

在 2017年8月23日星期三 UTC+8下午8:38:36,lambdadroid写道:

lambdadroid

unread,
Aug 23, 2017, 8:52:52 AM8/23/17
to Android-x86
I'm not sure. As I mentioned, I haven't tested this on Android x86, I use this on a ROM that is mostly just LineageOS 14.1 with a few fixes to make things work on a specific x86 device.

VPN worked for me with Linux 4.9 kernel, the 2 netd patches and OpenVPN for Android. I've also seen other VPN apps that are not working properly, though.

youling 257

unread,
Aug 23, 2017, 9:06:52 AM8/23/17
to Android-x86
I just need test ShadowsocksR vpn mode,vpn not working,shadowsocksR NAT mode working,but v2ray only has vpn mode. https://github.com/V2Ray-Android/Actinium/releases

在 2017年8月23日星期三 UTC+8下午8:52:52,lambdadroid写道:

Chih-Wei Huang

unread,
Aug 23, 2017, 1:07:53 PM8/23/17
to Android-x86
2017-08-23 19:47 GMT+08:00 <lambd...@gmail.com>:
>
> I personally don't use Android x86, but I maintain an Android port for a x86
> device using a Linux 4.9 kernel just like Android x86. Recently I had to
> backport a few commits from AOSP's master branch to fix issues with the
> newer kernel together with some Android components and I thought I'd suggest
> them here if you haven't applied them already.
>
> Note: I didn't test them on Android x86 but I assume it's affected by the
> same issues as my device.
>
> Patch for ART crash in Linux 4.9.34+:
> There was a change in Linux 4.9.34 (and probably newer kernels too) that
> causes a crash in ART when booting the device. It's related to some memory
> management change that was back-ported to the 4.9 kernel. The commit below
> fixes it for me.
>
> ART: Change main-thread thread paging scheme
> https://android.googlesource.com/platform/art/+/6c63f863f9dbf734732ff837c1e772b3482e59ff

Indeed I have already applied it to my local repo
when merged kernel 4.9.41 from kernel/common tree.
But I didn't publish it yet since I'm not 100% confident.
Thank you for confirming it. Will push it.

> Patch for system_netd issues:
> I've had a short glance at the netd hack patch that was posted here a few
> times and it looks related, but for me back-porting two commits fixed it
> properly. It's related to a change that was made when upstreaming a change
> to some network routing code, which requires a change in system_netd:
>
> Set both legacy and new UID routing attributes.
> https://android.googlesource.com/platform/system/netd/+/2b078678aafceeefea6a70e96ab8ddefe515d027z
>
> Use new-style UID routing.
> https://android.googlesource.com/platform/system/netd/+/22c24ebd283d6e8fb782b34975417308839d4ad7

Yes. I'm also testing them.


> On the Android 4.9 kernel from Google, the netd issue wasn't as obvious
> because it only happens when cleaning up a network interface (e.g. when
> switching to VPN) with a really weird error. That's due to a kernel bug that
> has been only fixed in newer kernel versions. After I back-ported the patch
> below there was an error when initializing the network interface (that was
> hidden before). This is fixed by the two patches I posted above.
>
> fib_rules: fix error return code
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=adeb45cbb5057731ce9c47aad93756135d7947bf
>
>
> I hope they are helpful for you. :)

Yes, they are.
Thank you for providing these.


--
Chih-Wei
Android-x86 project
http://www.android-x86.org

JJ Meijer

unread,
Aug 23, 2017, 1:37:34 PM8/23/17
to Android-x86
Thanks for the hard work hunting these patches down lambdadroid. Currently testing after merging Google's 4.9.44 with above patches and it's looking very good. Now only to make the Kernel stop panicking when suspending with Intel SST driver loaded... :)

Povilas Staniulis

unread,
Aug 23, 2017, 1:54:10 PM8/23/17
to andro...@googlegroups.com
Thanks for the patches. I did workaround the netd issue by just ignoring
return value of modifyOutputInterfaceRules. Now we have a proper patch
for netd issue instead of my hack.
Out of curiosity, what device do you maintain ? Something Bay Trail
based or older ?

On 2017.08.23 14:47, lambd...@gmail.com wrote:
> Hi,
>
> I personally don't use Android x86, but I maintain an Android port for
> a x86 device using a Linux 4.9 kernel just like Android x86. Recently
> I had to backport a few commits from AOSP's master branch to fix
> issues with the newer kernel together with some Android components and
> I thought I'd suggest them here if you haven't applied them already.
>
> Note: I didn't test them on Android x86 but I assume it's affected by
> the same issues as my device.
>
> *Patch for ART crash in Linux 4.9.34+:*
> There was a change in Linux 4.9.34 (and probably newer kernels too)
> that causes a crash in ART when booting the device. It's related to
> some memory management change that was back-ported to the 4.9 kernel.
> The commit below fixes it for me.
>
> ART: Change main-thread thread paging scheme
> https://android.googlesource.com/platform/art/+/6c63f863f9dbf734732ff837c1e772b3482e59ff
>
> *Patch for system_netd issues:*
> I've had a short glance at the netd hack patch that was posted here a
> few times and it looks related, but for me back-porting two commits
> fixed it properly. It's related to a change that was made when
> upstreaming a change to some network routing code, which requires a
> change in system_netd:
>
> Set both legacy and new UID routing attributes.https://android.googlesource.com/platform/system/netd/+/2b078678aafceeefea6a70e96ab8ddefe515d027z
>
> Use new-style UID routing.
> https://android.googlesource.com/platform/system/netd/+/22c24ebd283d6e8fb782b34975417308839d4ad7
>
> On the Android 4.9 kernel from Google, the netd issue wasn't as
> obvious because it only happens when cleaning up a network interface
> (e.g. when switching to VPN) with a really weird error. That's due to
> a kernel bug that has been only fixed in newer kernel versions. After
> I back-ported the patch below there was an error when initializing the
> network interface (that was hidden before). This is fixed by the two
> patches I posted above.
>
> fib_rules: fix error return code
> https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=adeb45cbb5057731ce9c47aad93756135d7947bf
>
>
> I hope they are helpful for you. :)
> Lambdadroid
> --
> You received this message because you are subscribed to the Google
> Groups "Android-x86" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to android-x86...@googlegroups.com
> <mailto:android-x86...@googlegroups.com>.
> To post to this group, send email to andro...@googlegroups.com
> <mailto:andro...@googlegroups.com>.
> Visit this group at https://groups.google.com/group/android-x86.
> For more options, visit https://groups.google.com/d/optout.


lambdadroid

unread,
Aug 23, 2017, 2:33:40 PM8/23/17
to Android-x86
Yes, it's an ASUS Android tablet (ASUS MeMo Pad 7 ME176C) that is based on Bay Trail. I basically threw away everything that came originally with the device and re-made it with Linux 4.9 and components taken from Android-IA. I use some smaller patches from Android x86 but for most things the Android-IA components (e.g. Audio HAL or hardware accelerated video decoder) have worked better for me, especially because some of them are essentially just updated versions of the old closed-source components that came originally with the device.

It's available on XDA[1] and the source is available on GitHub[2] if you want to take a closer look.

youling 257

unread,
Aug 23, 2017, 2:54:23 PM8/23/17
to Android-x86
extcon: Import Crystal Cove PMIC Power Source detection driver
extcon: Port Intel Crystal Cove power source to new intel_soc_pmic

is it can suspend to memory ?

在 2017年8月24日星期四 UTC+8上午2:33:40,lambdadroid写道:

lambdadroid

unread,
Aug 23, 2017, 3:00:14 PM8/23/17
to Android-x86
These patches are not related to suspend. They're used to detect if a powered USB cable is connected (e.g. if the tablet is either connected to a PC or a charger adapter).

Povilas Staniulis

unread,
Aug 23, 2017, 4:03:10 PM8/23/17
to andro...@googlegroups.com
Do you have camera driver working on your device ?

On 2017.08.23 21:33, lambdadroid wrote:
> Yes, it's an ASUS Android tablet (ASUS MeMo Pad 7 ME176C) that is
> based on Bay Trail. I basically threw away everything that came
> originally with the device and re-made it with Linux 4.9 and
> components taken from Android-IA. I use some smaller patches from
> Android x86 but for most things the Android-IA components (e.g. Audio
> HAL or hardware accelerated video decoder) have worked better for me,
> especially because some of them are essentially just updated versions
> of the old closed-source components that came originally with the device.
>
> It's available on XDA[1] and the source is available on GitHub[2] if
> you want to take a closer look.
>
> [1]:
> https://forum.xda-developers.com/memo-pad-7/orig-development/rom-unofficial-lineageos-14-1-asus-memo-t3633341
> [2]: https://github.com/me176c-dev
>
> On Wednesday, August 23, 2017 at 7:54:10 PM UTC+2, Povilas Staniulis
> wrote:
>
> Thanks for the patches. I did workaround the netd issue by just
> ignoring
> return value of modifyOutputInterfaceRules. Now we have a proper
> patch
> for netd issue instead of my hack.
> Out of curiosity, what device do you maintain ? Something Bay Trail
> based or older ?
>
> > an email to android-x86...@googlegroups.com <javascript:>
> > <mailto:android-x86...@googlegroups.com <javascript:>>.
> > To post to this group, send email to andro...@googlegroups.com
> <javascript:>
> > <mailto:andro...@googlegroups.com <javascript:>>.
> <https://groups.google.com/group/android-x86>.
> > For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android-x86" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to android-x86...@googlegroups.com
> <mailto:android-x86...@googlegroups.com>.

Mauro Rossi

unread,
Aug 23, 2017, 4:51:09 PM8/23/17
to Android-x86


Il giorno mercoledì 23 agosto 2017 20:33:40 UTC+2, lambdadroid ha scritto:
Yes, it's an ASUS Android tablet (ASUS MeMo Pad 7 ME176C) that is based on Bay Trail. I basically threw away everything that came originally with the device and re-made it with Linux 4.9 and components taken from Android-IA. I use some smaller patches from Android x86 but for most things the Android-IA components (e.g. Audio HAL or hardware accelerated video decoder) have worked better for me, especially because some of them are essentially just updated versions of the old closed-source components that came originally with the device.

It's available on XDA[1] and the source is available on GitHub[2] if you want to take a closer look.


I've seen you have enabled vulkan forking intel/vulkan-hal

The difference in your branch is the use of vulkan.mesa as module name
reflected in device_asus_me176 project:


Are there other changes needed in init.rc or init.sh necessary to enable the use of vulkan.intel?
Thanks for your information

Mauro

Jose Luis s

unread,
Aug 23, 2017, 4:58:48 PM8/23/17
to Android-x86
Hi Lambdadroid.

¿do you have GPS working?

Thanks

dada

unread,
Aug 23, 2017, 10:02:26 PM8/23/17
to Android-x86
Hi,
Thank you provide this. but this link is broken.
I used this:
Dada

在 2017年8月23日星期三 UTC+8下午7:47:37,lambdadroid写道:
Hi,

lambdadroid

unread,
Aug 24, 2017, 3:16:28 AM8/24/17
to Android-x86
The camera isn't working but I have no intention to make it work either. The camera is kind of stupid on this device anyway, I doubt anyone uses it.
>     > <mailto:android-x86+unsub...@googlegroups.com <javascript:>>.
>     > To post to this group, send email to andro...@googlegroups.com
>     <javascript:>
>     > <mailto:andro...@googlegroups.com <javascript:>>.
>     > Visit this group at https://groups.google.com/group/android-x86
>     <https://groups.google.com/group/android-x86>.
>     > For more options, visit https://groups.google.com/d/optout
>     <https://groups.google.com/d/optout>.
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android-x86" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to android-x86...@googlegroups.com

lambdadroid

unread,
Aug 24, 2017, 3:17:08 AM8/24/17
to Android-x86
No, GPS isn't working but to be honest I have never used it on this device anyway... Sorry :)

lambdadroid

unread,
Aug 24, 2017, 3:22:28 AM8/24/17
to Android-x86
Vulkan is indeed working for me. The name change doesn't matter, I was just annoyed that all modules were named .baytrail when they're not specifically related to Baytrail.

When I started the ROM I used drm_gralloc from Android x86. However, Vulkan was not working correctly with it. It seems like the Vulkan implementation doesn't support the GEM names that are still used in drm_gralloc. I recently switched to Android-IA's fork of minigbm[1] which is using PRIME fds, and since then it is working fine.

youling 257

unread,
Sep 1, 2017, 7:04:27 AM9/1/17
to Android-x86
https://android.googlesource.com/kernel/common/+/435416b698b19d2a716263804a917d3e22ed50c9

CONFIG_ANDROID_BINDER_IPC_SELFTEST=y,boot failed on Androidx86,any idea ? please you test newest android-4.9.


<13>[ 38.864964] init: Service 'logd-reinit' (pid 3602) exited with status 0
<13>[ 38.885072] init: Starting service 'healthd'...
<13>[ 38.913354] init: Starting service 'lmkd'...
<13>[ 38.942939] init: Starting service 'servicemanager'...
<6>[ 38.943503] binder_alloc_selftest: STARTED
stopped boot .

lambdadroid

unread,
Sep 1, 2017, 5:19:33 PM9/1/17
to Android-x86
I don't think you're supposed to enable CONFIG_ANDROID_BINDER_IPC_SELFTEST, that's only for testing. They add options to kernel/configs/android-base.config or kernel/configs/android-recommended.config if you're supposed to set them.

Anyway, I'm two commits behind right now (at https://android.googlesource.com/kernel/common/+/8c972e1bb1865434b35cac9758c2b5a48f610393) which is working fine for me. I'll let you know when I have tested latest.

lambdadroid

unread,
Sep 2, 2017, 6:37:35 AM9/2/17
to Android-x86
Just tested the latest kernel, booting fine and everything works as expected. Try it without enabling CONFIG_ANDROID_BINDER_IPC_SELFTEST.


On Friday, September 1, 2017 at 1:04:27 PM UTC+2, youling 257 wrote:

youling 257

unread,
Sep 2, 2017, 6:51:34 AM9/2/17
to Android-x86
you not help me,my problem is CONFIG_ANDROID_BINDER_IPC_SELFTEST=y

i used # CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set,boot Androidx86 a days.

在 2017年9月2日星期六 UTC+8下午6:37:35,lambdadroid写道:

lambdadroid

unread,
Sep 2, 2017, 7:26:06 AM9/2/17
to Android-x86
I'm sorry, but I'm not sure what "boot Androidx86 a days" is supposed to mean. Could you clarify that? You shouldn't set CONFIG_ANDROID_BINDER_IPC_SELFTEST=y.

youling 257

unread,
Sep 2, 2017, 7:30:09 AM9/2/17
to Android-x86
you think my mean is boot time a days ? bootloops a days ?
no,# CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set,30s boot enter Androidx86. 

在 2017年9月2日星期六 UTC+8下午7:26:06,lambdadroid写道:

youling 257

unread,
Sep 2, 2017, 7:33:37 AM9/2/17
to Android-x86
24 hours ago,i known the problem is CONFIG_ANDROID_BINDER_IPC_SELFTEST=y,stopped boot Androidx86,just CONFIG_ANDROID_BINDER_IPC_SELFTEST is not set,must can booot Androidx86,of course,yesterday,,my kernel #1 can't boot enter Androidx86,#2 can boot enter Androidx86.


在 2017年9月2日星期六 UTC+8下午7:26:06,lambdadroid写道:
I'm sorry, but I'm not sure what "boot Androidx86 a days" is supposed to mean. Could you clarify that? You shouldn't set CONFIG_ANDROID_BINDER_IPC_SELFTEST=y.

youling 257

unread,
Sep 2, 2017, 7:37:19 AM9/2/17
to Android-x86
your this thread,not change any thing kernel source,patch Android source,
if CONFIG_ANDROID_BINDER_IPC_SELFTEST=y,you may know something Android patch,can make boot enter Androidx86.


在 2017年9月2日星期六 UTC+8下午7:26:06,lambdadroid写道:
I'm sorry, but I'm not sure what "boot Androidx86 a days" is supposed to mean. Could you clarify that? You shouldn't set CONFIG_ANDROID_BINDER_IPC_SELFTEST=y.

lambdadroid

unread,
Sep 2, 2017, 8:28:10 AM9/2/17
to Android-x86
I'm still confused. I understand that you'd like to find a way to boot successfully with CONFIG_ANDROID_BINDER_IPC_SELFTEST=y (e.g. by patching the Android sources). However, why do want to set this option? It's supposed to be used for testing the kernel implementation, you're not supposed to set it for real devices. If everything is working without it, just keep it disabled.

youling 257

unread,
Sep 4, 2017, 4:31:56 AM9/4/17
to Android-x86
the problem is libart,[ 117.904234] zygote[4701]: segfault at bff9e000 ip b297a910 sp bffbcb70 error 4 in libart.so[b244b000+729000]


but,i used nougat xposed,the xposed hook libart,i like use xposed.
Source (for dev):

so,someone can build x86/x86_64 nougat xposed include this https://android.googlesource.com/platform/art/+/6c63f863f9dbf734732ff837c1e772b3482e59ff patch ?

youling 257

unread,
Sep 4, 2017, 4:39:41 AM9/4/17
to Android-x86
https://github.com/PurifyOS/xposed_art_n/commits/aosp-7.1.2_r27
what different ?
i used 26-07-17-xposed-v87-sdk25-Xposed-by-PurifyOS.zip has a month,no crash,stable,i don't know it used which xposed_art branch.
so,two version xposed_art,someone can build ?
Message has been deleted

youling 257

unread,
Sep 4, 2017, 6:29:51 AM9/4/17
to Android-x86
“OpenVPN for Android. I've also seen other VPN apps that are not working properly”

it is switch to other vpn problem.
when boot enter Androidx86,select one vpn,vpn can working,can bypass China GFW ;if switch to other vpn,vpn not work,switch back the first select vpn,also not working.

if you boot enter Android,select other vpn can working,if switch to openvpn,not working.
mean is only the first select vpn can working,it is switch to others vpn problem.

在 2017年8月23日星期三 UTC+8下午8:52:52,lambdadroid写道:
I'm not sure. As I mentioned, I haven't tested this on Android x86, I use this on a ROM that is mostly just LineageOS 14.1 with a few fixes to make things work on a specific x86 device.

VPN worked for me with Linux 4.9 kernel, the 2 netd patches and OpenVPN for Android. I've also seen other VPN apps that are not working properly, though.

On Wednesday, August 23, 2017 at 2:46:51 PM UTC+2, youling 257 wrote:
yes,4.13 kernel vpn not working.
https://android.googlesource.com/platform/system/netd/+/2b078678aafceeefea6a70e96ab8ddefe515d027

在 2017年8月23日星期三 UTC+8下午8:38:36,lambdadroid写道:
The kernel patch doesn't do anything except for making the problem visible, it won't make VPN working.

For me, VPN was working after I applied the two netd patches I posted above. It's possible that it's also working using the netd hack but I haven't tested that.

On Wednesday, August 23, 2017 at 2:34:10 PM UTC+2, youling 257 wrote:
if 4.9 kernel add this patch,https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git/commit/?id=adeb45cbb5057731ce9c47aad93756135d7947bf
nougat vpn should be working ?
i haven't test vpn on 4.12/4.13 kernel,here has a netd hack for 4.12/4.13 kernel

在 2017年8月23日星期三 UTC+8下午8:18:39,lambdadroid写道:
Reverting the kernel patches that have caused the issue only avoids the problem, it doesn't solve it. The patches improve kernel hardening, so reverting them is not the best solution in my opinion.

It's an issue that should be fixed in ART, not in the kernel.

On Wednesday, August 23, 2017 at 2:10:57 PM UTC+2, youling 257 wrote:
But,i from kernel source to solved art crash,https://github.com/youling257/android-4.9/commits/update?author=youling257

revert "mm... ",i won't to build 50GB+ Android source,i build kernel source,use custom kernel to boot Phoenix/lineage/Bliss/Androidx86,i only can wating the iso.


在 2017年8月23日星期三 UTC+8下午7:47:37,lambdadroid写道:
Hi,

I personally don't use Android x86, but I maintain an Android port for a x86 device using a Linux 4.9 kernel just like Android x86. Recently I had to backport a few commits from AOSP's master branch to fix issues with the newer kernel together with some Android components and I thought I'd suggest them here if you haven't applied them already.

Note: I didn't test them on Android x86 but I assume it's affected by the same issues as my device.

Patch for ART crash in Linux 4.9.34+:
There was a change in Linux 4.9.34 (and probably newer kernels too) that causes a crash in ART when booting the device. It's related to some memory management change that was back-ported to the 4.9 kernel. The commit below fixes it for me.


Patch for system_netd issues:
Reply all
Reply to author
Forward
0 new messages