]> git.proxmox.com Git - mirror_ubuntu-kernels.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)
commitd2f7d49826ae62b8b5c9829292e84861d2bda2b6
treec6e432705d61364c4b5d68924123978f63e81390
parent906fa90416fdb703467926ca4f6f55438cd7ea82
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