Re: How do I use kvm's emulated MOVBE with qemu?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> On 14 Sep 2018, at 20:26, Jim Mattson <jmattson@xxxxxxxxxx> wrote:
> 
> On Tue, Sep 11, 2018 at 12:52 PM, Jim Mattson <jmattson@xxxxxxxxxx> wrote:
>> Commit 84cffe499b941 ("kvm: Emulate MOVBE") implies that MOVBE
>> emulation can be requested with "qemu -cpu ...+movbe..." However, when
>> I try invoking qemu with "-cpu host,+movbe,+vmx", I get:
>> 
>> qemu-system-x86_64: warning: host doesn't support requested feature:
>> CPUID.01H:ECX.movbe [bit 22]
>> 
>> I ask because I'm trying to add a kvm-unit-test that makes use of this
>> functionality.
> 
> On a related note, qemu doesn't seem to use KVM_GET_EMULATED_CPUID at all.

KVM commit 9c15bb1d0a84 ("kvm: Add KVM_GET_EMULATED_CPUID")
intorudced IOCTL of KVM_GET_EMULATED_CPUID to get list of CPU features that can be
emulated by KVM (when not supported by host CPU) but in a "non-perfect" way.
That is, introducing significant performance hit to guest or CPU feature is implemented partially.
(BTW, this was non-trivial to understand from documentation or commit message.
I have figured it out from reading email-thread which introdcued this commit).

Later, KVM commit 84cffe499b94 ("kvm: Emulate MOVBE") introduced support of emulating
MOVBE even when not supported by host CPU. It does so because #UD is intercepted by KVM
and instruction which raised exception is passed to the x86 emulator. So commit only
needed to add emulation of MOVBE to x86 emulator.
However, because emulation of MOVBE (when not supported by host CPU) have significant
performance-hit if exposed to guest via CPUID, it was decided that MOVBE will not be exposed
by KVM_GET_SUPPORTED_CPUID but rather KVM_GET_EMULATED_CPUID.
Later, KVM commit fb6d4d340e05 ("KVM: x86: emulate RDPID") did the same to introduce support
of emulating RDPID when not supported by host CPU.

However, it seems that series which was suppose to modify QEMU to use KVM_GET_EMULATED_CPUID
was never adopted. The email-thread of that patch series can be found here:
https://lists.gnu.org/archive/html/qemu-devel/2014-06/msg01374.html

So even though QEMU allows specifying "+movbe" in command-line since QEMU commit
e117f7725af8 ("x86/cpuid: add missing CPUID feature flag names"), it actually
isn't really supported when using KVM, as it will always get filtered by
x86_cpu_filter_features() because it only use KVM_GET_SUPPORTED_CPUID to determine
"host_feat" which filters CPU features requested by user.

So if you wish to use MOVBE with QEMU, you will need to modify QEMU to use KVM_GET_EMULATED_CPUID...
And overcome all the various opinions in original QEMU email-thread on what should be the correct
QEMU user-interface... Good luck :P

-Liran

P.S
On a related note: Since UMIP cannot be fully emulated by KVM when not supported by host CPU,
(As it is impossible to cause SMSW to #VMExit), should UMIP also be defined in KVM_GET_EMULATED_CPUID
instead of KVM_GET_SUPPORTED_CPUID?
Or is UMIP not considered partially-implemented enough to be considered part of KVM_GET_EMULATED_CPUID?
(See KVM commits ae3e61e1c283 ("KVM: x86: add support for UMIP") and
0367f205a3b7 ("KVM: vmx: add support for emulating UMIP")).






[Index of Archives]     [KVM ARM]     [KVM ia64]     [KVM ppc]     [Virtualization Tools]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite Questions]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux