termux-packages icon indicating copy to clipboard operation
termux-packages copied to clipboard

[Package]: crosvm

Open codrutpopescu opened this issue 1 year ago • 58 comments

Why is it worth to add this package?

Snapdragon 8 Gen 2 and higher processors support a new hypervisor called Gunyah

:/data/data/com.termux/files/home # uname -a Linux localhost 5.15.94-android13-8-27940245-abX916BXXU1BWK6 #1 SMP PREEMPT Wed Nov 15 07:38:57 UTC 2023 aarch64 Toybox :/data/data/com.termux/files/home # ls -l /dev/gunyah crw------- 1 root root 10, 121 2022-08-14 08:12 /dev/gunyah

but qemu does not support this hypervisor. Qualcomm worked with crosvm. It would be amazing to run VMs at hypervisor speeds using crosvm on these processors.

Home page URL

https://crosvm.dev/

Source code URL

https://github.com/google/crosvm

Packaging policy acknowledgement

  • [X] I certify that I have read Termux Packaging Policy and understand that my request will be denied in case of violation.

Additional information

No response

codrutpopescu avatar Feb 10 '24 20:02 codrutpopescu

AFAIK for this you must rebuild kernel with KVM support. That is a nogo. @licy183 what do you think?

twaik avatar Feb 10 '24 21:02 twaik

No, I don't think so, it uses Gunyah instead of KVM https://developer.qualcomm.com/blog/gunyah-hypervisor-software-supporting-protected-vms-android-virtualization-framework I am not really an expert, I am just looking for ways to run VMs efficiently

codrutpopescu avatar Feb 10 '24 21:02 codrutpopescu

crosvm repo contains a few Gunyah mentions. Maybe it can work.

twaik avatar Feb 10 '24 21:02 twaik

Emmm... It may work but I'm afraid that it needs root permission.

licy183 avatar Feb 10 '24 23:02 licy183

According to this: https://github.com/quic/gunyah-hypervisor/issues/24 It's probaby not supported on mobile phones CPUs, so you may close this. You might understand better than me what they ar talking about and better decide.

codrutpopescu avatar Mar 01 '24 05:03 codrutpopescu

hmm there are two components. This SM8550 chip is fairly new (newer then the sc8280xp I'm typing on), and /dev/gunyah means its gunyah-aware in the sense that it may interact with it. Gunyah itself neeeds to be loaded from the boot rom before Android even starts. So Android is a guest of Gunyah (they call it PVM, primary-os virtual machine). But only if this tablet is shipped with it. Gunyah is also fairly new. My attempts with Gunyah were trying out the x86 quemu demonstrator (this worked here), and integrating the gunyah patches into my kernel. But, since my device didn't have Gunyah running from the rom, no effect. Would be containers (docker, lxd) enough for what you have in mind?

jglathe avatar Mar 01 '24 05:03 jglathe

hmm there are two components. This SM8550 chip is fairly new (newer then the sc8280xp I'm typing on), and /dev/gunyah means its gunyah-aware in the sense that it may interact with it. Gunyah itself neeeds to be loaded from the boot rom before Android even starts. So Android is a guest of Gunyah (they call it PVM, primary-os virtual machine). But only if this tablet is shipped with it. Gunyah is also fairly new. My attempts with Gunyah were trying out the x86 quemu demonstrator (this worked here), and integrating the gunyah patches into my kernel. But, since my device didn't have Gunyah running from the rom, no effect. Would be containers (docker, lxd) enough for what you have in mind?

My wish is to run an arm64 Linux VM (ideally RedHat) using hardware acceleration. For now I am using qemu with the option -tcg If anyone knows something better please let me know, I will be grateful.

codrutpopescu avatar Mar 01 '24 20:03 codrutpopescu

I have Snapdragon 8 generation 3 and I also have this file in /dev. It seems to me that if we gave termux virtualization permissions via adb, we would be able to run the VM on the phone.

The main difference I see between this and termux or containers is the ability to redirect phone components, e.g. USB. Termux enables USB but it doesn't work as well as with virtualization.

DienoX avatar Mar 29 '24 13:03 DienoX

A little more about this hypervisor https://youtu.be/hLdUCrlheKg?si=MrocW4lCtN3n3bSg

DienoX avatar Mar 29 '24 14:03 DienoX

No update regarding this I pressume as I don't see any mention or changelog. This could be a really nice addition, I am really dumbfound that there is nothing out yet that uses gunyah as even modern Samsung devices seem to have it enabled by default.

Soranokuni avatar Jun 18 '24 10:06 Soranokuni

AFAIK for this you must rebuild kernel with KVM support. That is a nogo. @licy183 what do you think?

In the current android kernel, the KVM module is enabled by default(GKI). But unfortunately, it requires the linux kernel be loaded into EL2, and currently both Qualcomm and Mediatek loads kernel into EL1 instead of EL2.

So it's impossible to enable KVM at Qualcomm/Mediatek chip(even with unlocked bootloader).

But since 8Gn2 and 8Gen3, Qualcomm loads Gunyah into the EL2, and the linux kernel in EL1 can communicate with Gunyah to request it to create another VM in EL1.

In this case, crosvm is just a userspace client can communicate to gunyah driver to create vm, it's reasonable to me to add crosvm to termux package.

KusakabeShi avatar Jul 26 '24 08:07 KusakabeShi