Question Help compiling kernel with KVM

Search This thread
Hi,
I wanted to compile a custom kernel with KVM for the ROG Phone 5 on the latest Android 12 (EU variant) so I looked at the Kirisakura kernel for base (from @Freak07) and I looked at the script that starts compiling the kernel. I could not find some things that was required such as the Google's GCC thing or the "DU_Tools" but I still managed to start compiling the kernel after editing the defconfig file using make menuconfig to enable KVM. Once I did that I ran the script but after like two minutes I got an error (Error 2).
So can someone help me doing this please?
Thanks.
 

chrisaw

Senior Member
Jun 12, 2007
314
237
Hey Alex - been looking in to creating a build script using docker for this out of curiosity.

Out of interest though - how are you planning to use KVM once it's enabled?
 

chrisaw

Senior Member
Jun 12, 2007
314
237
Got this building cleanly and producing a flashable ZIP:


Build instructions:

Code:
$ cd <kernel sources>/build/
$ ./build.sh

You will need Docker installed on your system via whatever means necessary and this is really aimed at Linux systems although you could also run the build on a Windows or Mac PC if you setup Docker correctly.

Broken build?
If when tinkering with builds on this device you end up stuck at the fastboot screen all you need to do is extract a copy of the latest (or any version you wish) firmware for your device and run the following:

Code:
$ fastboot flash boot boot.img # alternatively you can use a magisk patched image here
$ fastboot flash dtbo dtbo.img
$ fastboot flash vendor_boot vendor_boot.img
$ fastboot reboot

You should then be working again on the stock kernel with no data loss, etc unless you have specifically disabled encryption - in that case I can't confirm if you would lose data or not. Tread carefully.

Note:

This is simply a copy of Kirisakura's excellent kernel but with KVM enabled and should NOT be used by anyone expecting support from that developer. All I've added to this is a set of build scripts - I'm not trying to take any credit and 100% of credit for the kernel goes to freak07 themselves.

Just helping the thread raiser out in getting a successful build of the kernel sources themselves. :)
 
Last edited:
Hey Alex - been looking in to creating a build script using docker for this out of curiosity.

Out of interest though - how are you planning to use KVM once it's enabled?
Hey, I didn't tried using docker (because I don't know how to xD) and I want to use KVM because I heard that the Snapdragon 888 is compatible with it so I was thinking about doing a Windows 10 arm VM with native performance.
Got this building cleanly and producing a flashable ZIP:


Build instructions:

Code:
$ cd <kernel sources>/build/
$ ./build.sh

You will need Docker installed on your system via whatever means necessary and this is really aimed at Linux systems although you could also run the build on a Windows or Mac PC if you setup Docker correctly.
Thanks I will try that :)
 

chrisaw

Senior Member
Jun 12, 2007
314
237
Hey, I didn't tried using docker (because I don't know how to xD) and I want to use KVM because I heard that the Snapdragon 888 is compatible with it so I was thinking about doing a Windows 10 arm VM with native performance.

Thanks I will try that :)
Your chances of getting that working easily are slim.

Adding the KVM support to the kernel is easy but the problem you then get is about switching the CPU to "HYP" mode. (just based on what I read online)

If you have further info about this I'd be interested in reading it and seeing if we can get something which works. What I can tell you is that /dev/kvm does not get created simply by the changes I made.

Also be aware that /proc/config.gz is spoofed in these kernels with the "stock" config file so running something like "zcat /proc/config.gz" wont show KVM is enabled but it is. :)