Skip to content

Commit ff24148

Browse files
Sean Christophersonbonzini
authored andcommitted
KVM: nVMX: Move "vmcs12 to shadow/evmcs sync" to helper function
...so that the function doesn't need to be created when moving the nested code out of vmx.c. Signed-off-by: Sean Christopherson <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 3e8eacc commit ff24148

File tree

1 file changed

+26
-20
lines changed

1 file changed

+26
-20
lines changed

arch/x86/kvm/vmx/vmx.c

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9113,6 +9113,30 @@ static void vmx_update_hv_timer(struct kvm_vcpu *vcpu)
91139113
vmx->loaded_vmcs->hv_timer_armed = false;
91149114
}
91159115

9116+
static void nested_sync_from_vmcs12(struct kvm_vcpu *vcpu)
9117+
{
9118+
struct vcpu_vmx *vmx = to_vmx(vcpu);
9119+
9120+
/*
9121+
* hv_evmcs may end up being not mapped after migration (when
9122+
* L2 was running), map it here to make sure vmcs12 changes are
9123+
* properly reflected.
9124+
*/
9125+
if (vmx->nested.enlightened_vmcs_enabled && !vmx->nested.hv_evmcs)
9126+
nested_vmx_handle_enlightened_vmptrld(vcpu, false);
9127+
9128+
if (vmx->nested.hv_evmcs) {
9129+
copy_vmcs12_to_enlightened(vmx);
9130+
/* All fields are clean */
9131+
vmx->nested.hv_evmcs->hv_clean_fields |=
9132+
HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL;
9133+
} else {
9134+
copy_vmcs12_to_shadow(vmx);
9135+
}
9136+
9137+
vmx->nested.need_vmcs12_sync = false;
9138+
}
9139+
91169140
static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
91179141
{
91189142
struct vcpu_vmx *vmx = to_vmx(vcpu);
@@ -9133,26 +9157,8 @@ static void __noclone vmx_vcpu_run(struct kvm_vcpu *vcpu)
91339157
vmcs_write32(PLE_WINDOW, vmx->ple_window);
91349158
}
91359159

9136-
if (vmx->nested.need_vmcs12_sync) {
9137-
/*
9138-
* hv_evmcs may end up being not mapped after migration (when
9139-
* L2 was running), map it here to make sure vmcs12 changes are
9140-
* properly reflected.
9141-
*/
9142-
if (vmx->nested.enlightened_vmcs_enabled &&
9143-
!vmx->nested.hv_evmcs)
9144-
nested_vmx_handle_enlightened_vmptrld(vcpu, false);
9145-
9146-
if (vmx->nested.hv_evmcs) {
9147-
copy_vmcs12_to_enlightened(vmx);
9148-
/* All fields are clean */
9149-
vmx->nested.hv_evmcs->hv_clean_fields |=
9150-
HV_VMX_ENLIGHTENED_CLEAN_FIELD_ALL;
9151-
} else {
9152-
copy_vmcs12_to_shadow(vmx);
9153-
}
9154-
vmx->nested.need_vmcs12_sync = false;
9155-
}
9160+
if (vmx->nested.need_vmcs12_sync)
9161+
nested_sync_from_vmcs12(vcpu);
91569162

91579163
if (test_bit(VCPU_REGS_RSP, (unsigned long *)&vcpu->arch.regs_dirty))
91589164
vmcs_writel(GUEST_RSP, vcpu->arch.regs[VCPU_REGS_RSP]);

0 commit comments

Comments
 (0)