1

When running user mode qemu for target x86 on a target x86 (or just target arch = host arch), will qemu use KVM, transfer control to the directly to the CPU or will it be interpreting the instructions.

2
  • the user mode in qemu is for transparently running binaries compiled for a CPU on another CPU (eg. running x86 linux binaries on an arm linux machine without having to emulate a full computer with peripherals, OS, etc). qemu will JIT-translate the instructions to the target machine's, and the system calls into native system calls. KVM cannot have anything to do with this. – mosvy Aug 17 '19 at 17:18
  • not to be confused with the user-mode network stack (slirp). – mosvy Aug 17 '19 at 17:22
0

A few circumstantial evidences that user mode does not use KVM:

  • the userland executable qemu-x86_64 --help does not show a --kvm option, as is present for the full system executable qemu-system-x86_64 --help

  • we can see both input instructions and the binary translated instructions with:

    qemu-x86_64 -d in_asm,out_asm hello.out
    

    A commented example: How does native android code written for ARM run on x86

Now, for the more interesting question, could it in theory work?

I'm not sure, but on the gem5 simulator, which also has an analogous user mode (called syscall emulation), there was at least some serious investigation of this possibility by AMD, and they concluded it would be possible: http://www.m5sim.org/wiki/images/5/53/2015_ws_12_KVM-in-SE.pdf

Something was actually merged in 2014: adbaa4dfde96d5aaf84adf0ae4989ef880aad726 "kvm, x86: Adding support for SE mode execution". But when I tried on 3ca404da175a66e0b958165ad75eb5f54cb5e772 it failed with KeyError: 'OsKernel', gotta investigate/ask further.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.