KVM: nVMX: Lift sync_vmcs12() out of prepare_vmcs12()

... to make it more obvious that sync_vmcs12() is invoked on all nested
VM-Exits, e.g. hiding sync_vmcs12() in prepare_vmcs12() makes it appear
that guest state is NOT propagated to vmcs12 for a normal VM-Exit.

Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
Sean Christopherson 2019-05-07 08:36:26 -07:00 committed by Paolo Bonzini
parent 1c6f0b47fb
commit f4f8316d2a
1 changed files with 3 additions and 7 deletions

View File

@ -3500,11 +3500,7 @@ static void prepare_vmcs12(struct kvm_vcpu *vcpu, struct vmcs12 *vmcs12,
u32 exit_reason, u32 exit_intr_info, u32 exit_reason, u32 exit_intr_info,
unsigned long exit_qualification) unsigned long exit_qualification)
{ {
/* update guest state fields: */
sync_vmcs12(vcpu, vmcs12);
/* update exit information fields: */ /* update exit information fields: */
vmcs12->vm_exit_reason = exit_reason; vmcs12->vm_exit_reason = exit_reason;
vmcs12->exit_qualification = exit_qualification; vmcs12->exit_qualification = exit_qualification;
vmcs12->vm_exit_intr_info = exit_intr_info; vmcs12->vm_exit_intr_info = exit_intr_info;
@ -3865,9 +3861,9 @@ void nested_vmx_vmexit(struct kvm_vcpu *vcpu, u32 exit_reason,
vcpu->arch.tsc_offset -= vmcs12->tsc_offset; vcpu->arch.tsc_offset -= vmcs12->tsc_offset;
if (likely(!vmx->fail)) { if (likely(!vmx->fail)) {
if (exit_reason == -1) sync_vmcs12(vcpu, vmcs12);
sync_vmcs12(vcpu, vmcs12);
else if (exit_reason != -1)
prepare_vmcs12(vcpu, vmcs12, exit_reason, exit_intr_info, prepare_vmcs12(vcpu, vmcs12, exit_reason, exit_intr_info,
exit_qualification); exit_qualification);