ia64/xen-unstable

changeset 2379:f5ee3532bda7

bitkeeper revision 1.1159.53.16 (412f5ad1ywvFe397tLXQvP43KuI7TA)

Merge freefall.cl.cam.ac.uk:/auto/groups/xeno/BK/xeno.bk
into freefall.cl.cam.ac.uk:/auto/groups/xeno/users/kaf24/xeno
author kaf24@freefall.cl.cam.ac.uk
date Fri Aug 27 16:01:21 2004 +0000 (2004-08-27)
parents 6090073bceb8 64ae61ad91a7
children 7d71d261a98a
files xen/arch/x86/shadow.c xen/common/kernel.c xen/include/asm-x86/shadow.h xen/include/xen/spinlock.h
line diff
     1.1 --- a/xen/arch/x86/shadow.c	Fri Aug 27 15:57:33 2004 +0000
     1.2 +++ b/xen/arch/x86/shadow.c	Fri Aug 27 16:01:21 2004 +0000
     1.3 @@ -443,7 +443,7 @@ int shadow_mode_control(struct domain *d
     1.4      domain_pause(d);
     1.5      synchronise_pagetables(~0UL);
     1.6  
     1.7 -    spin_lock(&d->mm.shadow_lock);
     1.8 +    shadow_lock(&d->mm);
     1.9  
    1.10      if ( cmd == DOM0_SHADOW_CONTROL_OP_OFF )
    1.11      {
    1.12 @@ -470,7 +470,7 @@ int shadow_mode_control(struct domain *d
    1.13          rc = -EINVAL;
    1.14      }
    1.15  
    1.16 -    spin_unlock(&d->mm.shadow_lock);
    1.17 +    shadow_unlock(&d->mm);
    1.18  
    1.19      domain_unpause(d);
    1.20  
    1.21 @@ -620,19 +620,19 @@ int shadow_fault( unsigned long va, long
    1.22  
    1.23      // take the lock and reread gpte
    1.24  
    1.25 -	spin_lock(&current->mm.shadow_lock);
    1.26 +    shadow_lock(m);
    1.27  	
    1.28      if ( unlikely(__get_user(gpte, (unsigned long*)&linear_pg_table[va>>PAGE_SHIFT])) )
    1.29      {
    1.30          SH_VVLOG("shadow_fault - EXIT: read gpte faulted" );
    1.31 -        spin_unlock(&m->shadow_lock);
    1.32 +        shadow_unlock(m);
    1.33          return 0;  // propagate to guest
    1.34      }
    1.35  
    1.36      if ( unlikely(!(gpte & _PAGE_PRESENT)) )
    1.37      {
    1.38          SH_VVLOG("shadow_fault - EXIT: gpte not present (%lx)",gpte );
    1.39 -        spin_unlock(&m->shadow_lock);
    1.40 +        shadow_unlock(m);
    1.41          return 0;  // we're not going to be able to help
    1.42      }
    1.43  
    1.44 @@ -645,7 +645,7 @@ int shadow_fault( unsigned long va, long
    1.45          else
    1.46          {   // write fault on RO page
    1.47              SH_VVLOG("shadow_fault - EXIT: write fault on RO page (%lx)",gpte );
    1.48 -            spin_unlock(&m->shadow_lock);
    1.49 +            shadow_unlock(m);
    1.50              return 0; // propagate to guest
    1.51              // not clear whether we should set accessed bit here...
    1.52          }
    1.53 @@ -737,7 +737,7 @@ int shadow_fault( unsigned long va, long
    1.54  
    1.55      check_pagetable( current, current->mm.pagetable, "post-sf" );
    1.56  
    1.57 -    spin_unlock(&m->shadow_lock);
    1.58 +    shadow_unlock(m);
    1.59  
    1.60      return 1; // let's try the faulting instruction again...
    1.61  
     2.1 --- a/xen/common/kernel.c	Fri Aug 27 15:57:33 2004 +0000
     2.2 +++ b/xen/common/kernel.c	Fri Aug 27 16:01:21 2004 +0000
     2.3 @@ -396,12 +396,20 @@ long do_ni_hypercall(void)
     2.4  
     2.5  #ifndef NDEBUG
     2.6  
     2.7 -static int crit_count[NR_CPUS];
     2.8 -static int crit_checking = 1;
     2.9 +static int crit_count[NR_CPUS], crit_checking_disabled[NR_CPUS];
    2.10  
    2.11  void disable_criticalregion_checking(void)
    2.12  {
    2.13 -    crit_checking = 0;
    2.14 +    int cpu = smp_processor_id();
    2.15 +    ASSERT(crit_checking_disabled[cpu] >= 0);
    2.16 +    crit_checking_disabled[cpu]++;
    2.17 +}
    2.18 +
    2.19 +void enable_criticalregion_checking(void)
    2.20 +{
    2.21 +    int cpu = smp_processor_id();
    2.22 +    crit_checking_disabled[cpu]--;
    2.23 +    ASSERT(crit_checking_disabled[cpu] >= 0);
    2.24  }
    2.25  
    2.26  void criticalregion_enter(void)
    2.27 @@ -421,7 +429,7 @@ void criticalregion_exit(void)
    2.28  void ASSERT_no_criticalregion(void)
    2.29  {
    2.30      int cpu = smp_processor_id();
    2.31 -    if ( (crit_count[cpu] == 0) || !crit_checking )
    2.32 +    if ( (crit_count[cpu] == 0) || crit_checking_disabled[cpu] )
    2.33          return;
    2.34      disable_criticalregion_checking();
    2.35      ASSERT(crit_count[cpu] >= 0); /* -ve count is a special kind of bogus! */
     3.1 --- a/xen/include/asm-x86/shadow.h	Fri Aug 27 15:57:33 2004 +0000
     3.2 +++ b/xen/include/asm-x86/shadow.h	Fri Aug 27 16:01:21 2004 +0000
     3.3 @@ -26,6 +26,8 @@
     3.4  
     3.5  #define shadow_mode(_d)      ((_d)->mm.shadow_mode)
     3.6  #define shadow_lock_init(_d) spin_lock_init(&(_d)->mm.shadow_lock)
     3.7 +#define shadow_lock(_m)      spin_lock_nochecking(&(_m)->shadow_lock)
     3.8 +#define shadow_unlock(_m)    spin_unlock_nochecking(&(_m)->shadow_lock)
     3.9  
    3.10  extern void shadow_mode_init(void);
    3.11  extern int shadow_mode_control(struct domain *p, dom0_shadow_control_t *sc);
    3.12 @@ -134,9 +136,9 @@ static inline int mark_dirty( struct mm_
    3.13      int rc;
    3.14      ASSERT(local_irq_is_enabled());
    3.15      //if(spin_is_locked(&m->shadow_lock)) printk("+");
    3.16 -    spin_lock(&m->shadow_lock);
    3.17 +    shadow_lock(m);
    3.18      rc = __mark_dirty( m, mfn );
    3.19 -    spin_unlock(&m->shadow_lock);
    3.20 +    shadow_unlock(m);
    3.21      return rc;
    3.22  }
    3.23  
    3.24 @@ -388,20 +390,21 @@ static inline unsigned long get_shadow_s
    3.25  
    3.26      ASSERT(local_irq_is_enabled());
    3.27      //if(spin_is_locked(&m->shadow_lock)) printk("*");
    3.28 -    spin_lock(&m->shadow_lock);
    3.29 +    shadow_lock(m);
    3.30  
    3.31      if( m->shadow_mode == SHM_logdirty )
    3.32          __mark_dirty( m, gpfn );
    3.33  
    3.34      res = __shadow_status( m, gpfn );
    3.35 -    if (!res) spin_unlock(&m->shadow_lock);
    3.36 +    if (!res) 
    3.37 +        shadow_unlock(m);
    3.38      return res;
    3.39  }
    3.40  
    3.41  
    3.42  static inline void put_shadow_status( struct mm_struct *m )
    3.43  {
    3.44 -    spin_unlock(&m->shadow_lock);
    3.45 +    shadow_unlock(m);
    3.46  }
    3.47  
    3.48  
    3.49 @@ -583,11 +586,9 @@ static inline void shadow_mk_pagetable( 
    3.50      if ( unlikely(mm->shadow_mode) )
    3.51      {
    3.52          ASSERT(local_irq_is_enabled());
    3.53 -        spin_lock(&mm->shadow_lock);
    3.54 -
    3.55 -        __shadow_mk_pagetable( mm );
    3.56 -
    3.57 -        spin_unlock(&mm->shadow_lock);
    3.58 +        shadow_lock(mm);
    3.59 +        __shadow_mk_pagetable(mm);
    3.60 +        shadow_unlock(mm);
    3.61      }
    3.62  
    3.63      SH_VVLOG("leaving shadow_mk_pagetable( gptbase=%08lx, mode=%d ) sh=%08lx",
     4.1 --- a/xen/include/xen/spinlock.h	Fri Aug 27 15:57:33 2004 +0000
     4.2 +++ b/xen/include/xen/spinlock.h	Fri Aug 27 16:01:21 2004 +0000
     4.3 @@ -78,6 +78,7 @@ extern void criticalregion_enter(void);
     4.4  extern void criticalregion_exit(void);
     4.5  extern void ASSERT_no_criticalregion(void);
     4.6  extern void disable_criticalregion_checking(void);
     4.7 +extern void enable_criticalregion_checking(void);
     4.8  
     4.9  #define spin_lock(_lock) \
    4.10      do { criticalregion_enter(); _raw_spin_lock(_lock); } while (0)
    4.11 @@ -111,6 +112,7 @@ static inline int spin_trylock(spinlock_
    4.12  
    4.13  #define ASSERT_no_criticalregion()        ((void)0)
    4.14  #define disable_criticalregion_checking() ((void)0)
    4.15 +#define enable_criticalregion_checking()  ((void)0)
    4.16  
    4.17  #define spin_lock(_lock)             _raw_spin_lock(_lock)
    4.18  #define spin_trylock(_lock)          _raw_spin_trylock(_lock)
    4.19 @@ -124,4 +126,13 @@ static inline int spin_trylock(spinlock_
    4.20  
    4.21  #endif
    4.22  
    4.23 +/*
    4.24 + * Use these if you have taken special care to ensure that certain unsafe
    4.25 + * things can occur in your critical region (e.g., faults, user-space
    4.26 + * accesses). 
    4.27 + */
    4.28 +#define spin_lock_nochecking(_lock)    _raw_spin_lock(_lock)
    4.29 +#define spin_trylock_nochecking(_lock) _raw_spin_trylock(_lock)
    4.30 +#define spin_unlock_nochecking(_lock)  _raw_spin_unlock(_lock)
    4.31 +
    4.32  #endif /* __SPINLOCK_H__ */