x86/VMX: don't needlessly install VMFUNC emulation hook Instead of checking cpu_has_vmx_vmfunc inside the hook, use it to determine whether to install the hook in the first place. Signed-off-by: Jan Beulich --- a/xen/arch/x86/hvm/vmx/vmx.c +++ b/xen/arch/x86/hvm/vmx/vmx.c @@ -2011,7 +2011,7 @@ static int vmx_vcpu_emulate_vmfunc(const int rc = X86EMUL_EXCEPTION; struct vcpu *curr = current; - if ( !cpu_has_vmx_vmfunc && altp2m_active(curr->domain) && + if ( altp2m_active(curr->domain) && regs->_eax == 0 && p2m_switch_vcpu_altp2m_by_id(curr, regs->_ecx) ) rc = X86EMUL_OKAY; @@ -2155,7 +2155,6 @@ static struct hvm_function_table __initd .altp2m_vcpu_update_p2m = vmx_vcpu_update_eptp, .altp2m_vcpu_update_vmfunc_ve = vmx_vcpu_update_vmfunc_ve, .altp2m_vcpu_emulate_ve = vmx_vcpu_emulate_ve, - .altp2m_vcpu_emulate_vmfunc = vmx_vcpu_emulate_vmfunc, .tsc_scaling = { .max_ratio = VMX_TSC_MULTIPLIER_MAX, .setup = vmx_setup_tsc_scaling, @@ -2308,6 +2307,9 @@ const struct hvm_function_table * __init vmx_function_table.get_guest_bndcfgs = vmx_get_guest_bndcfgs; } + if ( !cpu_has_vmx_vmfunc ) + vmx_function_table.altp2m_vcpu_emulate_vmfunc = vmx_vcpu_emulate_vmfunc; + setup_vmcs_dump(); return &vmx_function_table;