]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commit
KVM: X86: Emulate MSR_IA32_MISC_ENABLE MWAIT bit
authorWanpeng Li <wanpengli@tencent.com>
Tue, 21 May 2019 06:06:54 +0000 (14:06 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Tue, 4 Jun 2019 17:29:09 +0000 (19:29 +0200)
commit511a8556e3342af6a46eb9477936b29aa983f154
tree59eb52e1ebf9eef6051629cfe9db3fd347693849
parentb51700632e0e53254733ff706e5bdca22d19dbe5
KVM: X86: Emulate MSR_IA32_MISC_ENABLE MWAIT bit

MSR IA32_MISC_ENABLE bit 18, according to SDM:

| When this bit is set to 0, the MONITOR feature flag is not set (CPUID.01H:ECX[bit 3] = 0).
| This indicates that MONITOR/MWAIT are not supported.
|
| Software attempts to execute MONITOR/MWAIT will cause #UD when this bit is 0.
|
| When this bit is set to 1 (default), MONITOR/MWAIT are supported (CPUID.01H:ECX[bit 3] = 1).

The CPUID.01H:ECX[bit 3] ought to mirror the value of the MSR bit,
CPUID.01H:ECX[bit 3] is a better guard than kvm_mwait_in_guest().
kvm_mwait_in_guest() affects the behavior of MONITOR/MWAIT, not its
guest visibility.

This patch implements toggling of the CPUID bit based on guest writes
to the MSR.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Liran Alon <liran.alon@oracle.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
[Fixes for backwards compatibility - Paolo]
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
arch/x86/include/uapi/asm/kvm.h
arch/x86/kvm/cpuid.c
arch/x86/kvm/x86.c