• Hou Wenlong's avatar
    KVM: x86: Use different callback if msr access comes from the emulator · d2f7d498
    Hou Wenlong authored
    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: default avatarSean Christopherson <seanjc@google.com>
    Signed-off-by: default avatarHou Wenlong <houwenlong93@linux.alibaba.com>
    Signed-off-by: default avatarPaolo Bonzini <pbonzini@redhat.com>
    Message-Id: <34208da8f51580a06e45afefac95afea0e3f96e3.1635842679.git.houwenlong93@linux.alibaba.com>
    d2f7d498
x86.c 333 KB