ia64/xen-unstable

changeset 15383:5794f9b80c3f

hvm: Fix deadlock in vpt.c and clean up some more.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Jun 19 14:52:53 2007 +0100 (2007-06-19)
parents 75d82009ec70
children 8eaee9ef472f
files xen/arch/x86/hvm/vpt.c
line diff
     1.1 --- a/xen/arch/x86/hvm/vpt.c	Tue Jun 19 11:06:25 2007 +0100
     1.2 +++ b/xen/arch/x86/hvm/vpt.c	Tue Jun 19 14:52:53 2007 +0100
     1.3 @@ -227,13 +227,10 @@ void pt_reset(struct vcpu *v)
     1.4  
     1.5      list_for_each_entry ( pt, head, list )
     1.6      {
     1.7 -        if ( pt->enabled )
     1.8 -        {
     1.9 -            pt->pending_intr_nr = 0;
    1.10 -            pt->last_plt_gtime = hvm_get_guest_time(pt->vcpu);
    1.11 -            pt->scheduled = NOW() + pt->period;
    1.12 -            set_timer(&pt->timer, pt->scheduled);
    1.13 -        }
    1.14 +        pt->pending_intr_nr = 0;
    1.15 +        pt->last_plt_gtime = hvm_get_guest_time(pt->vcpu);
    1.16 +        pt->scheduled = NOW() + pt->period;
    1.17 +        set_timer(&pt->timer, pt->scheduled);
    1.18      }
    1.19  
    1.20      spin_unlock(&v->arch.hvm_vcpu.tm_lock);
    1.21 @@ -247,10 +244,7 @@ void pt_migrate(struct vcpu *v)
    1.22      spin_lock(&v->arch.hvm_vcpu.tm_lock);
    1.23  
    1.24      list_for_each_entry ( pt, head, list )
    1.25 -    {
    1.26 -        if ( pt->enabled )
    1.27 -            migrate_timer(&pt->timer, v->processor);
    1.28 -    }
    1.29 +        migrate_timer(&pt->timer, v->processor);
    1.30  
    1.31      spin_unlock(&v->arch.hvm_vcpu.tm_lock);
    1.32  }
    1.33 @@ -263,8 +257,9 @@ void create_periodic_time(
    1.34  
    1.35      spin_lock(&v->arch.hvm_vcpu.tm_lock);
    1.36  
    1.37 -    init_timer(&pt->timer, pt_timer_fn, pt, v->processor);
    1.38      pt->enabled = 1;
    1.39 +    pt->pending_intr_nr = 0;
    1.40 +
    1.41      if ( period < 900000 ) /* < 0.9 ms */
    1.42      {
    1.43          gdprintk(XENLOG_WARNING,
    1.44 @@ -283,6 +278,8 @@ void create_periodic_time(
    1.45      pt->priv = data;
    1.46  
    1.47      list_add(&pt->list, &v->arch.hvm_vcpu.tm_list);
    1.48 +
    1.49 +    init_timer(&pt->timer, pt_timer_fn, pt, v->processor);
    1.50      set_timer(&pt->timer, pt->scheduled);
    1.51  
    1.52      spin_unlock(&v->arch.hvm_vcpu.tm_lock);
    1.53 @@ -295,8 +292,12 @@ void destroy_periodic_time(struct period
    1.54  
    1.55      pt_lock(pt);
    1.56      pt->enabled = 0;
    1.57 -    pt->pending_intr_nr = 0;
    1.58      list_del(&pt->list);
    1.59 +    pt_unlock(pt);
    1.60 +
    1.61 +    /*
    1.62 +     * pt_timer_fn() can run until this kill_timer() returns. We must do this
    1.63 +     * outside pt_lock() otherwise we can deadlock with pt_timer_fn().
    1.64 +     */
    1.65      kill_timer(&pt->timer);
    1.66 -    pt_unlock(pt);
    1.67  }