How to enable KVM on Jetson TX2 board?

Hi,

I want to know how I can enable virtualization support for the CPUs on TX2 board. Based on this https://developer.arm.com/products/processors/cortex-a/cortex-a57 the processor on this board support hardware virtualization. Can anybody help me to get KVM working on my board? Here is what I get when I type “kvm-ok” command:

INFO: /dev/kvm does not exist
HIT: sudo modprobe kvm
modeprobe: FATAL: Module msr not found in directory /lib/modules/4.4.15-tegra

Thanks,
Mamad

u may use as a reference :https://devtalk.nvidia.com/default/topic/1006055/jetson-tx2/-quot-error-getting-vgic-maintenance-irq-from-dt-quot-for-kvm-at-boot-up/

Thank you for the reply. Should I follow the instructions in http://www.virtualopensystems.com/en/solutions/guides/kvm-on-arm/ ?

If so, when I copy KVM enabled kernel Image and dtb files under /boot directory in the tx-2 rootfs, I cannot boot up the board anymore.

In this thread https://devtalk.nvidia.com/default/topic/1006055/jetson-tx2/-quot-error-getting-vgic-maintenance-irq-from-dt-quot-for-kvm-at-boot-up/ you mentioned: “I have once managed to run a guest OS within KVM at Jetson JTK1.” Can you elaborate on how you did this? This is exactly what I want to do on Jetson TX-2.

Thank you,
Mamad

when I copy KVM enabled kernel Image and dtb files under /boot directory in the tx-2 rootfs, I cannot boot up the board anymore

How did you build this kernel? By updating the config file and re-building based on the JetPack 3 sources?

U may like to use Docker : https://devtalk.nvidia.com/default/topic/1000224/jetson-tx2/docker-on-the-tx2/
Mamad, As far as I remember it was rather straightforward procedure. I used simple means like sudo apt-get install quemu, in general. But due to the resulting performance it was rather non-usable than usable.

Here is what I do:

I use the instruction in http://www.jetsonhacks.com/2017/03/25/build-kernel-and-modules-nvidia-jetson-tx2/ to get kernel source code and build kernel on tx2 board.
I enable “Tegra Virtualization Support” and “Kernel-based Virtual Machine (KVM) support” options from kernel configuration and build the kernel.

First I get the following error:

include/linux/irqchip/arm-gic.h: Assembler messages:
include/linux/irqchip/arm-gic.h:100: Error: unknown mnemonic enum' -- enum domain_gic_pm_event{’
include/linux/irqchip/arm-gic.h:101: Error: unknown mnemonic mod_domain_power_on' -- mod_domain_power_on,’
include/linux/irqchip/arm-gic.h:102: Error: unknown mnemonic mod_domain_power_off' -- mod_domain_power_off’
include/linux/irqchip/arm-gic.h:103: Error: junk at end of line, first unrecognized character is `}’
scripts/Makefile.build:297: recipe for target ‘arch/arm64/kvm/vgic-v2-switch.o’ failed
make[1]: *** [arch/arm64/kvm/vgic-v2-switch.o] Error 1
Makefile:958: recipe for target ‘arch/arm64/kvm’ failed

I am able to fix this error by the following changes in “include/linux/irqchip/arm-gic.h”

+#ifndef ASSEMBLY
enum domain_gic_pm_event {
MOD_DOMAIN_POWER_ON,
MOD_DOMAIN_POWER_OFF
};

-#ifndef ASSEMBLY

But after building kernel again I get this error:

CC init/version.o
LD init/built-in.o
drivers/built-in.o: In function nvmap_populate_ivm_carveout': /usr/src/kernel/kernel-4.4/drivers/video/tegra/../../../../nvmap//drivers/video/tegra/nvmap/nvmap_init.c:209: undefined reference to tegra_hv_mempool_reserve’
/usr/src/kernel/kernel-4.4/drivers/video/tegra/…/…/…/…/nvmap//drivers/video/tegra/nvmap/nvmap_init.c:209:(.init.text+0x5950): relocation truncated to fit: R_AARCH64_CALL26 against undefined symbol `tegra_hv_mempool_reserve’
Makefile:944: recipe for target ‘vmlinux’ failed
make: *** [vmlinux] Error 1
CHK include/config/kernel.release

Can you let me know how to get around these and enabled KVM on Jetson-tx2 board?

BTW, I want to do some instrumentations using KVM, so containers does not work for me and I don’t care about the speed of visualization.

Thank you,
Mamad

Sounds like the virtualization modules have not been ported to the 27.1 kernel (which is 4.x based rather than 3.x based.)

If so, then you will have to port those modules yourself, or you will have to wait for someone else to do it.

Hi Mamad,

I faced the same issue with u, how about it going now? do u find any method to fix it?

Yafei - No. I didn’t spend more time on this.

Mamad, Thank you!

Hi all,

I successfully create virtual machines using KVM on Jetson TX2. If you are interested, please see my Github repository for detailed information.

https://github.com/BaoqianWang/VirtualizationOnJetsonTX2

Baoqian Wang

hi wbq7758258,
I am following your introduction about how to create virtual machines step by step ,but I encountered such issue: qemu-system-aarch64:Initialization of device cfi.pflash01 failed: failed to read the initial flash content.
I used the ubuntu 18.04 ISO. Could you help me out?