4

My guest OS is an x86 (.vmdk format) and it seems from QEMU documentation that since my host is an ARM Raspberry Pi 3, I can't take advantage of KVM even after enabling it in the kernel.

Is that correct?

3
  • You might have more luck with this question at Raspberry Pi.
    – phk
    Jan 29, 2017 at 21:53
  • 1
    @phk Not really. This is a question about Linux's KVM. The fact that a Pi is involved is peripheral to the question. Jan 29, 2017 at 22:59
  • @Gilles How to enable HYP mode depends on the bootloader which makes it somewhat RPi-specific. Also, you can find similar questions at the other SE site. But of course, none of them have to do with emulating another architecture but instead (para)virtualization.
    – phk
    Jan 29, 2017 at 23:11

4 Answers 4

12

The naive way to run a virtual machine is to interpret each instruction. The VM software decodes each instruction and runs it.

When the instruction set of the virtual machine is the same as the host, an alternative method is to simply execute the instructions. Only a few instructions can't be executed directly because the guest doesn't have full control over the hardware. A sticky point is memory accesses: the guest doesn't have access to the whole memory, so a translation needs to be performed on the addresses. High-end CPUs such as x86 CPUs with the VT-x (Intel) or AMD-V (AMD) extension, or ARM Cortex-A15 and above (including the Pi 2 and the Pi 3), have hardware features to perform this address translation. KVM is a component of the Linux kernel that takes advantage of these instructions to allow a code in a virtual machine to be executed directly by the native processor.

This doesn't help you, because you aren't trying to execute ARM code on an ARM CPU, or x86 on an x86 CPU. You want to execute x86 code on an ARM CPU. For this, software to decode and interpret the instructions is necessary. KVM doesn't help here.

1
  • This is exactly the answer I was looking for. Thanks for your time and knowledge.
    – A. Michael
    Jan 30, 2017 at 3:39
-1

You may enable kvm in the kernel but without the proper cpu extensions the module will not load.

5
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – phk
    Jan 29, 2017 at 21:29
  • @phk It looks like an answer to me. The ten-hours-earlier answer is certainly better, but this answers the question all the same. Jan 29, 2017 at 21:35
  • @MichaelHomer I get the feeling that both answers actually don't answer what OP wants, OP might be looking for cross-architecture virtualization ("My guest OS is an x86").
    – phk
    Jan 29, 2017 at 21:52
  • True, but irrelevant. The Pi 3 has the proper CPU extensions, but they aren't useful here since the guest is x86. Jan 29, 2017 at 23:01
  • The OP explicitly said he loaded KVM in the kernel and now wonders why it doesn't work. I provided an answer to that, since the answer to the main question - whether this should work or not - has already been provided. So either someone is just so hysterical to hold the downvote button too fast, or just can't read. Not that I care much about points, but I wanted to make things clear(er)
    – dyasny
    Jan 30, 2017 at 1:01
-2

Yes that's correct. KVM relies on CPU virtualization support ( Intel VT or AMD-V ) and since the Raspberry PI 3 ARM CPU does not support these instructions you cannot make use of KVM.

2
  • ARM Virtualization Extensions exist as well, also OP apparently wants to emulate a different architecture.
    – phk
    Jan 29, 2017 at 21:49
  • Correct conclusion but wrong reason. KVM can be used with an ARM guest on an ARM host. What it isn't useful for is cross-architecture virtualization. Jan 29, 2017 at 23:00
-2

To accelerator the emulation (i.e turn the kernel to full virtualization) you would need the KVM module and a proper CPU to execute the virtual machine code, essentially it's a an add-on to the CPU. There is many way you could tell if your system support it, either execute the command ~$ lscpu, check for your system capabilities ~$ virsh capabilities, or simply $ cat /proc/cpuinfo. The flags you are looking for are vmx for Intel & svm for AMD.

Now ARM CPU's, as far my knowledge they do not have that CPU add-on. Theoretically yes, you could run some sort of emulated systems on ARM CPU without CPU extensions but that would be super slow. As for the Raspberry, I guess you would run out of resources before you could initiate you virtual machine without KVM-like-for-ARM.

As for my experience, I did need to execute some FreeBSD code (PFsense) on low power device, but ARM arch's aren't supported, so I did run a full virtualization on Intel compute stick instead.

    [root@compute ~]# lscpu 
Architecture:          x86_64
CPU op-mode(s):        32-bit, 64-bit
Byte Order:            Little Endian
CPU(s):                4
On-line CPU(s) list:   0-3
Thread(s) per core:    1
Core(s) per socket:    4
Socket(s):             1
NUMA node(s):          1
Vendor ID:             GenuineIntel
CPU family:            6
Model:                 55
Model name:            Intel(R) Atom(TM) CPU  Z3735F @ 1.33GHz
Stepping:              8
CPU MHz:               666.452
CPU max MHz:           1832.6000
CPU min MHz:           499.8000
BogoMIPS:              2662.40
Virtualization:        VT-x
L1d cache:             24K
L1i cache:             32K
L2 cache:              1024K
NUMA node0 CPU(s):     0-3
Flags:                 fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 cx16 xtpr pdcm sse4_1 sse4_2 movbe popcnt tsc_deadline_timer aes rdrand lahf_lm 3dnowprefetch epb tpr_shadow vnmi flexpriority ept vpid tsc_adjust smep erms dtherm ida arat
3
  • 2
    High-end ARM CPUs such as the one in the Pi 3 do have hardware virtualization extensions, and KVM does support them. But that's only useful to run an ARM guest, whereas the question is about an x86 guest. Jan 29, 2017 at 23:02
  • @Gilles Would not the command lscpu show you the virtualization extension
    – Abdullah
    Jan 30, 2017 at 12:48
  • On x86, yes, either vmx or svm. On arm, no. /proc/cpuinfo reports optional processor features, but not the ones that come with a given ARM core, and virtualization comes with a core: Cortex-A15 and above (which includes the Pi 2's Cortex-A7 and the Pi 3's Cortex-A53 but not the original Pi's ARM1176). There's no easy way to find out the capabilities of an ARM CPU from what Linux reports, you have to start with the CPU model (BCMxxxx) and look at its datasheet. Jan 30, 2017 at 13:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .