KVM (Kernel Virtual Machine) on Samsung Galaxy A6 (Exynos 7870)

Search This thread

raspiduino

Senior Member
Jun 23, 2021
84
16
I have an Galaxy A6 which has the Exynos 7870 CPU. I downloaded the kernel source from the Samsung source page, and when I typed
Bash:
make menuconfig
it has the Virtualization option. So does that mean the CPU itself support KVM? Thanks!

I just compile the kernel, pack it to boot.img, put boot.img to the AP and flash it using Odin but not work. I want to try if KVM exist to run Windows ARM in QEMU kvm in Termux :)
 

raspiduino

Senior Member
Jun 23, 2021
84
16
Can you set up Windows Debug (https://docs.microsoft.com/en-us/wi...gger/setting-up-a-null-modem-cable-connection) and set up QEMU to output serial over network, then setup virtual serial port on a Windows machine that has Windbg, then use windbg to debug?

Searching on the Internet said that 0xc0000001 is related to hardware not working / not respoding. Maybe your KVM implementation has error OR I think the most common case some of your system register is not properly set (usually by phone's bootloader) for Windows to use.
 

raspiduino

Senior Member
Jun 23, 2021
84
16
Will this kernel work on galaxy J7 metal (J710MN)? If it doesn't work, could you make a compilation?
Not really sure. I don't have that phone model. You can go get your kernel source (from Samsung Open Source page), then apply the patch kvm.patch in the exynos-kvm-patch repo (either by hand or by git apply). Then compile, root the phone, flash new kernel and see if it works.
 

JhosephRF

Member
Jul 5, 2021
16
1
Not really sure. I don't have that phone model. You can go get your kernel source (from Samsung Open Source page), then apply the patch kvm.patch in the exynos-kvm-patch repo (either by hand or by git apply). Then compile, root the phone, flash new kernel and see if it works.
In your post on Github there is a link to download the kernel with kvm support. I want to know if this kernel would work on Galaxy A6 Plus. Because this is the model available in my region, i don't know if the kernel of both smartphones are the same.
 

raspiduino

Senior Member
Jun 23, 2021
84
16
In your post on Github there is a link to download the kernel with kvm support. I want to know if this kernel would work on Galaxy A6 Plus. Because this is the model available in my region, i don't know if the kernel of both smartphones are the same.
I'm not really sure, but it worth a try.

If you buy a new A6+ phone to try this, I would recommend not to, since it might break the warranty.

If you already got one then just try it, the warranty is probably already outdated
 

JhosephRF

Member
Jul 5, 2021
16
1
I'm not really sure, but it worth a try.

If you buy a new A6+ phone to try this, I would recommend not to, since it might break the warranty.

If you already got one then just try it, the warranty is probably already outdated
There is no kernel available for this version on the Samsung Open Source website
Samsung Open Source .jpg
Samsung Galaxy A6+ Plus.jpg
 

raspiduino

Senior Member
Jun 23, 2021
84
16
My a6lte is broken now, so I will not have anything to test the kernel on. Good luck for you all on the development of a6lte-kvm! Thank you for joining the thread!

Probably I will get a new Samsung Phone, but I have to wait until the warranty period ended to root the device.

See you soon.
 

Ryujin96

Senior Member
I tried your patch on my device, modified a little bit for calling your "preinit_hyp_mode()" function from "init/main.c". I can boot into stock rom, install termux on it and then install qemu-system-arm and qemu-system-aarch64. I also run "chmod 666 /dev/kvm". Then I tried qemu-system-aarch64 with --enable-kvm but it said kvm not found. I also tried qemu-system-arm but it said "kvm_init_vcpu failed: invalid argument". "/dev/kvm" is available. What am I doing wrong?

Also my hard keys (volume up/down and power key) don't work after booting with that kernel but it work with stock rom, although this is not the main problem.

Thanks!
how did u fix the error related to "preinit_hyp_mode()" function in "init/main.c"?
 

raspiduino

Senior Member
Jun 23, 2021
84
16
how did u fix the error related to "preinit_hyp_mode()" function in "init/main.c"?
Sorry for late reply. Now I finally remember how I did it.

If you mean "the error" is the phome can boot but you cannot start KVM QEMU, then here is the answer:

- DO NOT use Termux for this kind of things. Termux use proot (fake chroot, with fake "device call" simulation). We need to use some chroot apps, like Linux Deploy (available on Google Play, also open source, so it can really changes the hardware states.

If you are using a6lte:

- After installing Linux Deploy, install a chroot environment, selecting the architecture as ARMHF, and username as "root" in the setting. Also enable VNC

- Get the shell. Run `dpkg --add-architecture arm64`. Then `apt update`. Then `apt install qemu-system-arm`

- Now you should be able to use it
 
Jun 19, 2017
8
0
Sorry for late reply. Now I finally remember how I did it.

If you mean "the error" is the phome can boot but you cannot start KVM QEMU, then here is the answer:

- DO NOT use Termux for this kind of things. Termux use proot (fake chroot, with fake "device call" simulation). We need to use some chroot apps, like Linux Deploy (available on Google Play, also open source, so it can really changes the hardware states.

If you are using a6lte:

- After installing Linux Deploy, install a chroot environment, selecting the architecture as ARMHF, and username as "root" in the setting. Also enable VNC

- Get the shell. Run `dpkg --add-architecture arm64`. Then `apt update`. Then `apt install qemu-system-arm`

- Now you should be able to use it
Sorry for late reply. Now I finally remember how I did it.

If you mean "the error" is the phome can boot but you cannot start KVM QEMU, then here is the answer:

- DO NOT use Termux for this kind of things. Termux use proot (fake chroot, with fake "device call" simulation). We need to use some chroot apps, like Linux Deploy (available on Google Play, also open source, so it can really changes the hardware states.

If you are using a6lte:

- After installing Linux Deploy, install a chroot environment, selecting the architecture as ARMHF, and username as "root" in the setting. Also enable VNC

- Get the shell. Run `dpkg --add-architecture arm64`. Then `apt update`. Then `apt install qemu-system-arm`

- Now you should be able to use it
Hello senior developer, have you solved running arm windows with kvm support?
 

raspiduino

Senior Member
Jun 23, 2021
84
16
Hello senior developer
I'm not event a developer, I'm a student :)

have you solved running arm windows with kvm support?
No actually, I'm too busy (for other stuff) for backporting PMU to my kernel. If your device runs a 4.14 or 5.x or (probably not yet) 6.x kernel, and you are able to get KVM on it, then you are good to go, since these things have been claimed to have PMU and boot Windows.
 

Top Liked Posts

  • There are no posts matching your filters.
  • 1
    This seems to work for me. qemu-system-aarch64 in Linux Deploy works with -enable-kvm.

    Attached a kernel with KVM enabled + latest Magisk: https://mega.nz/file/d8lGhY7b#NKQZEL3G6bT7SetrHLh4rNgmgg0L5EXJ0Lir_QjAebA

    EDIT: uploaded the patch to Github: https://github.com/sleirsgoevy/exynos-kvm-patch
    1
    Oh thanks you so much! I will try this right now!
    Just 3 questions:
    - How do you build and pack the kernel? I tried both "make Image" and "make Image.gz" then unpack boot.img using android image kitchen but it did not boot when I flash with Odin.
    - Do you get a factory reset prompt when first boot this kernel with stock firmware? I got it once when I tried patching stock kernel with magisk.
    - If you get the factory reset prompt in question 2: after reset and setup Android, I cannot get the phone's pin lock and password work anymore. So how to fix this?

    Thank you very much!
    I used magiskboot for repacking the kernel. Unpack boot.img with `magiskboot unpack boot.img`, replace `kernel` with `Image` (not `Image.gz`), then repack with `magiskboot repack boot.img`, and flash `new-boot.img`. The magiskboot binary can be found in the Magisk installation zip.
    1
    A small status update: Windows on ARM currently halts due to missing support for performance counters in Linux 3.18's KVM. Linux handles its registers as "read all zeroes, write ignored", but Windows expects the counters to actually tick. Probably a proper implementation needs to be backported from newer Linux.
    1
    This should not happen, unless for some reason you are trying to do it without using root. If you're using the proper root-enabled chroot, and not the proot hack, changing the architecture in settings should be enough.
    1
    For debugging, add proper earlycon options to kernel command line, 'coz it is probably panicking way before late serial is initialized.

    Steps to boot Linux:
    * dump DTB from your QEMU installation: `qemu -M virt,dumpdtb=dtb.bin`
    * use dtc tool from the Linux kernel source to translate it to dts
    * modify the dts file as follows:
    ```
    timer {
    interrupts = <0x1 0xd 0x304 0x1 0xe 0x304 0x1 0xb 0x304 0x1 0xa 0x304>;
    always-on;
    compatible = "arm,armv8-timer", "arm,armv7-timer";
    clock-frequency = <0x18cba80>; <-- add this
    };
    ```
    * now recompile it to dtb and provide to qemu via the -dtb flag

    Attached my own patched DTB for -M virt.