KVM: SVM: avoid emulation with stale next_rip
authorWanpeng Li <kernellwpQ@gmail.com>
Sat, 12 Sep 2020 06:16:39 +0000 (02:16 -0400)
committerPaolo Bonzini <pbonzini@redhat.com>
Sat, 12 Sep 2020 06:19:23 +0000 (02:19 -0400)
commite42c68281b444f9a20d72a062f8c6fd0d31e4de8
tree67741349b8710c32ef6367662ed7eb062955826f
parentd831de177217cd494bfb99f2c849a0d40c2a7890
KVM: SVM: avoid emulation with stale next_rip

svm->next_rip is reset in svm_vcpu_run() only after calling
svm_exit_handlers_fastpath(), which will cause SVM's
skip_emulated_instruction() to write a stale RIP.

We can move svm_exit_handlers_fastpath towards the end of
svm_vcpu_run().  To align VMX with SVM, keep svm_complete_interrupts()
close as well.

Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
Cc: Paul K. <kronenpj@kronenpj.dyndns.org>
Reviewed-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
[Also move vmcb_mark_all_clean before any possible write to the VMCB.
 - Paolo]
arch/x86/kvm/svm/svm.c