]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: x86: Use different callback if msr access comes from the emulator
authorHou Wenlong <houwenlong93@linux.alibaba.com>
Tue, 2 Nov 2021 09:15:31 +0000 (17:15 +0800)
committerPaolo Bonzini <pbonzini@redhat.com>
Wed, 8 Dec 2021 09:25:16 +0000 (04:25 -0500)
commit602aa9375ff95eacc946dbfd5e284cc231dd37af
treec6e432705d61364c4b5d68924123978f63e81390
parenta85b2d222ccefb09b476e8ee093ca716a2d1cdbf
KVM: x86: Use different callback if msr access comes from the emulator

If msr access triggers an exit to userspace, the
complete_userspace_io callback would skip instruction by vendor
callback for kvm_skip_emulated_instruction(). However, when msr
access comes from the emulator, e.g. if kvm.force_emulation_prefix
is enabled and the guest uses rdmsr/wrmsr with kvm prefix,
VM_EXIT_INSTRUCTION_LEN in vmcs is invalid and
kvm_emulate_instruction() should be used to skip instruction
instead.

As Sean noted, unlike the previous case, there's no #UD if
unrestricted guest is disabled and the guest accesses an MSR in
Big RM. So the correct way to fix this is to attach a different
callback when the msr access comes from the emulator.

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Hou Wenlong <houwenlong93@linux.alibaba.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Message-Id: <34208da8f51580a06e45afefac95afea0e3f96e3.1635842679.git.houwenlong93@linux.alibaba.com>
arch/x86/kvm/x86.c