ia64/xen-unstable

changeset 9061:0820df08a996

Fix SVM guest pin timer migration logic.

Signed-off-by: Tom Woller <thomas.woller@amd.com>
author kaf24@firebug.cl.cam.ac.uk
date Tue Feb 28 10:13:26 2006 +0100 (2006-02-28)
parents 985879d9d935
children 933d0d70378f
files xen/arch/x86/hvm/svm/svm.c xen/arch/x86/hvm/svm/vmcb.c xen/include/asm-x86/hvm/svm/svm.h xen/include/asm-x86/hvm/svm/vmcb.h
line diff
     1.1 --- a/xen/arch/x86/hvm/svm/svm.c	Tue Feb 28 10:12:29 2006 +0100
     1.2 +++ b/xen/arch/x86/hvm/svm/svm.c	Tue Feb 28 10:13:26 2006 +0100
     1.3 @@ -820,8 +820,29 @@ void svm_relinquish_resources(struct vcp
     1.4  
     1.5  void arch_svm_do_resume(struct vcpu *v) 
     1.6  {
     1.7 -    svm_do_resume(v);
     1.8 -    reset_stack_and_jump(svm_asm_do_resume);
     1.9 +    /* pinning VCPU to a different core? */
    1.10 +    if ( v->arch.hvm_svm.launch_core == smp_processor_id()) {
    1.11 +        svm_do_resume( v );
    1.12 +        reset_stack_and_jump( svm_asm_do_resume );
    1.13 +    }
    1.14 +    else {
    1.15 +        printk("VCPU core pinned: %d to %d\n", v->arch.hvm_svm.launch_core, smp_processor_id() );
    1.16 +        v->arch.hvm_svm.launch_core = smp_processor_id();
    1.17 +        svm_migrate_timers( v );
    1.18 +        svm_do_resume( v );
    1.19 +        reset_stack_and_jump( svm_asm_do_resume );
    1.20 +    }
    1.21 +}
    1.22 +
    1.23 +
    1.24 +void svm_migrate_timers(struct vcpu *v)
    1.25 +{
    1.26 +    struct hvm_virpit *vpit = &(v->domain->arch.hvm_domain.vpit);
    1.27 +
    1.28 +    migrate_timer( &vpit->pit_timer, v->processor );
    1.29 +    migrate_timer( &v->arch.hvm_svm.hlt_timer, v->processor );
    1.30 +    if ( hvm_apic_support(v->domain) && VLAPIC( v ))
    1.31 +        migrate_timer( &(VLAPIC(v)->vlapic_timer ), v->processor );
    1.32  }
    1.33  
    1.34  
    1.35 @@ -2668,26 +2689,23 @@ asmlinkage void svm_asid(void)
    1.36  {
    1.37      struct vcpu *v = current;
    1.38      struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    1.39 -    int core = smp_processor_id();
    1.40 -    int oldcore = v->arch.hvm_svm.core; 
    1.41 -    /* 
    1.42 -     * if need to assign new asid or if switching cores, 
    1.43 -     * then retire asid for old core, and assign new for new core.
    1.44 -     */
    1.45 -    if( v->arch.hvm_svm.core != core ) {
    1.46 -        if (svm_dbg_on)
    1.47 -            printk("old core %d new core %d\n",(int)v->arch.hvm_svm.core,(int)core);
    1.48 -        v->arch.hvm_svm.core = core;
    1.49 -    }
    1.50 -    if( test_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags) ||
    1.51 -          (oldcore != core)) {
    1.52 -        if(!asidpool_assign_next(vmcb, 1, 
    1.53 -	            oldcore, core)) {
    1.54 +
    1.55 +   /*
    1.56 +    * if need to assign new asid, or if switching cores,
    1.57 +    * retire asid for the old core, and assign a new asid to the current core.
    1.58 +    */
    1.59 +    if ( test_bit( ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags ) ||
    1.60 +       ( v->arch.hvm_svm.asid_core != v->arch.hvm_svm.launch_core )) {
    1.61 +        /* recycle asid */
    1.62 +        if ( !asidpool_assign_next( vmcb, 1,
    1.63 +	     v->arch.hvm_svm.asid_core, v->arch.hvm_svm.launch_core )) {
    1.64              /* If we get here, we have a major problem */
    1.65              domain_crash_synchronous();
    1.66          }
    1.67 +
    1.68 +        v->arch.hvm_svm.asid_core = v->arch.hvm_svm.launch_core;
    1.69 +        clear_bit( ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags );
    1.70      }
    1.71 -    clear_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags);
    1.72  }
    1.73  
    1.74  /*
     2.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Tue Feb 28 10:12:29 2006 +0100
     2.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Tue Feb 28 10:13:26 2006 +0100
     2.3 @@ -306,7 +306,7 @@ void destroy_vmcb(struct arch_svm_struct
     2.4  {
     2.5      if(arch_svm->vmcb != NULL)
     2.6      {
     2.7 -        asidpool_retire(arch_svm->vmcb, arch_svm->core);
     2.8 +        asidpool_retire(arch_svm->vmcb, arch_svm->asid_core);
     2.9           free_vmcb(arch_svm->vmcb);
    2.10      }
    2.11      if(arch_svm->iopm != NULL) {
    2.12 @@ -404,18 +404,17 @@ err_out:
    2.13  
    2.14  void svm_do_launch(struct vcpu *v)
    2.15  {
    2.16 -    /* Update CR3, GDT, LDT, TR */
    2.17 -    struct vmcb_struct *vmcb;
    2.18 +    struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
    2.19      int core = smp_processor_id();
    2.20 -    vmcb = v->arch.hvm_svm.vmcb;
    2.21      ASSERT(vmcb);
    2.22  
    2.23 +    /* Update CR3, GDT, LDT, TR */
    2.24      svm_stts(v);
    2.25  
    2.26 -    /* current core is the one we will perform the vmrun on */
    2.27 -    v->arch.hvm_svm.core = core;
    2.28 +    /* current core is the one we intend to perform the VMRUN on */
    2.29 +    v->arch.hvm_svm.launch_core = v->arch.hvm_svm.asid_core = core;
    2.30      clear_bit(ARCH_SVM_VMCB_ASSIGN_ASID, &v->arch.hvm_svm.flags);
    2.31 -    if ( !asidpool_assign_next(vmcb, 0, core, core) )
    2.32 +    if ( !asidpool_assign_next( vmcb, 0, core, core ))
    2.33          BUG();
    2.34  
    2.35      if (v->vcpu_id == 0)
     3.1 --- a/xen/include/asm-x86/hvm/svm/svm.h	Tue Feb 28 10:12:29 2006 +0100
     3.2 +++ b/xen/include/asm-x86/hvm/svm/svm.h	Tue Feb 28 10:13:26 2006 +0100
     3.3 @@ -54,6 +54,8 @@ extern int load_vmcb(struct arch_svm_str
     3.4  /* For debugging. Remove when no longer needed. */
     3.5  extern void svm_dump_host_regs(const char *from);
     3.6  
     3.7 +extern void svm_migrate_timers(struct vcpu *v);
     3.8 +
     3.9  /* ASID API */
    3.10  enum {
    3.11      ASID_AVAILABLE = 0,
     4.1 --- a/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Feb 28 10:12:29 2006 +0100
     4.2 +++ b/xen/include/asm-x86/hvm/svm/vmcb.h	Tue Feb 28 10:13:26 2006 +0100
     4.3 @@ -457,7 +457,8 @@ struct arch_svm_struct {
     4.4      u64                 vmexit_tsc; /* tsc read at #VMEXIT. for TSC_OFFSET */
     4.5      int                 injecting_event;
     4.6      int                 saved_irq_vector;
     4.7 -    u32                 core;        /* cpu of last vmexit */
     4.8 +    u32                 launch_core;
     4.9 +    u32                 asid_core;
    4.10      
    4.11      unsigned long       flags;      /* VMCB flags */
    4.12      unsigned long       cpu_shadow_cr0; /* copy of guest read shadow CR0 */