ia64/xen-unstable

changeset 8806:26befe042dd5

Fix CPU-migration of VMX domains.

Signed-off-by: Yunhong Jiang <yunhong.jiang@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Thu Feb 09 12:10:28 2006 +0100 (2006-02-09)
parents 01fa38f79207
children 10d6c1dc1bc7
files xen/arch/x86/hvm/vmx/vmcs.c xen/arch/x86/hvm/vmx/vmx.c xen/include/asm-x86/hvm/vmx/vmcs.h xen/include/asm-x86/hvm/vmx/vmx.h
line diff
     1.1 --- a/xen/arch/x86/hvm/vmx/vmcs.c	Thu Feb 09 11:32:17 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/vmx/vmcs.c	Thu Feb 09 12:10:28 2006 +0100
     1.3 @@ -75,6 +75,26 @@ static int load_vmcs(struct arch_vmx_str
     1.4      return 0;
     1.5  }
     1.6  
     1.7 +static void vmx_smp_clear_vmcs(void *info)
     1.8 +{
     1.9 +    struct vcpu *v = (struct vcpu *)info;
    1.10 +
    1.11 +    ASSERT(HVM_DOMAIN(v));
    1.12 +
    1.13 +    if (v->arch.hvm_vmx.launch_cpu == smp_processor_id())
    1.14 +        __vmpclear(virt_to_maddr(v->arch.hvm_vmx.vmcs));
    1.15 +}
    1.16 +
    1.17 +void vmx_request_clear_vmcs(struct vcpu *v)
    1.18 +{
    1.19 +    ASSERT(HVM_DOMAIN(v));
    1.20 +
    1.21 +    if (v->arch.hvm_vmx.launch_cpu == smp_processor_id())
    1.22 +        __vmpclear(virt_to_maddr(v->arch.hvm_vmx.vmcs));
    1.23 +    else
    1.24 +        smp_call_function(vmx_smp_clear_vmcs, v, 1, 1);
    1.25 +}
    1.26 +
    1.27  #if 0
    1.28  static int store_vmcs(struct arch_vmx_struct *arch_vmx, u64 phys_ptr)
    1.29  {
    1.30 @@ -167,6 +187,7 @@ static void vmx_set_host_env(struct vcpu
    1.31      host_env.tr_base = (unsigned long) &init_tss[cpu];
    1.32      error |= __vmwrite(HOST_TR_SELECTOR, host_env.tr_selector);
    1.33      error |= __vmwrite(HOST_TR_BASE, host_env.tr_base);
    1.34 +    error |= __vmwrite(HOST_RSP, (unsigned long)get_stack_bottom());
    1.35  }
    1.36  
    1.37  static void vmx_do_launch(struct vcpu *v)
    1.38 @@ -212,7 +233,6 @@ static void vmx_do_launch(struct vcpu *v
    1.39      shadow_direct_map_init(v);
    1.40      __vmwrite(GUEST_CR3, pagetable_get_paddr(v->domain->arch.phys_table));
    1.41      __vmwrite(HOST_CR3, pagetable_get_paddr(v->arch.monitor_table));
    1.42 -    __vmwrite(HOST_RSP, (unsigned long)get_stack_bottom());
    1.43  
    1.44      v->arch.schedule_tail = arch_vmx_do_resume;
    1.45      v->arch.hvm_vmx.launch_cpu = smp_processor_id();
    1.46 @@ -510,10 +530,11 @@ void arch_vmx_do_resume(struct vcpu *v)
    1.47      }
    1.48      else
    1.49      {
    1.50 -        __vmpclear(virt_to_maddr(v->arch.hvm_vmx.vmcs));
    1.51 +        vmx_request_clear_vmcs(v);
    1.52          load_vmcs(&v->arch.hvm_vmx, virt_to_maddr(v->arch.hvm_vmx.vmcs));
    1.53 +        vmx_migrate_timers(v);
    1.54 +        vmx_set_host_env(v);
    1.55          vmx_do_resume(v);
    1.56 -        vmx_set_host_env(v);
    1.57          v->arch.hvm_vmx.launch_cpu = smp_processor_id();
    1.58          reset_stack_and_jump(vmx_asm_do_relaunch);
    1.59      }
     2.1 --- a/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 09 11:32:17 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/vmx/vmx.c	Thu Feb 09 12:10:28 2006 +0100
     2.3 @@ -91,6 +91,7 @@ void vmx_relinquish_resources(struct vcp
     2.4  	        (void *)d->arch.hvm_domain.shared_page_va);
     2.5      }
     2.6  
     2.7 +    vmx_request_clear_vmcs(v);
     2.8      destroy_vmcs(&v->arch.hvm_vmx);
     2.9      free_monitor_pagetable(v);
    2.10      vpit = &v->domain->arch.hvm_domain.vpit;
    2.11 @@ -338,6 +339,16 @@ int vmx_relinquish_guest_resources(struc
    2.12      return 1;
    2.13  }
    2.14  
    2.15 +void vmx_migrate_timers(struct vcpu *v)
    2.16 +{
    2.17 +    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
    2.18 +
    2.19 +    migrate_timer(&vpit->pit_timer, v->processor);
    2.20 +    migrate_timer(&v->arch.hvm_vmx.hlt_timer, v->processor);
    2.21 +    if ( hvm_apic_support(v->domain) && VLAPIC(v))
    2.22 +        migrate_timer(&(VLAPIC(v)->vlapic_timer), v->processor);
    2.23 +}
    2.24 +
    2.25  void vmx_store_cpu_guest_regs(struct vcpu *v, struct cpu_user_regs *regs)
    2.26  {
    2.27  #if defined (__x86_64__)
     3.1 --- a/xen/include/asm-x86/hvm/vmx/vmcs.h	Thu Feb 09 11:32:17 2006 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/vmx/vmcs.h	Thu Feb 09 12:10:28 2006 +0100
     3.3 @@ -95,6 +95,8 @@ int modify_vmcs(struct arch_vmx_struct *
     3.4                  struct cpu_user_regs *regs);
     3.5  void destroy_vmcs(struct arch_vmx_struct *arch_vmx);
     3.6  
     3.7 +extern void vmx_request_clear_vmcs(struct vcpu *v);
     3.8 +
     3.9  #define VMCS_USE_HOST_ENV       1
    3.10  #define VMCS_USE_SEPARATE_ENV   0
    3.11  
     4.1 --- a/xen/include/asm-x86/hvm/vmx/vmx.h	Thu Feb 09 11:32:17 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/vmx/vmx.h	Thu Feb 09 12:10:28 2006 +0100
     4.3 @@ -31,7 +31,7 @@ extern void vmx_asm_do_resume(void);
     4.4  extern void vmx_asm_do_launch(void);
     4.5  extern void vmx_intr_assist(void);
     4.6  extern void vmx_set_tsc_shift(struct vcpu *, struct hvm_virpit *);
     4.7 -
     4.8 +extern void vmx_migrate_timers(struct vcpu *v);
     4.9  extern void arch_vmx_do_launch(struct vcpu *);
    4.10  extern void arch_vmx_do_resume(struct vcpu *);
    4.11