From: Andrew Cooper Date: Mon, 28 May 2018 14:02:34 +0000 (+0100) Subject: x86/vmx: Defer vmx_vmcs_exit() as long as possible in construct_vmcs() X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=3bd7cf6a11769e898c3869ef3f790f23eb7daf2b;p=xen.git x86/vmx: Defer vmx_vmcs_exit() as long as possible in construct_vmcs() paging_update_paging_modes() and vmx_vlapic_msr_changed() both operate on the VMCS being constructed. Avoid dropping and re-acquiring the reference multiple times. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Acked-by: Kevin Tian (cherry picked from commit f30e3cf34042846e391e3f8361fc6a76d181a7ee) --- diff --git a/xen/arch/x86/hvm/vmx/vmcs.c b/xen/arch/x86/hvm/vmx/vmcs.c index 60ef8a8c5b..d419f80be3 100644 --- a/xen/arch/x86/hvm/vmx/vmcs.c +++ b/xen/arch/x86/hvm/vmx/vmcs.c @@ -983,6 +983,7 @@ static int construct_vmcs(struct vcpu *v) unsigned long sysenter_eip; u32 vmexit_ctl = vmx_vmexit_control; u32 vmentry_ctl = vmx_vmentry_control; + int rc = 0; vmx_vmcs_enter(v); @@ -1074,8 +1075,8 @@ static int construct_vmcs(struct vcpu *v) if ( msr_bitmap == NULL ) { - vmx_vmcs_exit(v); - return -ENOMEM; + rc = -ENOMEM; + goto out; } memset(msr_bitmap, ~0, PAGE_SIZE); @@ -1271,8 +1272,6 @@ static int construct_vmcs(struct vcpu *v) if ( cpu_has_vmx_mpx ) __vmwrite(GUEST_BNDCFGS, 0); - vmx_vmcs_exit(v); - /* PVH: paging mode is updated by arch_set_info_guest(). */ if ( is_hvm_domain(d) ) { @@ -1282,7 +1281,10 @@ static int construct_vmcs(struct vcpu *v) vmx_vlapic_msr_changed(v); } - return 0; + out: + vmx_vmcs_exit(v); + + return rc; } int vmx_read_guest_msr(u32 msr, u64 *val)