direct-io.hg

changeset 15450:b528cb182cc7

vmx: Use per-cpu vmcs pointer to avoid unnecessary vmcs loading in
vmx_do_resume().
Signed-off-by: Eric Liu <eric.e.liu@intel.com>
author kfraser@localhost.localdomain
date Tue Jul 03 10:29:55 2007 +0100 (2007-07-03)
parents 1e04c4be12aa
children 647f9671dc44
files xen/arch/x86/hvm/vmx/vmcs.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Tue Jul 03 10:21:21 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Tue Jul 03 10:29:55 2007 +0100
     1.3 @@ -45,6 +45,8 @@ u32 vmx_vmexit_control __read_mostly;
     1.4  u32 vmx_vmentry_control __read_mostly;
     1.5  bool_t cpu_has_vmx_ins_outs_instr_info __read_mostly;
     1.6  
     1.7 +static DEFINE_PER_CPU(struct vmcs_struct *, current_vmcs);
     1.8 +
     1.9  static u32 vmcs_revision_id __read_mostly;
    1.10  
    1.11  static u32 adjust_vmx_controls(u32 ctl_min, u32 ctl_opt, u32 msr)
    1.12 @@ -180,6 +182,9 @@ static void __vmx_clear_vmcs(void *info)
    1.13  
    1.14      v->arch.hvm_vmx.active_cpu = -1;
    1.15      v->arch.hvm_vmx.launched   = 0;
    1.16 +
    1.17 +    if ( v->arch.hvm_vmx.vmcs == this_cpu(current_vmcs) )
    1.18 +        this_cpu(current_vmcs) = NULL;
    1.19  }
    1.20  
    1.21  static void vmx_clear_vmcs(struct vcpu *v)
    1.22 @@ -199,6 +204,7 @@ static void vmx_load_vmcs(struct vcpu *v
    1.23  {
    1.24      __vmptrld(virt_to_maddr(v->arch.hvm_vmx.vmcs));
    1.25      v->arch.hvm_vmx.active_cpu = smp_processor_id();
    1.26 +    this_cpu(current_vmcs) = v->arch.hvm_vmx.vmcs;
    1.27  }
    1.28  
    1.29  void vmx_vmcs_enter(struct vcpu *v)
    1.30 @@ -512,7 +518,8 @@ void vmx_do_resume(struct vcpu *v)
    1.31  
    1.32      if ( v->arch.hvm_vmx.active_cpu == smp_processor_id() )
    1.33      {
    1.34 -        vmx_load_vmcs(v);
    1.35 +        if ( v->arch.hvm_vmx.vmcs != this_cpu(current_vmcs) )
    1.36 +            vmx_load_vmcs(v);
    1.37      }
    1.38      else
    1.39      {